Files
php-ai-sdk/docs/examples.md
T
2026-11-13 15:03:53 +03:00

2.7 KiB

Примеры

Каждый пример начинается с заголовка «Инструменты / Флаги» — по нему видно, что именно зарегистрировано и какие настройки включены.

Файл Что показывает Инструменты Флаги
01-chat.php простой ответ — —
02-tools.php цикл вызова инструментов get_time, calculator, get_weather значения по умолчанию
03-custom-tool.php свой инструмент с нуля server_info —
04-cli.php диалог в терминале get_time, calculator, get_weather —
05-settings.php настройки агента get_time, calculator toolChoice, toolApproval, historyLimit
06-finish.php явное завершение finish, calculator toolChoice=required, finishTool
07-tools.php прикладные утилиты convert_units, date_calc, uuid, hash_text —
08-shell.php команды оболочки run_command workdir, shell, timeout, maxOutput, allow, tmpDir
09-files.php файлы и поиск read_file, list_dir, write_file, replace_in_file, search_files, find_files песочница, create_dirs, all
10-http.php HTTP без сети http_request allowPrivate, auth, методы
11-json.php инструменты без модели json_query, convert_units, date_calc, uuid, hash_text —
12-logging.php логи запросов get_time, calculator verbose, sink
13-code-task.php агент пишет код и проверяет тестом read_file, write_file, replace_in_file, list_dir, run_command workdir, allow, maxRounds
14-hooks.php прогресс и остановка get_time, calculator hooks: onStep, onToolStart, onToolEnd, shouldStop
15-csv.php вопросы к таблице csv_query, calculator песочница
16-dialog.php многоходовый диалог — setSystemPrompt, messages, usage, reset, Cost
17-approval.php запрет опасного действия list_dir, read_file, write_file toolApproval
18-errors.php ошибки и повторы — Retry, Retry::none(), AiException

10-http.php, 11-json.php и 18-errors.php работают без модели — их можно запускать где угодно. Остальные обращаются к модели из .env.