From 7c8f9776959e0243706e529ca08535d017b1dbc8 Mon Sep 17 00:00:00 2001 From: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:35:06 +0500 Subject: [PATCH] Community: Fix `with_structured_output` for `ChatSambaNovaCloud` (#28796) - **Description:** The `kwargs` was being checked as None object which was causing the rest of code in `with_structured_output` not getting executed. The checking part has been fixed in this PR. - **Issue:** #28776 --- .../langchain_community/chat_models/sambanova.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/community/langchain_community/chat_models/sambanova.py b/libs/community/langchain_community/chat_models/sambanova.py index a2ddf24d8c8..e345c0f6920 100644 --- a/libs/community/langchain_community/chat_models/sambanova.py +++ b/libs/community/langchain_community/chat_models/sambanova.py @@ -616,7 +616,7 @@ class ChatSambaNovaCloud(BaseChatModel): # 'parsing_error': None # } """ # noqa: E501 - if kwargs is not None: + if kwargs: raise ValueError(f"Received unsupported arguments {kwargs}") is_pydantic_schema = _is_pydantic_class(schema) if method == "function_calling": @@ -629,8 +629,8 @@ class ChatSambaNovaCloud(BaseChatModel): llm = self.bind_tools([schema], tool_choice=tool_name) if is_pydantic_schema: output_parser: OutputParserLike[Any] = PydanticToolsParser( - tools=[schema], - first_tool_only=True, + tools=[schema], # type: ignore[list-item] + first_tool_only=True, # type: ignore[list-item] ) else: output_parser = JsonOutputKeyToolsParser( @@ -642,7 +642,7 @@ class ChatSambaNovaCloud(BaseChatModel): # llm = self.bind(response_format={"type": "json_object"}) if is_pydantic_schema: schema = cast(Type[BaseModel], schema) - output_parser = PydanticOutputParser(pydantic_object=schema) + output_parser = PydanticOutputParser(pydantic_object=schema) # type: ignore[type-var, arg-type] else: output_parser = JsonOutputParser() @@ -660,7 +660,7 @@ class ChatSambaNovaCloud(BaseChatModel): # ) if is_pydantic_schema: schema = cast(Type[BaseModel], schema) - output_parser = PydanticOutputParser(pydantic_object=schema) + output_parser = PydanticOutputParser(pydantic_object=schema) # type: ignore[type-var, arg-type] else: output_parser = JsonOutputParser() else: