mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-02 01:23:07 +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
|
||||
# }
|
||||
""" # 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:
|
||||
|
Loading…
Reference in New Issue
Block a user