Remove duplicated system prompts

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
This commit is contained in:
Víctor Mayoral Vilches 2025-05-23 14:37:23 +00:00
parent 8de5d7922b
commit ceafdcb350
1 changed files with 17 additions and 15 deletions

View File

@ -407,14 +407,15 @@ class OpenAIChatCompletionsModel(Model):
msg_copy = converted_messages[idx].copy() msg_copy = converted_messages[idx].copy()
msg_copy["cache_control"] = {"type": "ephemeral"} msg_copy["cache_control"] = {"type": "ephemeral"}
converted_messages[idx] = msg_copy converted_messages[idx] = msg_copy
# --- Add to message_history: user, system, and assistant tool call messages ---
# Add system prompt to message_history # # --- Add to message_history: user, system, and assistant tool call messages ---
if system_instructions: # # Add system prompt to message_history
sys_msg = { # if system_instructions:
"role": "system", # sys_msg = {
"content": system_instructions # "role": "system",
} # "content": system_instructions
add_to_message_history(sys_msg) # }
# add_to_message_history(sys_msg)
# Add user prompt(s) to message_history # Add user prompt(s) to message_history
if isinstance(input, str): if isinstance(input, str):
@ -845,13 +846,14 @@ class OpenAIChatCompletionsModel(Model):
msg_copy = converted_messages[idx].copy() msg_copy = converted_messages[idx].copy()
msg_copy["cache_control"] = {"type": "ephemeral"} msg_copy["cache_control"] = {"type": "ephemeral"}
converted_messages[idx] = msg_copy converted_messages[idx] = msg_copy
# --- Add to message_history: user, system prompts ---
if system_instructions: # # --- Add to message_history: user, system prompts ---
sys_msg = { # if system_instructions:
"role": "system", # sys_msg = {
"content": system_instructions # "role": "system",
} # "content": system_instructions
add_to_message_history(sys_msg) # }
# add_to_message_history(sys_msg)
if isinstance(input, str): if isinstance(input, str):
user_msg = { user_msg = {