jack 2 months ago
parent
commit
f86f3b1d6b
2 changed files with 6 additions and 4 deletions
  1. 1 1
      app/core/runner/thread_runner.py
  2. 5 3
      app/core/runner/utils/message_util.py

+ 1 - 1
app/core/runner/thread_runner.py

@@ -452,7 +452,7 @@ class ThreadRunner:
                 for content in message.content:
                     if content["type"] == "text":
                         assistant_content += content["text"]["value"]
-                if assistant_content is not None and assistant_content != "":
+                if assistant_content is not None:
                     chat_messages.append(msg_util.new_message(role, assistant_content, message.reasoning_content))
                 #chat_messages.append(msg_util.new_message(role, assistant_content, message.reasoning_content))
 

+ 5 - 3
app/core/runner/utils/message_util.py

@@ -18,8 +18,10 @@ from openai.types.chat.chat_completion_message_tool_call import Function
 def new_message(role: str, content: str, reasoning_content=None):
     if role != "user" and role != "system" and role != "assistant":
         raise ValueError(f"Invalid role {role}")
-
-    return {"role": role, "content": content}
+    if reasoning_content is None:
+        return {"role": role, "content": content}
+    else:
+        return {"role": role, "content": content, "reasoning_content": reasoning_content}
 
 
 def system_message(content: str):
@@ -35,7 +37,7 @@ def assistant_message(content: str):
 
 
 def tool_calls(tool_calls, reasoning_content=None):
-    if reasoning_content is None or reasoning_content == "":
+    if reasoning_content is None:
         return {"role": "assistant", "tool_calls": tool_calls}
     else:
         return {"role": "assistant", "tool_calls": tool_calls, "reasoning_content": reasoning_content}