Skip to content

Commit 85757d5

Browse files
joonlimjoonlim
authored andcommitted
fix: normalize conditionagent response content before parsing
1 parent 06dc0e1 commit 85757d5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/components/nodes/agentflow/ConditionAgent/ConditionAgent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,18 +408,18 @@ class ConditionAgent_Agentflow implements INode {
408408
await analyticHandlers.onLLMEnd(llmIds, analyticsOutput, { model: modelName, provider: model })
409409
}
410410

411+
const responseContent = extractResponseContent(response)
412+
411413
let calledOutputName: string
412414
try {
413-
const parsedResponse = this.parseJsonMarkdown(response.content as string)
415+
const parsedResponse = this.parseJsonMarkdown(responseContent)
414416
if (!parsedResponse.output || typeof parsedResponse.output !== 'string') {
415417
throw new Error('LLM response is missing the "output" key or it is not a string.')
416418
}
417419
calledOutputName = parsedResponse.output
418420
} catch (error) {
419421
throw new Error(
420-
`Failed to parse a valid scenario from the LLM's response. Please check if the model is capable of following JSON output instructions. Raw LLM Response: "${
421-
response.content as string
422-
}"`
422+
`Failed to parse a valid scenario from the LLM's response. Please check if the model is capable of following JSON output instructions. Raw LLM Response: "${responseContent}"`
423423
)
424424
}
425425

0 commit comments

Comments
 (0)