with_structured_output
not working with models on retrieval chains. Its only working on a raw chain I create myself
#18258
Replies: 3 comments 3 replies
-
🤖 Based on the error message you provided, it seems like the output from the retrieval model is not matching the expected schema defined by In the LangChain framework, the However, when using models on retrieval chains, the output from the retrieval model may not directly match the expected schema, leading to validation errors. This is because the retrieval model's output is expected to be a string (the retrieved text), but the structured output mechanism expects the output to match the defined schema (e.g., a pydantic model or a dictionary defining a JSON schema). When the output does not match the expected schema, a validation error occurs, indicating that a string was expected but a different type was received. To resolve this issue, you need to ensure that the output from the retrieval model is appropriately formatted or transformed to match the expected schema before it is passed to the structured output validation mechanism. This may involve additional processing steps to convert the retrieval model's output into a format that conforms to the expected structured output schema. For more details on how the I hope this helps! If you have any more questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
This sounds good. Thanks! |
Beta Was this translation helpful? Give feedback.
-
How can I retry with error message? |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
with_structured_output()
is not working when I use it in a model which I pipe with a combination ofcreate_stuff_documents_chain
andcreate_retrieval_chain
It doesn't respond with the Pydantic I've specified and gives error :-
{"detail": "Error invoking retriever chain: 1 validation error for Generation\ntext\n str type expected (type=type_error.str)"}
The method
with_structured_output()
is working well with my other chain but is creating an issue in my retrieval chain.Any help would be appreciated!
System Info
langchain==0.1.9
langchain-community==0.0.24
langchain-core==0.1.26
langchain-openai==0.0.7
Beta Was this translation helpful? Give feedback.
All reactions