v2.1.1: fix developer role mapping for DeepSeek and other providers
This commit is contained in:
@@ -151,6 +151,8 @@ def oa_input_to_messages(input_data):
|
||||
t = item.get("type")
|
||||
if t == "message":
|
||||
role = item.get("role", "user")
|
||||
if role == "developer":
|
||||
role = "system"
|
||||
text = ""
|
||||
for part in item.get("content", []):
|
||||
pt = part.get("type", "")
|
||||
@@ -323,6 +325,8 @@ def an_input_to_messages(input_data):
|
||||
t = item.get("type")
|
||||
if t == "message":
|
||||
role = item.get("role", "user")
|
||||
if role == "developer":
|
||||
role = "user"
|
||||
text = ""
|
||||
for part in item.get("content", []):
|
||||
pt = part.get("type", "")
|
||||
@@ -532,7 +536,11 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
def _handle_openai_compat(self, body, model, stream):
|
||||
input_data = body.get("input", "")
|
||||
chat_body = {"model": model, "messages": oa_input_to_messages(input_data)}
|
||||
messages = oa_input_to_messages(input_data)
|
||||
instructions = body.get("instructions", "").strip()
|
||||
if instructions:
|
||||
messages.insert(0, {"role": "system", "content": instructions})
|
||||
chat_body = {"model": model, "messages": messages}
|
||||
for k in ("temperature", "top_p", "max_output_tokens"):
|
||||
if k in body:
|
||||
chat_body["max_tokens" if k == "max_output_tokens" else k] = body[k]
|
||||
@@ -562,6 +570,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
input_data = body.get("input", "")
|
||||
an_body = {"model": model, "messages": an_input_to_messages(input_data),
|
||||
"max_tokens": body.get("max_output_tokens", 8192)}
|
||||
instructions = body.get("instructions", "").strip()
|
||||
if instructions:
|
||||
an_body["system"] = instructions
|
||||
for k in ("temperature", "top_p"):
|
||||
if k in body:
|
||||
an_body[k] = body[k]
|
||||
|
||||
Reference in New Issue
Block a user