Skip to content

Commit 7f6f37f

Browse files
committed
Fixes in HTTP middleware
1 parent be73f3f commit 7f6f37f

File tree

111 files changed

+5162
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+5162
-525
lines changed

.gitattributes

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Exclude unnecessary files from Composer and Git exports
22
/.cursorignore export-ignore
3+
/.cursorprompt export-ignore
34
/.github/ export-ignore
45
/.gitignore export-ignore
56
/.gitattributes export-ignore
@@ -9,21 +10,25 @@
910
/mkdocs.yml export-ignore
1011
/mkdocs.yml.bak export-ignore
1112
/phpunit.xml export-ignore
13+
/phpstan.neon export-ignore
1214
/phpstan.neon.dist export-ignore
1315
/phpunit.xml.dist export-ignore
1416
/psalm.xml export-ignore
15-
/phpstan.neon export-ignore
17+
/pyrightconfig.json export-ignore
18+
/requirements-doc.txt export-ignore
1619
*.md export-ignore
1720
*.mdx export-ignore
1821

1922
# Project specific ignores
2023
/archived/ export-ignore
2124
/docs/ export-ignore
2225
/docs-build/ export-ignore
23-
#/evals/ export-ignore # include this one with distribution
24-
#/examples/ export-ignore # include this one with distribution
25-
/src-auxiliary/ export-ignore
26+
/evals/ export-ignore
27+
/examples/ export-ignore
28+
/src-auxiliary/ export-ignore
2629
/src-experimental/ export-ignore
30+
/src-hub/ export-ignore
31+
/src-tell/ export-ignore
2732
/notes/ export-ignore
2833
/scratchpad/ export-ignore
2934
/tests/ export-ignore

config/debug.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
<?php
2-
return [
3-
'http' => [
4-
'enabled' => false,
5-
'trace' => false,
6-
'requestUrl' => true,
7-
'requestHeaders' => true,
8-
'requestBody' => true,
9-
'responseHeaders' => true,
10-
'responseBody' => true,
11-
'responseStream' => true,
12-
],
13-
];
1+
<?php
2+
return [
3+
'http' => [
4+
'enabled' => false, // enable/disable debug
5+
'trace' => false, // dump HTTP trace information (available for some clients - e.g. Guzzle)
6+
'requestUrl' => true, // dump request URL to console
7+
'requestHeaders' => true, // dump request headers to console
8+
'requestBody' => true, // dump request body to console
9+
'responseHeaders' => true, // dump response headers to console
10+
'responseBody' => true, // dump response body to console
11+
'responseStream' => true, // dump stream data to console
12+
'responseStreamByLine' => true, // dump stream data as full lines (true) or as raw received chunks (false)
13+
],
14+
];

config/http.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
return [
66
'defaultClient' => 'guzzle',
77

8-
'cache' => [
9-
'enabled' => false,
10-
'expiryInSeconds' => 3600,
11-
'path' => '/tmp/instructor/cache',
12-
],
13-
148
'clients' => [
159
'guzzle' => [
1610
'httpClientType' => HttpClientType::Guzzle->value,
@@ -48,5 +42,5 @@
4842
'poolTimeout' => 60,
4943
'failOnError' => true,
5044
],
51-
]
45+
],
5246
];

docs/release-notes/v0.12.10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Excluded examples, evals and some CLI tools (hub and tell) to minimize distribution size (they are still available in the source code repository)

docs/release-notes/v0.12.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed composer.json

evals/LLMModes/run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
),
4343
);
4444

45-
//Debug::enable();
45+
//Debug::setEnabled();
4646
$connections = array_keys(Settings::get('llm', 'connections'));
4747
$modes = [Mode::Tools, Mode::JsonSchema, Mode::Json, Mode::MdJson, Mode::Text];
4848
$stream = [true, false];

evals/SimpleExtraction/run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
responseModel: Company::class,
2222
);
2323

24-
//Debug::enable();
24+
//Debug::setEnabled();
2525

2626
$experiment = new Experiment(
2727
cases: InferenceCases::except(

evals/UseExamples/run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
responseModel: Company::class,
2222
);
2323

24-
//Debug::enable();
24+
//Debug::setEnabled();
2525

2626
$experiment = new Experiment(
2727
cases: InferenceCases::except(

examples/A03_Troubleshooting/Debugging/run.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class User {
2828
public string $name;
2929
}
3030

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

3333
$instructor = (new Instructor)->withConnection('openai');
3434

@@ -42,6 +42,13 @@ class User {
4242
echo "\nResult:\n";
4343
dump($user);
4444

45+
assert(isset($user->name));
46+
assert(isset($user->age));
47+
assert($user->name === 'Jason');
48+
assert($user->age === 25);
49+
50+
// CASE 1.2 - normal flow, streaming request
51+
4552
echo "\n### CASE 1.2 - Debugging streaming request\n\n";
4653
$user2 = $instructor->withDebug()->respond(
4754
messages: "Anna is 21 years old.",
@@ -52,11 +59,6 @@ class User {
5259
echo "\nResult:\n";
5360
dump($user2);
5461

55-
assert(isset($user->name));
56-
assert(isset($user->age));
57-
assert($user->name === 'Jason');
58-
assert($user->age === 25);
59-
6062
assert(isset($user2->name));
6163
assert(isset($user2->age));
6264
assert($user2->name === 'Anna');
@@ -65,9 +67,9 @@ class User {
6567

6668
// CASE 2 - forcing API error via empty LLM config
6769

68-
$instructor = (new Instructor)->withLLMConfig(new LLMConfig());
70+
$instructor = (new Instructor)->withLLMConfig(new LLMConfig(apiUrl: 'https://wrong.com'));
6971

70-
echo "\n### CASE 2 - Debugging exception\n\n";
72+
echo "\n### CASE 2 - Debugging with HTTP exception\n\n";
7173
try {
7274
$user = $instructor->withDebug()->respond(
7375
messages: "Jason is 25 years old.",

examples/A04_APISupport/Minimaxi/run.php

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,

0 commit comments

Comments
 (0)