feat(langchain,openai): add strict flag to ProviderStrategy structured output (#34149)

This commit is contained in:
Towseef Altaf
2025-12-11 02:05:23 +05:30
committed by GitHub
parent 69dd39c461
commit d27fb0c432
3 changed files with 32 additions and 8 deletions

View File

@@ -1886,9 +1886,10 @@ class BaseChatOpenAI(BaseChatModel):
):
# compat with langchain.agents.create_agent response_format, which is
# an approximation of OpenAI format
strict = response_format["json_schema"].get("strict", None)
response_format = cast(dict, response_format["json_schema"]["schema"])
kwargs["response_format"] = _convert_to_openai_response_format(
response_format
response_format, strict=strict
)
return super().bind(tools=formatted_tools, **kwargs)