Spelling variant issue with with_structured_output()
and Cohere
#26864
Replies: 1 comment 3 replies
-
Hey @jackpeplinski! 👋 I'm here to help you with bugs, answer questions, and even guide you on becoming a contributor. While you're waiting for a human maintainer, I'm at your service! The issue you're encountering with the The To address this issue, you can implement a custom post-processing step to normalize the field names before validation. Here's an example of how you can achieve this:
By normalizing the field names before passing the data to the Pydantic model for validation, you can ensure that the schema validation succeeds regardless of regional spelling variations. This approach should help you handle the spelling variant issue with the |
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.
-
Checked other resources
Commit to Help
Example Code
Using code from Langchain doc's How to use reference examples when doing extraction.
Description
Using MistralAI, the code returns:
Using Cohere, the code throws an error (note the
u
incolour
):Why is Cohere adding a
u
tocolor
whenData
is a list of persons andPerson
has the attributehair_color
nothair_colour
? Cohere was founded in Canada where color is spelled with au
, but shouldn't their API return the response in the structure I specify?System Info
langchain==0.3.0
langchain-anthropic==0.2.1
langchain-cohere==0.3.0
langchain-community==0.3.0
langchain-core==0.3.5
langchain-experimental==0.3.1
langchain-mistralai==0.2.0
langchain-text-splitters==0.3.0
Linux-6.1.85+-x86_64-with-glibc2.35
3.10.12
Beta Was this translation helpful? Give feedback.
All reactions