mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-25 07:09:11 +00:00
Merge branch 'docs/ai-structured-data' into docs/ai-stream-stop
This commit is contained in:
commit
84add33654
2 files changed
+14
-13
No files matched your search
@@ -65,15 +65,16 @@ feedback go after the fixed prompt, so repeated calls can reuse a cached prefix.
|
||||
|
||||
## Use a Prompt With Another Model
|
||||
|
||||
The selected OpenAI model supports structured output. OpenAI's
|
||||
The example model, `gpt-5.4-nano`, accepts `outputFormat`. OpenAI's
|
||||
[structured-output guide](https://developers.openai.com/api/docs/guides/structured-outputs)
|
||||
covers model support. The catalog has no documented universal support flag.
|
||||
For a model without `outputFormat`, put the same schema in the system prompt,
|
||||
omit that option, and run exactly the same parser and validator.
|
||||
lists the OpenAI models that do. The model catalog doesn't say which models
|
||||
accept it. For a model without `outputFormat`, put the same schema in the system
|
||||
prompt, omit that option, and run exactly the same parser and validator.
|
||||
|
||||
The full code includes the schema in the prompt in both modes. After selecting
|
||||
your replacement model, call `extract(requests, false)` for prompt-only output.
|
||||
A model that returns invalid JSON gets the same bounded correction loop.
|
||||
The full code already puts the schema in the system prompt. To use a model
|
||||
without `outputFormat`, change the model ID at the top and call
|
||||
`extract(requests, false)`. A model that returns invalid JSON gets the same
|
||||
bounded correction loop.
|
||||
|
||||
## Reuse a Validated Result
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ const result = await puter.ai.chat(context, { model, normalize: true, compaction
|
||||
context.push(result.message);
|
||||
```
|
||||
|
||||
This example selects a model with native compaction. The [Anthropic availability
|
||||
list](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#availability)
|
||||
covers its supported models. Puter also implements native compaction for OpenAI
|
||||
Responses models. A catalog entry alone establishes availability, not compaction
|
||||
support. Choose the manual summary below when your model lacks native compaction.
|
||||
This example selects a model with native compaction. Claude models on the
|
||||
[Anthropic availability list](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#availability)
|
||||
and OpenAI Responses models support it. The model catalog doesn't say which
|
||||
models support compaction. For other models, such as Gemini, use the manual
|
||||
summary below.
|
||||
|
||||
## Carry the Artifact Forward
|
||||
|
||||
@@ -116,7 +116,7 @@ subscription actions, or another failure with its code and message:
|
||||
```js
|
||||
const models = await puter.ai.listModels();
|
||||
const nativeCompaction = true;
|
||||
const modelId = nativeCompaction ? 'claude-sonnet-4-6' : 'gpt-5.4-nano';
|
||||
const modelId = nativeCompaction ? 'claude-sonnet-4-6' : 'gemini-3.5-flash-lite';
|
||||
const model = models.find(item => item.id === modelId)?.puterId;
|
||||
if (!model) throw new Error('The conversation model is unavailable.');
|
||||
const chatId = crypto.randomUUID();
|
||||
|
||||
Reference in new issue
Block a user