feat: таймаут от модели и оценка стоимости запроса
- Tools\\Support\\Timeout: значение timeout из аргументов модели, но не выше максимума инструмента; параметр описан в схемах - run_command и http_request принимают timeout (по умолчанию / maxTimeout) - Cost: тарифы по модели задаются явно, estimate() и format(); неизвестная модель даёт null, а не выдуманное число - Agent копит usage по всем раундам: usage() и сброс в reset() - пример 12 показывает расход и стоимость - 112 тестов
This commit is contained in:
1 parent
78aca90074
commit
ab081a4dcd
10 files changed
+304
-12
No files matched your search
@@ -56,6 +56,11 @@ $result = $client->chat($messages, $tools = [], $options = []);
|
||||
// options: tool_choice, parallel_tool_calls, temperature, max_tokens
|
||||
$result->text; $result->toolCalls; $result->usage;
|
||||
|
||||
// Расход и стоимость
|
||||
$agent->usage(); // [prompt_tokens, completion_tokens] за диалог
|
||||
$cost = (new Cost())->withRate('model', input: 0.07, output: 0.28);
|
||||
echo $cost->format($cost->estimate('model', $agent->usage()));
|
||||
|
||||
// Логирование поверх любого клиента
|
||||
$client = new LoggingClient($client, sink: fn (string $l) => error_log($l), verbose: true);
|
||||
|
||||
@@ -98,3 +103,4 @@ $tools->add(new FinishTool());
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user