Skip to content

Commit f84d985

Browse files
committed
fix: remove unused tempfile import and simplify input content handling in generate_tool_message_complete
1 parent 8c9a3b8 commit f84d985

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

apps/application/flow/tools.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import queue
1414
import re
1515
import shutil
16-
import tempfile
1716
import threading
1817
import zipfile
1918
from functools import reduce
@@ -236,21 +235,14 @@ def to_stream_response_simple(stream_event):
236235
return r
237236

238237

239-
tool_message_json_template = """
240-
%s
241-
"""
242-
243238
def generate_tool_message_complete(icon, name, input_content, output_content):
244239
"""生成包含输入和输出的工具消息模版"""
245240
# 确保输入内容是字符串,如果不是则尝试转换为 JSON 字符串
246241
if not isinstance(input_content, str):
247-
try:
248-
input_content = json.dumps(input_content, ensure_ascii=False)
249-
except Exception:
250-
input_content = str(input_content)
242+
input_content = json.dumps(input_content, ensure_ascii=False)
251243
# 格式化输出
252244
if not isinstance(output_content, str):
253-
output_content = json.dumps(output_content, ensure_ascii=False)
245+
output_content = json.dumps(output_content, ensure_ascii=False)
254246
content = {
255247
"icon": icon,
256248
"title": name,

0 commit comments

Comments
 (0)