jack 3 days ago
parent
commit
5c7d93b6a5
2 changed files with 15 additions and 1 deletions
  1. 14 0
      app/core/runner/thread_runner.py
  2. 1 1
      app/services/run/run.py

+ 14 - 0
app/core/runner/thread_runner.py

@@ -149,6 +149,13 @@ class ThreadRunner:
         执行 run step
         """
         logging.info("step %d is running", len(run_steps) + 1)
+        if instruction == "":
+            instruction = "You are a multilingual AI assistant.\n"
+                    "- Detect user language; reply in same language unless told "
+                    "otherwise.\n"
+                    "- Default to English if detection is unclear.\n"
+                    "- Give concise, accurate, and safe answers; admit when "
+                    "unsure.\n"
 
         assistant_system_message = [msg_util.system_message(instruction)]
 
@@ -426,6 +433,13 @@ class ThreadRunner:
                 for content in message.content:
                     if content["type"] == "text":
                         message_content += content["text"]["value"]
+                if message_content == "":
+                    message_content = "You are a multilingual AI assistant.\n"
+                    "- Detect user language; reply in same language unless told "
+                    "otherwise.\n"
+                    "- Default to English if detection is unclear.\n"
+                    "- Give concise, accurate, and safe answers; admit when "
+                
                 chat_messages.append(msg_util.new_message(role, message_content))
 
         chat_messages.reverse()  # 倒序排列,最新的消息在前面

+ 1 - 1
app/services/run/run.py

@@ -47,7 +47,7 @@ class RunService:
         if not body.top_p and db_asst.top_p:
             body.top_p = db_asst.top_p
         if body.additional_instructions:
-            body.instructions = body.additional_instructions
+            body.instructions += "\n" + body.additional_instructions
 
         file_ids = []
         """