feat: 好像不能将额外的信息放在ToolMessage中
This commit is contained in:
@@ -22,7 +22,13 @@ from app.utils.postgres_checkpointer import PostgresCheckpointerManager, AsyncPo
|
|||||||
description="一个用于获取当前时间的工具,没有参数"
|
description="一个用于获取当前时间的工具,没有参数"
|
||||||
)
|
)
|
||||||
def tool_get_datetime():
|
def tool_get_datetime():
|
||||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
return {
|
||||||
|
"result": f"当前时间为:{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}",
|
||||||
|
"render": {
|
||||||
|
"type": "DataTable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@tool(
|
@tool(
|
||||||
@@ -88,7 +94,7 @@ def tool_book_hotel() -> str:
|
|||||||
if resume_data == "N":
|
if resume_data == "N":
|
||||||
return f"用户选择取消预定酒店"
|
return f"用户选择取消预定酒店"
|
||||||
|
|
||||||
return "预定成功"
|
return ToolMessage(content="预定成功", additional_kwargs={"render": {"type": "DataTable"}})
|
||||||
|
|
||||||
|
|
||||||
class ChatMessage(BaseModel):
|
class ChatMessage(BaseModel):
|
||||||
@@ -200,6 +206,7 @@ def add_langgraph_chat_route(app: FastAPI):
|
|||||||
emit_chunk["tool_calls"] = chunk_message.tool_calls
|
emit_chunk["tool_calls"] = chunk_message.tool_calls
|
||||||
elif isinstance(chunk_message, ToolMessage):
|
elif isinstance(chunk_message, ToolMessage):
|
||||||
emit_chunk["tool_name"] = chunk_message.name
|
emit_chunk["tool_name"] = chunk_message.name
|
||||||
|
emit_chunk["additional_kwargs"] = chunk_message.additional_kwargs
|
||||||
|
|
||||||
result_template["choices"][0]["delta"]['content'] = emit_chunk
|
result_template["choices"][0]["delta"]['content'] = emit_chunk
|
||||||
result_template["choices"][0]["delta"]['role'] = 'assistant'
|
result_template["choices"][0]["delta"]['role'] = 'assistant'
|
||||||
|
|||||||
Reference in New Issue
Block a user