Skip to content

The agent engineering platform.

feat(groq): Allow kwargs in with_structured_output to override tool_choice (#34053)

dumko2001fb892ee50ac8
diff --git a/libs/partners/groq/langchain_groq/chat_models.py b/libs/partners/groq/langchain_groq/chat_models.py
index e5a36ce868..454cd74744 100644
--- a/libs/partners/groq/langchain_groq/chat_models.py
+++ b/libs/partners/groq/langchain_groq/chat_models.py
@@ -1141,9 +1141,6 @@ class ChatGroq(BaseChatModel):
""" # noqa: E501
_ = kwargs.pop("strict", None)
- if kwargs:
- msg = f"Received unsupported arguments {kwargs}"
- raise ValueError(msg)
is_pydantic_schema = _is_pydantic_class(schema)
if method == "function_calling":
if schema is None:
@@ -1161,6 +1158,7 @@ class ChatGroq(BaseChatModel):
"kwargs": {"method": "function_calling"},
"schema": formatted_tool,
},
+ **kwargs,
)
if is_pydantic_schema:
output_parser: OutputParserLike = PydanticToolsParser(
@@ -1193,6 +1191,7 @@ class ChatGroq(BaseChatModel):
llm = self.bind(
response_format=response_format,
ls_structured_output_format=ls_format_info,
+ **kwargs,
)
output_parser = (
PydanticOutputParser(pydantic_object=schema) # type: ignore[type-var, arg-type]
@@ -1207,6 +1206,7 @@ class ChatGroq(BaseChatModel):
"kwargs": {"method": "json_mode"},
"schema": schema,
},
+ **kwargs,
)
output_parser = (
PydanticOutputParser(pydantic_object=schema) # type: ignore[type-var, arg-type]