Skip to content

Commit f989669

Browse files
committed
fix: fix llm structured output
1 parent a101e24 commit f989669

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/lib/ai/workflow/pulse-workflow.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,21 @@ export async function createPulseWorkflow(
138138
position: { x: 560, y: 0 },
139139
}) as UINode<NodeKind.LLM>;
140140
llmNode.data.model = model ?? DEFAULT_MODEL;
141-
llmNode.data.outputSchema = {
141+
llmNode.data.outputSchema.properties.answer = {
142142
type: "object",
143143
properties: {
144-
answer: { type: "string" },
145-
hasNewInfo: { type: "boolean" },
144+
hasNewInfo: {
145+
type: "boolean",
146+
description:
147+
"Indicates whether there is meaningful new information to report.",
148+
},
149+
answer: {
150+
type: "string",
151+
description: "The summary text of the latest findings.",
152+
},
146153
},
147-
required: ["answer", "hasNewInfo"],
148-
} as ObjectJsonSchema7;
154+
required: ["answer"],
155+
};
149156
llmNode.data.messages = [
150157
{
151158
role: "system",
@@ -198,7 +205,7 @@ export async function createPulseWorkflow(
198205
{
199206
source: {
200207
nodeId: llmNode.id,
201-
path: ["hasNewInfo"],
208+
path: ["answer", "hasNewInfo"],
202209
},
203210
operator: BooleanConditionOperator.IsTrue,
204211
},
@@ -229,7 +236,7 @@ export async function createPulseWorkflow(
229236
mention(inputNode.id, ["query"]),
230237
text(":"),
231238
]),
232-
paragraph([mention(llmNode.id, ["answer"])]),
239+
paragraph([mention(llmNode.id, ["answer", "answer"])]),
233240
]),
234241
},
235242
];
@@ -245,7 +252,7 @@ export async function createPulseWorkflow(
245252
key: "text",
246253
source: {
247254
nodeId: llmNode.id,
248-
path: ["answer"],
255+
path: ["answer", "answer"],
249256
},
250257
},
251258
];

0 commit comments

Comments
 (0)