cohere[patch]: support kwargs in with_structured_output (#19736)

**Description:** We'd like to support passing additional kwargs in
`with_structured_output`. I believe this is the accepted approach to
enable additional arguments on API calls.
pull/18603/head^2
harry-cohere 5 months ago committed by GitHub
parent ce0a588ae6
commit 23fcc14650
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -191,10 +191,8 @@ class ChatCohere(BaseChatModel, BaseCohere):
A Runnable that takes any ChatModel input and returns either a dict or
Pydantic class as output.
"""
if kwargs:
raise ValueError(f"Received unsupported arguments {kwargs}")
is_pydantic_schema = isinstance(schema, type) and issubclass(schema, BaseModel)
llm = self.bind_tools([schema])
llm = self.bind_tools([schema], **kwargs)
if is_pydantic_schema:
output_parser: OutputParserLike = PydanticToolsParser(
tools=[schema], first_tool_only=True

Loading…
Cancel
Save