Filament OpenAI Assistant is a filament plugin that adds a chat page with an Open AI assistant
- Integrate with OpenAI Assistant
- Easy to Setup
- Multiple Assistants
- Multiple Threads
- Support for dark mode
First, you need install the package via composer:
composer require ercogx/filament-openai-assistant
Then need publish migration:
php artisan vendor:publish --tag="filament-openai-assistant-migrations"
Optional you can change foreign id for auth user if you use a different model instead of the \App\Models\User::class
Next, you can publish the config files with:
php artisan vendor:publish --tag="filament-openai-assistant-config"
This will create a config/filament-openai-assistant.php
configuration file in your project, which you can modify to your needs using environment variables:
OPENAI_API_KEY=sk-***
OPENAI_ASSISTANT_ID=asst_***
OPENAI_ASSISTANT_NAME=Assistant
You can also add more assistants to the assistants
array as needed
The last step add the Plugin to your Panel's configuration. This will register the plugin's page with the Panel.
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\Ercogx\FilamentOpenaiAssistant\OpenaiAssistantPlugin::make()
]);
}
You can also change the chat page to customize it
\Ercogx\FilamentOpenaiAssistant\OpenaiAssistantPlugin::make()
->setRegistrablePages([
\App\Filament\Pages\ChatPage::class
])
<?php
namespace App\Filament\Pages;
use Ercogx\FilamentOpenaiAssistant\Pages\OpenaiAssistantPage;
class ChatPage extends OpenaiAssistantPage
{
}
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-openai-assistant-views"
Optionally, you can publish the translations using
php artisan vendor:publish --tag="filament-openai-assistant-translations"
If you want to use your own model for chat thread you need call useChatThreadModel
in boot method of any service provider
public function boot(): void
{
\Ercogx\FilamentOpenaiAssistant\Services\ChatThreadModelServices::useChatThreadModel(\App\Models\MyChatThread::class);
}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.