PHP code example of fendinger / kirby-visitor-ai-chat

1. Go to this page and download the library: Download fendinger/kirby-visitor-ai-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/ */

    

fendinger / kirby-visitor-ai-chat example snippets


return [
    'fendinger.visitor-ai-chat' => [
        'providers' => [
            'embedding' => 'openai',   // openai | mistral | gemini | ionos | mittwald
            'chat'      => 'openai',
        ],
        'openai'   => ['apiKey' => 'sk-...'],
        'mistral'  => ['apiKey' => '...'],
        'gemini'   => ['apiKey' => '...'],
        'ionos'    => ['apiKey' => '...'],
        'mittwald' => ['apiKey' => '...'],

        // Optional:
        'ui' => ['locale' => 'de'],    // null = auto
        'rateLimit' => ['perMinute' => 10, 'perHour' => 60],
        'chunk' => ['size' => 800, 'overlap' => 120],
        'topK' => 5,
        'maxQuery' => 500,
        '

 snippet('visitor-ai-chat-widget') 

'fendinger.visitor-ai-chat' => [
    'systemPrompt' => <<<PROMPT
    You are the assistant for example.com. Answer strictly from the CONTEXT below.
    Keep answers under 3 sentences. Respond in {locale}.

    CONTEXT:
    {context}
    PROMPT,
],

'translations' => [
    'visitor-ai-chat.title'    => 'Ask this site',
    'visitor-ai-chat.greeting' => 'Hi! How can I help?',
    // ...
],

'ui' => ['title' => 'Chat Bot'],

'ui' => ['theme' => 'dark'],   // 'light' (default) | 'dark'

'fendinger.visitor-ai-chat' => [
    'license' => ['key' => 'XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX'],
],

return [
    'panel' => [
        'viewButtons' => [
            'page' => ['page.preview', 'page.reindex', 'page.settings'],
        ],
    ],
];

'fendinger.visitor-ai-chat' => [
    'pricing' => [
        'openai' => [
            'gpt-4o-mini' => ['input' => 0.15, 'output' => 0.60],
            // ...
        ],
    ],
],

'fendinger.visitor-ai-chat' => [
    'logging' => [
        'enabled'       => false,  // default: true
        'retentionDays' => 90,     // 0 = unlimited
    ],
],
bash
php -r '