You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangChain rather than my code.
The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
The following code doesn't work:
classPerson(BaseModel):
first_name: strlast_name: strLLM=AzureChatOpenAI(
azure_deployment="gpt-4o-2024-08-06", api_version="2024-08-01-preview", temperature=0
).with_structured_output(schema=Person, method="json_schema", strict=True)
result=LLM.invoke(HumanMessage("Who was the first president of the United States?"))
Error Message and Stack Trace (if applicable)
The exception received was:
Received unsupported arguments {'strict': True}
File "/home/goldbermg3/GitProjects/remis-pdf-utils/structured_out_test.py", line 13, in <module>
).with_structured_output(schema=Person, method="json_schema", strict=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Received unsupported arguments {'strict': True}
Description
I expected the new Structured Output capability (which is available through Azure) which is implemented on BaseChatOpenAI to work using AzureChatOpenAI. However, after browsing the code, I saw that the support for mode="json_schema" and the strict argument is implemented only for BaseChatOpenAI; AzureChatOpenAI overrides BaseChatOpenAI.with_structured_outputs and does not include support for those arguments.
System Info
System Information
OS: Linux
OS Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
Python Version: 3.11.9 (main, Apr 6 2024, 17:59:24) [GCC 11.4.0]
How can we get this fixed? I would assume most businesses in Europe do not use the OpenAI API directly, but instead through Azure. Thus, this is a pretty bad limitation that it is not implemented for the Azure version of the API.
Hello, my group and I are from the University of Toronto, and we are going to take a look and work on this issue, hopefully to have a working PR soon.
Hi Emily, I really appreciate you volunteering to work on this. However, I believe the issue has been fixed already. I've seen no update about it, but I was checking the code and saw that it was updated. Tested it a couple of days ago and it appears to now be working. It only works for GPT-4o, not GPT-4o-mini, but that is an Azure issue, not a Langchain issue. Even though OpenAI released strict structured output for GPT-4o-mini two months ago, Azure is yet to do the same.
Checked other resources
Example Code
The following code doesn't work:
Error Message and Stack Trace (if applicable)
The exception received was:
Description
I expected the new Structured Output capability (which is available through Azure) which is implemented on
BaseChatOpenAI
to work usingAzureChatOpenAI
. However, after browsing the code, I saw that the support formode="json_schema"
and thestrict
argument is implemented only forBaseChatOpenAI
;AzureChatOpenAI
overridesBaseChatOpenAI.with_structured_outputs
and does not include support for those arguments.System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: