PHP code example of filaforge / filament-huggingface-chat

1. Go to this page and download the library: Download filaforge/filament-huggingface-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-huggingface-chat example snippets


use Filament\Panel;

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

// config/hf-chat.php
return [
    'api_token' => env('HF_API_TOKEN'),
    'base_url' => env('HF_BASE_URL', 'https://api-inference.huggingface.co'),
    'default_model' => env('HF_MODEL_ID', 'meta-llama/Meta-Llama-3-8B-Instruct'),
    'max_length' => env('HF_MAX_LENGTH', 512),
    'temperature' => env('HF_TEMPERATURE', 0.7),
    'stream' => env('HF_STREAM', false),
    'timeout' => env('HF_TIMEOUT', 60),
    'use_openai_format' => env('HF_USE_OPENAI', true),
];

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

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