Upgrade
Polyglot 2.0 is centered around explicit request fields.
The main migration points are:
- remove old output mode usage
- set
responseFormatfor native JSON or JSON schema - set
toolsandtoolChoicefor tool calling - use
stream()->deltas()for streaming
Response Model¶
Polyglot is now explicitly the raw inference layer.
InferenceResponseis the final raw provider response- streaming yields
PartialInferenceDelta - structured value ownership belongs to higher-level packages such as Instructor
If older code assumed that Polyglot streaming yielded accumulated partial response snapshots, update that code to work from deltas instead.
Before¶
After¶
<?php
use Cognesy\Messages\Messages;
use Cognesy\Polyglot\Inference\Data\ResponseFormat;
use Cognesy\Polyglot\Inference\Inference;
$data = Inference::using('openai')
->withMessages(Messages::fromString('Return JSON.'))
->withResponseFormat(new ResponseFormat(type: 'json_object'))
->asJsonData();
Markdown-JSON fallback is no longer a Polyglot concern. Use Instructor when you need higher-level structured output strategies.
Streaming Migration¶
Update old streaming code like this:
- replace partial-response iteration with
stream()->deltas() - assemble final raw output with
final() - move partial structured parsing to Instructor or your own delta accumulator