-
|
Hello team. I have the following question. This is my agent: // Agent Output
export interface ClassificationOutput {
prompt: Prompt; // <- type Prompt from "ai"
context: Context; // <- type Context from local
}
// Agent Settings
export type ClassifierSettings = AgentSettings<
ToolSet,
ClassificationOutput,
Partial<ClassificationOutput>
>;
// Agent
export interface Classifier extends Agent<
ToolSet,
ClassificationOutput,
Partial<ClassificationOutput>
>
// BasicAgent
class DefaultClassifier
extends Agent<ToolSet, ClassificationOutput, Partial<ClassificationOutput>>
implements ClassifierHow can I use // option #1
experimental_output: Output.object<ClassificationOutput, PartialObject<ClassificationOutput>>({
schema: jsonSchema<ClassificationOutput>({ ... })
// ... Module '"ai"' declares 'PartialObject' locally, but it is not exported.ts(2459)
// option #2
experimental_output: Output.object<ClassificationOutput>({ ... })
// ... Type 'Output<ClassificationOutput, PartialObject<ClassificationOutput>>' is not assignable to type 'Output<ClassificationOutput, Partial<ClassificationOutput>>'.I understand that // This works!
export interface ClassificationOutput {
prompt: string;
context: string;
}My questions are:
Thank you, just looking for clarification, I'm enjoying this Agent flexibility you guys are introducing here :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @rbadillap 👋 Core idea: experimental_output only guarantees JSON-serializable shapes at runtime. Types like Prompt (from ai) or your own classes aren’t serializable, so you should expose a DTO (plain JSON) for the model, then map ↔︎ your richer types in your app. **What to do
2) Use that schema with experimental_output
3) Map DTO ⟷ domain types in your agent Answers to your questions 1. Am I over-engineering with these types? 2. Should I change the output interface to primitives? 3. Is PartialObject the real issue? |
Beta Was this translation helpful? Give feedback.
Hi @rbadillap 👋
Core idea: experimental_output only guarantees JSON-serializable shapes at runtime. Types like Prompt (from ai) or your own classes aren’t serializable, so you should expose a DTO (plain JSON) for the model, then map ↔︎ your richer types in your app.
**What to do