mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 06:39:52 +00:00
[rfc] core: make tool_call_id optional
This commit is contained in:
parent
2898b95ca7
commit
161f6af9ce
@ -50,7 +50,7 @@ class ToolMessage(BaseMessage):
|
|||||||
to request multiple tool calls in parallel.
|
to request multiple tool calls in parallel.
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
|
|
||||||
tool_call_id: str
|
tool_call_id: Optional[str] = None
|
||||||
"""Tool call that this message is responding to."""
|
"""Tool call that this message is responding to."""
|
||||||
|
|
||||||
type: Literal["tool"] = "tool"
|
type: Literal["tool"] = "tool"
|
||||||
@ -119,7 +119,7 @@ class ToolMessage(BaseMessage):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
tool_call_id = values["tool_call_id"]
|
tool_call_id = values.get("tool_call_id")
|
||||||
if isinstance(tool_call_id, (UUID, int, float)):
|
if isinstance(tool_call_id, (UUID, int, float)):
|
||||||
values["tool_call_id"] = str(tool_call_id)
|
values["tool_call_id"] = str(tool_call_id)
|
||||||
return values
|
return values
|
||||||
|
@ -892,6 +892,9 @@ def _format_output(
|
|||||||
content: Any, artifact: Any, tool_call_id: Optional[str], name: str, status: str
|
content: Any, artifact: Any, tool_call_id: Optional[str], name: str, status: str
|
||||||
) -> Union[ToolMessage, Any]:
|
) -> Union[ToolMessage, Any]:
|
||||||
if tool_call_id:
|
if tool_call_id:
|
||||||
|
if isinstance(content, ToolMessage):
|
||||||
|
content.tool_call_id = tool_call_id
|
||||||
|
return content
|
||||||
if not _is_message_content_type(content):
|
if not _is_message_content_type(content):
|
||||||
content = _stringify(content)
|
content = _stringify(content)
|
||||||
return ToolMessage(
|
return ToolMessage(
|
||||||
|
Loading…
Reference in New Issue
Block a user