fix: migrate structured-output.test.ts to v6
This commit is contained in:
@@ -363,20 +363,25 @@ describe("structured-output.createStructuredOutputTool", () => {
|
||||
expect(inputSchema.jsonSchema?.properties?.tags?.items?.type).toBe("string")
|
||||
})
|
||||
|
||||
test("toModelOutput returns text value", () => {
|
||||
test("toModelOutput returns text value", async () => {
|
||||
const tool = SessionPrompt.createStructuredOutputTool({
|
||||
schema: { type: "object" },
|
||||
onSuccess: () => {},
|
||||
})
|
||||
|
||||
expect(tool.toModelOutput).toBeDefined()
|
||||
const modelOutput = tool.toModelOutput!({
|
||||
output: "Test output",
|
||||
title: "Test",
|
||||
metadata: { valid: true },
|
||||
})
|
||||
const modelOutput = await Promise.resolve(
|
||||
tool.toModelOutput!({
|
||||
toolCallId: "test-call-id",
|
||||
input: {},
|
||||
output: {
|
||||
output: "Test output",
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
expect(modelOutput.type).toBe("text")
|
||||
if (modelOutput.type !== "text") throw new Error("expected text model output")
|
||||
expect(modelOutput.value).toBe("Test output")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user