Skip to content

Commit a4346a4

Browse files
committed
Release version 0.12.11
1 parent 7f6f37f commit a4346a4

File tree

19 files changed

+65
-84
lines changed

19 files changed

+65
-84
lines changed

docs-build/cookbook/instructor/api_support/minimaxi.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class User {
4141
// Get Instructor with specified LLM client connection
4242
// See: /config/llm.php to check or change LLM client connection configuration details
4343
$instructor = (new Instructor)->withConnection('minimaxi');
44-
Debug::enable();
44+
Debug::setEnabled();
4545
$user = $instructor->respond(
4646
messages: "Jason (@jxnlco) is 25 years old and is the admin of this project. He likes playing football and reading books.",
4747
responseModel: User::class,

docs-build/cookbook/instructor/api_support/moonshotai.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class User {
4141
// Get Instructor with specified LLM client connection
4242
// See: /config/llm.php to check or change LLM client connection configuration details
4343
$instructor = (new Instructor)->withConnection('moonshot-kimi');
44-
Debug::enable();
44+
Debug::setEnabled();
4545
$user = $instructor->respond(
4646
messages: "Jason (@jxnlco) is 25 years old and is the admin of this project. He likes playing football and reading books.",
4747
responseModel: User::class,

docs-build/cookbook/instructor/api_support/sambanova.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class User {
4141
// Get Instructor with specified LLM client connection
4242
// See: /config/llm.php to check or change LLM client connection configuration details
4343
$instructor = (new Instructor)->withConnection('sambanova');
44-
Debug::enable();
44+
Debug::setEnabled();
4545
$user = $instructor->respond(
4646
messages: "Jason (@jxnlco) is 25 years old and is the admin of this project. He likes playing football and reading books.",
4747
responseModel: User::class,

docs-build/cookbook/instructor/extras/complex_extraction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ enum StakeholderRole: string {
9696
case Other = 'other';
9797
}
9898

99-
Debug::enable();
99+
Debug::setEnabled();
100100

101101
$instructor = new Instructor;
102102

docs-build/cookbook/instructor/extras/complex_extraction_gemini.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ enum StakeholderRole: string {
9595
case Other = 'other';
9696
}
9797

98-
//Debug::enable();
98+
//Debug::setEnabled();
9999
$instructor = (new Instructor)->withConnection('gemini');
100100

101101
echo "PROJECT EVENTS:\n\n";

docs-build/cookbook/instructor/troubleshooting/debugging.mdx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ require 'examples/boot.php';
2222

2323
use Cognesy\Instructor\Instructor;
2424
use Cognesy\Polyglot\LLM\Data\LLMConfig;
25+
use Cognesy\Utils\Str;
2526

2627
class User {
2728
public int $age;
2829
public string $name;
2930
}
3031

31-
// CASE 1 - normal flow
32+
// CASE 1.1 - normal flow, sync request
3233

3334
$instructor = (new Instructor)->withConnection('openai');
3435

@@ -42,8 +43,15 @@ $user = $instructor->withDebug()->respond(
4243
echo "\nResult:\n";
4344
dump($user);
4445

46+
assert(isset($user->name));
47+
assert(isset($user->age));
48+
assert($user->name === 'Jason');
49+
assert($user->age === 25);
50+
51+
// CASE 1.2 - normal flow, streaming request
52+
4553
echo "\n### CASE 1.2 - Debugging streaming request\n\n";
46-
$user2 = $instructor->withDebug()->respond(
54+
$user2 = $instructor->withDebug(true)->respond(
4755
messages: "Anna is 21 years old.",
4856
responseModel: User::class,
4957
options: [ 'stream' => true ]
@@ -52,11 +60,6 @@ $user2 = $instructor->withDebug()->respond(
5260
echo "\nResult:\n";
5361
dump($user2);
5462

55-
assert(isset($user->name));
56-
assert(isset($user->age));
57-
assert($user->name === 'Jason');
58-
assert($user->age === 25);
59-
6063
assert(isset($user2->name));
6164
assert(isset($user2->age));
6265
assert($user2->name === 'Anna');
@@ -65,18 +68,20 @@ assert($user2->age === 21);
6568

6669
// CASE 2 - forcing API error via empty LLM config
6770

68-
$instructor = (new Instructor)->withLLMConfig(new LLMConfig());
71+
// let's initialize the instructor with an incorrect LLM config
72+
$instructor = (new Instructor)
73+
->withLLMConfig(new LLMConfig(apiUrl: 'https://example.com'));
6974

70-
echo "\n### CASE 2 - Debugging exception\n\n";
75+
echo "\n### CASE 2 - Debugging with HTTP exception\n\n";
7176
try {
72-
$user = $instructor->withDebug()->respond(
77+
$user = $instructor->withDebug(true)->respond(
7378
messages: "Jason is 25 years old.",
7479
responseModel: User::class,
7580
options: [ 'stream' => true ]
7681
);
7782
} catch (Exception $e) {
78-
echo "\nCaught it:\n";
79-
dump($e);
83+
$msg = Str::limit($e->getMessage(), 250);
84+
echo "\nCaught exception: " . $msg . "\n";
8085
}
8186
?>
8287
```

docs-build/cookbook/polyglot/llm_advanced/reasoning_content.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use Cognesy\Polyglot\LLM\Inference;
1919
use Cognesy\Utils\Debug\Debug;
2020
use Cognesy\Utils\Str;
2121

22-
//Debug::enable();
22+
//Debug::setEnabled();
2323

2424
// EXAMPLE 1: regular API, allows to customize inference options
2525
$response = (new Inference)

docs-build/cookbook/polyglot/llm_extras/chat_with_summary.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $chat = ChatWithSummary::create(
5656
);
5757
$chat->script()->section('main')->appendMessage($startMessage);
5858

59-
//Debug::enable();
59+
//Debug::setEnabled();
6060

6161
for($i = 0; $i < $maxSteps; $i++) {
6262
$chat->script()

docs-build/cookbook/polyglot/llm_extras/tool_use.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ require 'examples/boot.php';
3838
use Cognesy\Addons\ToolUse\Tools\FunctionTool;
3939
use Cognesy\Addons\ToolUse\ToolUse;
4040

41-
//Debug::enable();
41+
//Debug::setEnabled();
4242

4343
function add_numbers(int $a, int $b) : int {
4444
return $a + $b;

docs-build/cookbook/polyglot/llm_troubleshooting/http_debug.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ docname: 'http_debug'
55

66
## Overview
77

8-
Instructor PHP provides a way to debug HTTP calls made to LLM APIs via `Debug::enable()` method.
9-
`Debug::enable()` works globally, it turns on dumping all HTTP requests and responses to the console.
10-
11-
> NOTE: Currently `Debug::enable()` is only supported by Guzzle HTTP client.
8+
Instructor PHP provides a way to debug HTTP calls made to LLM APIs via `Debug::setEnabled()` method.
9+
`Debug::setEnabled()` works globally, it turns on dumping all HTTP requests and responses to the console.
1210

1311
## Example
1412

@@ -19,7 +17,7 @@ require 'examples/boot.php';
1917
use Cognesy\Polyglot\LLM\Inference;
2018
use Cognesy\Utils\Debug\Debug;
2119

22-
Debug::enable();
20+
Debug::setEnabled();
2321

2422
$response = (new Inference)
2523
->create(

0 commit comments

Comments
 (0)