Skip to content

Commit c5d3469

Browse files
committed
Fixes in example execution
1 parent b3456c9 commit c5d3469

File tree

18 files changed

+252
-61
lines changed

18 files changed

+252
-61
lines changed

examples/A04_APISupport/Meta/run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: 'Meta'
33
docname: 'meta'
44
id: 'c351'
5+
skip: true
56
---
67
## Overview
78

examples/A04_APISupport/Minimaxi/run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: 'Minimaxi'
33
docname: 'minimaxi'
44
id: '1d6f'
5+
skip: true
56
---
67
## Overview
78

examples/A04_APISupport/Perplexity/run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class User {
3737

3838
$structuredOutput = new StructuredOutput(
3939
StructuredOutputRuntime::fromProvider(LLMProvider::using('perplexity'))
40-
->withOutputMode(OutputMode::Json)
40+
->withOutputMode(OutputMode::MdJson)
4141
);
4242

4343
$user = $structuredOutput->with(

examples/A05_Extras/CustomExtractor/run.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Cognesy\Instructor\Extraction\Data\ExtractionInput;
3333
use Cognesy\Instructor\Extraction\Exceptions\ExtractionException;
3434
use Cognesy\Instructor\Extraction\Extractors\DirectJsonExtractor;
35+
use Cognesy\Instructor\Extraction\ResponseExtractor;
3536
use Cognesy\Instructor\StructuredOutput;
3637
use Cognesy\Instructor\StructuredOutputRuntime;
3738
use Cognesy\Polyglot\Inference\LLMProvider;
@@ -115,10 +116,10 @@ class Person {
115116
// DirectJson is tried first (will fail), then XmlJsonExtractor (will succeed)
116117
$person = new StructuredOutput(
117118
StructuredOutputRuntime::fromProvider(LLMProvider::using('openai'))
118-
->withExtractors([
119+
->withExtractor(ResponseExtractor::fromExtractors(
119120
new DirectJsonExtractor(),
120121
new XmlJsonExtractor('json'),
121-
])
122+
))
122123
)
123124
->withResponseClass(Person::class)
124125
->withMessages("Extract: Alice Johnson, 28 years old, lives in San Francisco")
@@ -180,10 +181,10 @@ class Person {
180181
// Custom extractors work for streaming too
181182
$stream = new StructuredOutput(
182183
StructuredOutputRuntime::fromProvider(LLMProvider::using('openai'))
183-
->withExtractors([
184+
->withExtractor(ResponseExtractor::fromExtractors(
184185
new DirectJsonExtractor(),
185186
new XmlJsonExtractor('json'),
186-
])
187+
))
187188
)
188189
->withResponseClass(Person::class)
189190
->withMessages("Extract person data...")

examples/A05_Extras/CustomExtractor/run_streaming.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Cognesy\Instructor\Extraction\Data\ExtractionInput;
66
use Cognesy\Instructor\Extraction\Exceptions\ExtractionException;
77
use Cognesy\Instructor\Extraction\Extractors\DirectJsonExtractor;
8+
use Cognesy\Instructor\Extraction\ResponseExtractor;
89
use Cognesy\Instructor\StructuredOutput;
910
use Cognesy\Instructor\StructuredOutputRuntime;
1011
use Cognesy\Polyglot\Inference\LLMProvider;
@@ -65,10 +66,10 @@ class Person {
6566

6667
$stream = new StructuredOutput(
6768
StructuredOutputRuntime::fromProvider(LLMProvider::using('openai'))
68-
->withExtractors([
69+
->withExtractor(ResponseExtractor::fromExtractors(
6970
new DirectJsonExtractor(),
7071
new XmlJsonExtractor('json'),
71-
])
72+
))
7273
)
7374
->withResponseClass(Person::class)
7475
->withMessages("Extract person data...")

examples/A05_Extras/TranslateUIFields/run.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
use Cognesy\Instructor\StructuredOutput;
2222
use Cognesy\Instructor\StructuredOutputRuntime;
23-
use Cognesy\Instructor\Validation\Validators\SymfonyValidator;
2423
use Cognesy\Polyglot\Inference\LLMProvider;
2524

2625
class TextElementModel
@@ -40,7 +39,7 @@ public function __construct(
4039
$transformedModel = new StructuredOutput(
4140
StructuredOutputRuntime::fromProvider(LLMProvider::using('openai'))
4241
->withMaxRetries(2)
43-
->withValidators([SymfonyValidator::class])
42+
->withValidator(new \Cognesy\Instructor\Validation\Validators\SymfonyValidator())
4443
)
4544
->withInput($sourceModel)
4645
->withResponseClass(get_class($sourceModel))

examples/B02_LLMAdvanced/ReasoningContent/run.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
// EXAMPLE 1: regular API, allows to customize inference options
2222
$response = Inference::using('deepseek-r')
23-
->withMessages(Messages::fromString('What is the capital of France. Answer with just a name.'))
24-
->withMaxTokens(256)
23+
->withMessages(Messages::fromString('What is the capital of France? Answer with just the city name, nothing else.'))
24+
->withMaxTokens(1024)
2525
->response();
2626

2727
echo "\nCASE #1: Sync response\n";
@@ -34,8 +34,8 @@
3434
// EXAMPLE 2: streaming response
3535
$stream = Inference::using('deepseek-r')
3636
->with(
37-
messages: Messages::fromString('What is capital of Brasil. Answer with just a name.'),
38-
options: ['max_tokens' => 256]
37+
messages: Messages::fromString('What is the capital of Brasil? Answer with just the city name, nothing else.'),
38+
options: ['max_tokens' => 1024]
3939
)
4040
->withStreaming()
4141
->stream();

examples/B04_LLMApiSupport/A21/run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: 'A21'
33
docname: 'llm_a21'
44
id: '1dd0'
5+
skip: true
56
---
67
## Overview
78

examples/B04_LLMApiSupport/Meta/run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: 'Meta'
33
docname: 'llm_meta'
44
id: '2dca'
5+
skip: true
56
---
67
## Overview
78

examples/B04_LLMApiSupport/Minimaxi/run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: 'Minimaxi'
33
docname: 'llm_minimaxi'
44
id: '89a2'
5+
skip: true
56
---
67
## Overview
78

0 commit comments

Comments
 (0)