Files
php-ai-sdk/bootstrap.php
T
rsgrinko 14fe8d8a5e feat: минимальная PHP-библиотека для чата с вызовом инструментов
- AiClient: любой OpenAI-совместимый /chat/completions (DeepSeek, OpenAI, Ollama, llama.cpp)
- Agent: цикл function calling, история диалога, трассировка вызовов
- Tool + ToolRegistry: инструмент = 4 метода, ошибки уходят модели текстом
- ChatClient: интерфейс, чтобы подменять модель в тестах
- инструменты: get_time, calculator (без eval), get_weather (open-meteo)
- 4 примера и 18 тестов без сети
- настройки в .env: AI_BASE_URL/AI_MODEL/AI_API_KEY/AI_VERIFY_SSL/AI_CAINFO
2026-11-12 18:06:01 +03:00

36 lines
1017 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
/**
* Точка входа SDK: автозагрузка классов + чтение .env.
*
* Во всех примерах и тестах достаточно одной строки:
* require __DIR__ . '/bootstrap.php';
*/
// Автозагрузка: AiSdk\Tools\* -> tools/, остальное AiSdk\* -> src/.
spl_autoload_register(static function (string $class): void {
$map = [
'AiSdk\\Tools\\' => __DIR__ . '/tools/',
'AiSdk\\' => __DIR__ . '/src/',
];
foreach ($map as $prefix => $dir) {
if (!str_starts_with($class, $prefix)) {
continue;
}
$file = $dir . str_replace('\\', '/', substr($class, strlen($prefix))) . '.php';
if (is_file($file)) {
require $file;
return;
}
}
});
// .env рядом с bootstrap.php; если файла нет — работаем на значениях по умолчанию.
\AiSdk\Env::load(__DIR__ . '/.env');