PHP code example of jansuchanek / nchat

1. Go to this page and download the library: Download jansuchanek/nchat 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/ */

    

jansuchanek / nchat example snippets


final class AdminPresenter extends BasePresenter
{
    use NChat\Presenter\ChatPresenterTrait;
}

$openActions = array_merge(['dashboard'], self::getChatActionNames());

class SqliteChatStorage implements ChatStorageInterface
{
    public function saveMessage(array $data): int { /* ... */ }
    public function fetchMessages(int $userId, array $criteria = []): array { /* ... */ }
    // ...8 methods total
}

class MyAiResponder implements AiResponderInterface
{
    public function respond(string $context): string { /* call OpenAI/Claude/Gemini */ }
    public function getSystemPrompt(): string { return 'You are...'; }
    public function getBotName(): string { return '🤖 Bot'; }
}