Skip to content

Commit

Permalink
cohere[patch]: support kwargs in with_structured_output (#19736)
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
harry-cohere authored Mar 29, 2024
1 parent ce0a588 commit 23fcc14
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions libs/partners/cohere/langchain_cohere/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ def with_structured_output(
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
Expand Down

0 comments on commit 23fcc14

Please sign in to comment.