Skip to content

Commit

Permalink
Community: Fix with_structured_output for ChatSambaNovaCloud (#28796
Browse files Browse the repository at this point in the history
)

- **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
  • Loading branch information
keenborder786 authored Dec 18, 2024
1 parent 684b146 commit 7c8f977
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libs/community/langchain_community/chat_models/sambanova.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class AnswerWithJustification(BaseModel):
# '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":
Expand All @@ -629,8 +629,8 @@ class AnswerWithJustification(BaseModel):
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(
Expand All @@ -642,7 +642,7 @@ class AnswerWithJustification(BaseModel):
# 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()

Expand All @@ -660,7 +660,7 @@ class AnswerWithJustification(BaseModel):
# )
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:
Expand Down

0 comments on commit 7c8f977

Please sign in to comment.