mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-17 16:39:52 +00:00
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.
This commit is contained in:
parent
ce0a588ae6
commit
23fcc14650
@ -191,10 +191,8 @@ class ChatCohere(BaseChatModel, BaseCohere):
|
|||||||
A Runnable that takes any ChatModel input and returns either a dict or
|
A Runnable that takes any ChatModel input and returns either a dict or
|
||||||
Pydantic class as output.
|
Pydantic class as output.
|
||||||
"""
|
"""
|
||||||
if kwargs:
|
|
||||||
raise ValueError(f"Received unsupported arguments {kwargs}")
|
|
||||||
is_pydantic_schema = isinstance(schema, type) and issubclass(schema, BaseModel)
|
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:
|
if is_pydantic_schema:
|
||||||
output_parser: OutputParserLike = PydanticToolsParser(
|
output_parser: OutputParserLike = PydanticToolsParser(
|
||||||
tools=[schema], first_tool_only=True
|
tools=[schema], first_tool_only=True
|
||||||
|
Loading…
Reference in New Issue
Block a user