diff --git a/Dockerfile.modelscope b/Dockerfile.modelscope index a67ee0c..7202faa 100644 --- a/Dockerfile.modelscope +++ b/Dockerfile.modelscope @@ -54,4 +54,4 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8001/api/health || exit 1 # 启动命令 - 使用优化的统一启动脚本 -CMD ["python3", "start_unified.py", "--profile", "balanced"] +CMD ["sh", "-c", "python3 start_unified.py --profile ${PROFILE:-balanced}"] diff --git a/routes/chat.py b/routes/chat.py index c41b378..dd0e9bf 100644 --- a/routes/chat.py +++ b/routes/chat.py @@ -83,14 +83,14 @@ async def enhanced_generate_stream_response( if isinstance(msg, AIMessageChunk): # 处理工具调用 - if msg.tool_call_chunks and config.tool_response: + if msg.tool_call_chunks: message_tag = "TOOL_CALL" - for tool_call_chunk in msg.tool_call_chunks: - if tool_call_chunk["name"]: - new_content = f"[{message_tag}] {tool_call_chunk['name']}\n" - if tool_call_chunk['args']: - new_content += tool_call_chunk['args'] - + if config.tool_response: + for tool_call_chunk in msg.tool_call_chunks: + if tool_call_chunk["name"]: + new_content = f"[{message_tag}] {tool_call_chunk['name']}\n" + if tool_call_chunk['args']: + new_content += tool_call_chunk['args'] # 处理文本内容 elif msg.content: preamble_completed.set() @@ -101,11 +101,11 @@ async def enhanced_generate_stream_response( new_content = f"[{meta_message_tag}]\n" if msg.text: new_content += msg.text - # 处理工具响应 - elif isinstance(msg, ToolMessage) and config.tool_response and msg.content: + elif isinstance(msg, ToolMessage) and msg.content: message_tag = "TOOL_RESPONSE" - new_content = f"[{message_tag}] {msg.name}\n{msg.text}\n" + if config.tool_response: + new_content = f"[{message_tag}] {msg.name}\n{msg.text}\n" # 收集完整内容 if new_content: