mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
fix(fireworks): bind_tools(strict: bool) and reasoning_content (#34343)
Extract strict from kwargs and pass it to convert_to_openai_tool when converting tools. This ensures that when strict is provided, it's properly used during tool conversion and removed from kwargs before calling the parent bind method. Also extract reasoning_content from API responses and store it in additional_kwargs for AIMessage objects. Fixes https://github.com/langchain-ai/langchain/issues/34341 and https://github.com/langchain-ai/langchain/issues/34342 --------- Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
@@ -114,8 +114,12 @@ def _convert_dict_to_message(_dict: Mapping[str, Any]) -> BaseMessage:
|
||||
# Also Fireworks returns None for tool invocations
|
||||
content = _dict.get("content", "") or ""
|
||||
additional_kwargs: dict = {}
|
||||
if reasoning_content := _dict.get("reasoning_content"):
|
||||
additional_kwargs["reasoning_content"] = reasoning_content
|
||||
|
||||
if function_call := _dict.get("function_call"):
|
||||
additional_kwargs["function_call"] = dict(function_call)
|
||||
|
||||
tool_calls = []
|
||||
invalid_tool_calls = []
|
||||
if raw_tool_calls := _dict.get("tool_calls"):
|
||||
@@ -678,7 +682,10 @@ class ChatFireworks(BaseChatModel):
|
||||
**kwargs: Any additional parameters to pass to
|
||||
`langchain_fireworks.chat_models.ChatFireworks.bind`
|
||||
""" # noqa: E501
|
||||
formatted_tools = [convert_to_openai_tool(tool) for tool in tools]
|
||||
strict = kwargs.pop("strict", None)
|
||||
formatted_tools = [
|
||||
convert_to_openai_tool(tool, strict=strict) for tool in tools
|
||||
]
|
||||
if tool_choice is not None and tool_choice:
|
||||
if isinstance(tool_choice, str) and (
|
||||
tool_choice not in ("auto", "any", "none")
|
||||
|
||||
Reference in New Issue
Block a user