Fix the impersonate response role

This commit is contained in:
Yiximail 2024-08-22 16:26:41 +08:00
parent 34b493b231
commit 38b3daad55

View File

@ -371,6 +371,7 @@ def chat_completions_common(body: dict, is_legacy: bool = False, stream=False, p
yield chunk yield chunk
else: else:
role = 'user' if impersonate else 'assistant'
resp = { resp = {
"id": cmpl_id, "id": cmpl_id,
"object": object_type, "object": object_type,
@ -379,7 +380,7 @@ def chat_completions_common(body: dict, is_legacy: bool = False, stream=False, p
resp_list: [{ resp_list: [{
"index": 0, "index": 0,
"finish_reason": stop_reason, "finish_reason": stop_reason,
"message": {"role": "assistant", "content": answer} "message": {"role": role, "content": answer}
}], }],
"usage": { "usage": {
"prompt_tokens": token_count, "prompt_tokens": token_count,