mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-04 10:42:55 +00:00
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
This commit is contained in:
parent
684b146b18
commit
7c8f977695
@ -616,7 +616,7 @@ class ChatSambaNovaCloud(BaseChatModel):
|
|||||||
# 'parsing_error': None
|
# 'parsing_error': None
|
||||||
# }
|
# }
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
if kwargs is not None:
|
if kwargs:
|
||||||
raise ValueError(f"Received unsupported arguments {kwargs}")
|
raise ValueError(f"Received unsupported arguments {kwargs}")
|
||||||
is_pydantic_schema = _is_pydantic_class(schema)
|
is_pydantic_schema = _is_pydantic_class(schema)
|
||||||
if method == "function_calling":
|
if method == "function_calling":
|
||||||
@ -629,8 +629,8 @@ class ChatSambaNovaCloud(BaseChatModel):
|
|||||||
llm = self.bind_tools([schema], tool_choice=tool_name)
|
llm = self.bind_tools([schema], tool_choice=tool_name)
|
||||||
if is_pydantic_schema:
|
if is_pydantic_schema:
|
||||||
output_parser: OutputParserLike[Any] = PydanticToolsParser(
|
output_parser: OutputParserLike[Any] = PydanticToolsParser(
|
||||||
tools=[schema],
|
tools=[schema], # type: ignore[list-item]
|
||||||
first_tool_only=True,
|
first_tool_only=True, # type: ignore[list-item]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
output_parser = JsonOutputKeyToolsParser(
|
output_parser = JsonOutputKeyToolsParser(
|
||||||
@ -642,7 +642,7 @@ class ChatSambaNovaCloud(BaseChatModel):
|
|||||||
# llm = self.bind(response_format={"type": "json_object"})
|
# llm = self.bind(response_format={"type": "json_object"})
|
||||||
if is_pydantic_schema:
|
if is_pydantic_schema:
|
||||||
schema = cast(Type[BaseModel], 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:
|
else:
|
||||||
output_parser = JsonOutputParser()
|
output_parser = JsonOutputParser()
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ class ChatSambaNovaCloud(BaseChatModel):
|
|||||||
# )
|
# )
|
||||||
if is_pydantic_schema:
|
if is_pydantic_schema:
|
||||||
schema = cast(Type[BaseModel], 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:
|
else:
|
||||||
output_parser = JsonOutputParser()
|
output_parser = JsonOutputParser()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user