PHPackages                             tobiebenezer/php-ai - 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. [Framework](/categories/framework)
4. /
5. tobiebenezer/php-ai

ActiveLibrary[Framework](/categories/framework)

tobiebenezer/php-ai
===================

Laravel 8 compatible AI assistant scaffold.

v1.0.1(today)00proprietaryPHPPHP ^7.3|^8.0

Since Jun 30Pushed todayCompare

[ Source](https://github.com/tobiebenezer/php-ai)[ Packagist](https://packagist.org/packages/tobiebenezer/php-ai)[ RSS](/packages/tobiebenezer-php-ai/feed)WikiDiscussions main Synced today

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

AI Package (`ai`)
=================

[](#ai-package-ai)

This package provides a Laravel-compatible AI Assistant infrastructure designed to integrate LLMs (e.g., OpenRouter, Gemini) with analytical tools and guardrails.

---

Features
--------

[](#features)

- **Multi-Provider Support**: Adapter system supporting OpenRouter and Google Gemini APIs.
- **Dynamic Tool Discovery**: Scans and loads analytical tools automatically.
- **Guardrail Pipeline**: Pre-execution system instructions (`InstructionGuardrail`) and run-time safety check filters (`RuntimeGuardrail`).
- **Interactive Livewire Integration**: Dynamic, user-friendly client-side chat interface.

---

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

[](#installation)

Add the local repository to your host project's `composer.json` file:

```
"repositories": [
    {
        "type": "path",
        "url": "packages/Tobiebenezer/Ai"
    }
]
```

Then install the package:

```
composer require tobiebenezer/calsoft-ai
```

### Configuration &amp; Migrations

[](#configuration--migrations)

Publish the configuration file, migrations, and stubs:

```
# Publish everything
php artisan vendor:publish --provider="Tobiebenezer\Ai\AiServiceProvider"

# Or publish individually
php artisan vendor:publish --tag="calsoft-ai-config"
php artisan vendor:publish --tag="calsoft-ai-migrations"
php artisan vendor:publish --tag="calsoft-ai-stubs"
```

Run the migrations to create the configuration table:

```
php artisan migrate
```

---

How to Write Custom AI Tools
----------------------------

[](#how-to-write-custom-ai-tools)

The package discovers all classes implementing `Tobiebenezer\Ai\Contracts\Tool` inside the configured path (default: `app/Ai/Tools/`).

### Extending `AnalyticalTool`

[](#extending-analyticaltool)

For database-backed, analytical querying tools, you should extend the abstract `Tobiebenezer\Ai\Tools\AnalyticalTool` class. This provides built-in query building, grouping, formatting, filter validation, and aggregation.

Here is an example tool that allows the AI to query a `Sales` table:

```
