PHP code example of filaforge / filament-opensource-chat

1. Go to this page and download the library: Download filaforge/filament-opensource-chat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

filaforge / filament-opensource-chat example snippets


use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other configuration
        ->plugin(\Filaforge\OpensourceChat\OpensourceChatPlugin::make());
}

// config/opensource-chat.php
return [
    'default_provider' => env('OS_CHAT_PROVIDER', 'local'),
    'providers' => [
        'local' => [
            'base_url' => env('OS_CHAT_LOCAL_URL', 'http://localhost:8000'),
            'api_key' => env('OS_CHAT_LOCAL_KEY', ''),
            'model' => env('OS_CHAT_LOCAL_MODEL', 'llama3'),
        ],
        'fireworks' => [
            'base_url' => env('OS_CHAT_FIREWORKS_URL', 'https://api.fireworks.ai'),
            'api_key' => env('OS_CHAT_FIREWORKS_KEY', ''),
            'model' => env('OS_CHAT_FIREWORKS_MODEL', 'llama-v2-7b-chat'),
        ],
        'together' => [
            'base_url' => env('OS_CHAT_TOGETHER_URL', 'https://api.together.xyz'),
            'api_key' => env('OS_CHAT_TOGETHER_KEY', ''),
            'model' => env('OS_CHAT_TOGETHER_MODEL', 'meta-llama/Llama-2-7b-chat-hf'),
        ],
    ],
    'max_tokens' => env('OS_CHAT_MAX_TOKENS', 4096),
    'temperature' => env('OS_CHAT_TEMPERATURE', 0.7),
    'stream' => env('OS_CHAT_STREAM', true),
    'timeout' => env('OS_CHAT_TIMEOUT', 60),
];

// remove ->plugin(\Filaforge\OpensourceChat\OpensourceChatPlugin::make())
bash
# Publish provider groups (config, views, migrations)
php artisan vendor:publish --provider="Filaforge\\OpensourceChat\\Providers\\OpensourceChatServiceProvider"

# Run migrations
php artisan migrate
bash
php artisan tinker
echo env('OS_CHAT_PROVIDER');
echo env('OS_CHAT_LOCAL_URL');
bash
php artisan optimize:clear
bash
composer remove filaforge/opensource-chat
php artisan optimize:clear