PHPackages                             schmosbyy/ai-companion - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. schmosbyy/ai-companion

ActiveLibrary

schmosbyy/ai-companion
======================

AI Companion for your Laravel App

v1.0.0(1y ago)09proprietaryPHP

Since Feb 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/schmosbyy/AiCompanion)[ Packagist](https://packagist.org/packages/schmosbyy/ai-companion)[ RSS](/packages/schmosbyy-ai-companion/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

AI Companion for Laravel
========================

[](#ai-companion-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/defc36856da6eb94654c6f720fb1fcafd58f97e7c87e761cf435102d5ea18cac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363686d6f736279792f61692d636f6d70616e696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schmosbyy/ai-companion) [![Total Downloads](https://camo.githubusercontent.com/62fc3c5318307265943a4c113a1fdd3ec656a6c585bcd2b1b7277091576d7641/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7363686d6f736279792f61692d636f6d70616e696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schmosbyy/ai-companion)

Overview
--------

[](#overview)

**AI Companion** is a Laravel package that enables **natural language to SQL conversion**, executes queries **securely**, and intelligently determines whether to display results as an **HTML table** or **Chart.js visualization**.

This package is designed for developers who want **AI-powered data querying** within their Laravel applications while ensuring **security** and **ease of use**.

[![AI Companion UI](./screenshot.png)](./screenshot.png)

---

Features
--------

[](#features)

✅ Convert **natural language** into **SQL queries** using a local LLM (via Ollama)
✅ Validate SQL queries to **prevent SQL injection**
✅ Automatically select between **HTML tables** and **Chart.js graphs** for the best visualization
✅ Provides a user-friendly **/ai-home** endpoint for executing queries
✅ Supports **configurable AI models**, API endpoints, and execution timeout

---

Installation
------------

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require schmosbyy/ai-companion
```

### Step 2: Configure (Optional)

[](#step-2-configure-optional)

The package works out of the box with **default configurations**, but if you want to modify them, publish the config file:

```
php artisan vendor:publish --tag=ai-config
```

This will create the file:
📄 `config/ai.php`

---

Usage
-----

[](#usage)

### 1️⃣ Start the Local LLM Server

[](#1️⃣-start-the-local-llm-server)

AI Companion requires **Ollama** running as an API server.
Run the following command to **serve the LLM**:

```
ollama serve
```

Ensure that the required model is **downloaded** and available.
To check available models, run:

```
ollama list
```

If the model is missing, download it with:

```
ollama pull qwen2.5-coder:14b
```

---

### 2️⃣ Use the AI Companion

[](#2️⃣-use-the-ai-companion)

Visit:

```
http://your-app.test/ai-home

```

Here, you can enter **natural language queries**, and the AI will:

1. **Convert it into SQL**
2. **Validate the SQL for security**
3. **Run the query safely**
4. **Determine the best visualization** (table or graph)

---

### 3️⃣ Customizing Configurations

[](#3️⃣-customizing-configurations)

By default, the package uses:

```
return [
    'model' => env('AI_MODEL', 'qwen2.5-coder:14b'),
    'api_url' => env('AI_API_URL', 'http://127.0.0.1:11435/api/generate'),
    'timeout' => env('AI_TIMEOUT', 600),
];
```

If you want to **change the AI model** or **API URL**, update your `.env`:

```
AI_MODEL=my-custom-llm
AI_API_URL=http://localhost:1234/api/generate
AI_TIMEOUT=300
```

---

Security
--------

[](#security)

🚨 **SQL Injection Protection**

- The package **only allows SELECT queries**
- It **strictly validates** the query before execution
- Malicious queries (INSERT, DELETE, DROP, etc.) **are blocked**

⚠️ **Additional Best Practices**

- Ensure your **database permissions** restrict unwanted changes
- Always **validate user inputs** before running AI-powered queries

---

License
-------

[](#license)

This project is licensed under the **Prosperity Public License 3.0.0**.
🔹 **Non-commercial use is allowed freely**
🔹 **Commercial use requires explicit permission**

Read the full [LICENSE](LICENSE) file for details.

---

Credits &amp; Attribution
-------------------------

[](#credits--attribution)

This package is inspired by:

- Laravel's built-in **Query Builder**
- **Ollama** for local AI inference

🚀 **Happy Querying!**

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance43

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

457d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/550bc41cb5b55cc74b33ca5ce3e958fa28e6f7b5ee4ac89feb2d2bfe9730bbd3?d=identicon)[schmosbyy](/maintainers/schmosbyy)

---

Top Contributors

[![schmosbyy](https://avatars.githubusercontent.com/u/22574772?v=4)](https://github.com/schmosbyy "schmosbyy (18 commits)")

### Embed Badge

![Health badge](/badges/schmosbyy-ai-companion/health.svg)

```
[![Health](https://phpackages.com/badges/schmosbyy-ai-companion/health.svg)](https://phpackages.com/packages/schmosbyy-ai-companion)
```

###  Alternatives

[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[bayareawebpro/laravel-multistep-forms

Responsable MultiStep Form Builder for Laravel.

967.9k](/packages/bayareawebpro-laravel-multistep-forms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
