Overview

Instructor PHP provides a way to debug HTTP calls made to LLM APIs via Debug::enable() method. Debug::enable() works globally, it turns on dumping all HTTP requests and responses to the console.

NOTE: Currently Debug::enable() is only supported by Guzzle HTTP client.

Example

<?php
require 'examples/boot.php';

use Cognesy\Polyglot\LLM\Inference;
use Cognesy\Utils\Debug\Debug;

Debug::enable();

$response = (new Inference)
    ->create(
        messages: [['role' => 'user', 'content' => 'What is the capital of Brasil']],
        options: ['max_tokens' => 128]
    )
    ->toText();

echo "USER: What is capital of Brasil\n";
echo "ASSISTANT: $response\n";
?>