Update openai_ondemand_adapter.py
Browse files
openai_ondemand_adapter.py
CHANGED
|
@@ -201,17 +201,17 @@ def chat_completions():
|
|
| 201 |
# 您可能需要根据 OnDemand API 的具体要求调整此格式
|
| 202 |
formatted_query_parts = []
|
| 203 |
for msg in messages:
|
| 204 |
-
role = msg.get("role", "user").strip()
|
| 205 |
content = msg.get("content", "").strip()
|
| 206 |
if not content: # 跳过空内容的消息
|
| 207 |
continue
|
| 208 |
-
formatted_query_parts.append(f"
|
| 209 |
|
| 210 |
if not formatted_query_parts:
|
| 211 |
return jsonify({"error": "No valid content found in 'messages'."}), 400
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
final_query_to_ondemand = start_prompt + "\n".join(formatted_query_parts)
|
| 215 |
|
| 216 |
# --- 结束构造 query ---
|
| 217 |
|
|
|
|
| 201 |
# 您可能需要根据 OnDemand API 的具体要求调整此格式
|
| 202 |
formatted_query_parts = []
|
| 203 |
for msg in messages:
|
| 204 |
+
role = msg.get("role", "user").strip().capitalize()
|
| 205 |
content = msg.get("content", "").strip()
|
| 206 |
if not content: # 跳过空内容的消息
|
| 207 |
continue
|
| 208 |
+
formatted_query_parts.append(f"<|{role}|>: {content}")
|
| 209 |
|
| 210 |
if not formatted_query_parts:
|
| 211 |
return jsonify({"error": "No valid content found in 'messages'."}), 400
|
| 212 |
+
|
| 213 |
+
start_prompt = "下面是对话的历史记录. 你应当遵从指令并用中文回复.\n"
|
| 214 |
+
final_query_to_ondemand = start_prompt + "\n".join(formatted_query_parts)
|
| 215 |
|
| 216 |
# --- 结束构造 query ---
|
| 217 |
|