From 23fcc14650aeb60ba4f918b809000f028ceff4c9 Mon Sep 17 00:00:00 2001 From: harry-cohere <127103098+harry-cohere@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:30:14 +0000 Subject: [PATCH] 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. --- libs/partners/cohere/langchain_cohere/chat_models.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/partners/cohere/langchain_cohere/chat_models.py b/libs/partners/cohere/langchain_cohere/chat_models.py index ce2ce6a568..51a66cfcdf 100644 --- a/libs/partners/cohere/langchain_cohere/chat_models.py +++ b/libs/partners/cohere/langchain_cohere/chat_models.py @@ -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