Replies: 2 comments 3 replies
-
🤖 Hey @zirkelc, great to see you back here! Hope you're doing well. Based on the information you've provided and the context from the langchainjs repository, it seems like the issue you're experiencing might be due to the fact that the output parser for the StructuredChatAgent is not always guaranteed to return a structured response. The output parser used in the StructuredChatAgent is the static getDefaultOutputParser(
fields?: OutputParserArgs & {
toolNames: string[];
}
) {
if (fields?.llm) {
return StructuredChatOutputParserWithRetries.fromLLM(fields.llm, {
toolNames: fields.toolNames,
});
}
return new StructuredChatOutputParserWithRetries({
toolNames: fields?.toolNames,
});
} In this method, if an LLM (Language Learning Model) is provided, it creates an output parser with retry logic from the LLM. If the LLM is not provided, it creates a new instance of If you want to ensure a structured response, you might need to implement additional error handling or fallback logic in your application. You can find more details about this in the langchain/src/agents/structured_chat/index.ts file. Regarding the I hope this helps! If you have any other questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
@dosu-bot I'm using OpenAI Tools Agent and not the StructuredChatAgent |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an Agent with one dynamic structured tool and I want the agent to return a structured response. I followed the example on the documentation to implement the agent. However, the agent doesn't always return a structured response.
Here is my code example from the documentation. I extended the response schema with `answer`, `classification` and `sentiment`. The websearch tool also requires structured input.
I get the following results.
First response to
what is the current weather in honolulu?
Second response to
and in miami?
Third response to
great, what about in new york?
As you can see, the first and third responses are structured with
answer
,classification
andsentiment
, while the second response only contains the default response keyoutput
.Is there a way to consistently get a structured response?
Beta Was this translation helpful? Give feedback.
All reactions