From 8f238a2abc592762fe21e94341099d1648d27225 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Sun, 15 Dec 2024 20:41:13 +0530 Subject: [PATCH] fix o1 with system messages --- daras_ai_v2/language_model.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/daras_ai_v2/language_model.py b/daras_ai_v2/language_model.py index 4f081daa7..af058646d 100644 --- a/daras_ai_v2/language_model.py +++ b/daras_ai_v2/language_model.py @@ -1042,6 +1042,14 @@ def _run_openai_chat( ) -> list[ConversationEntry] | typing.Generator[list[ConversationEntry], None, None]: from openai._types import NOT_GIVEN + if model in ( + LargeLanguageModels.o1_mini.model_id, + LargeLanguageModels.o1_preview.model_id, + ): + for entry in messages: + if entry["role"] == CHATML_ROLE_SYSTEM: + entry["role"] = CHATML_ROLE_USER + if avoid_repetition: frequency_penalty = 0.1 presence_penalty = 0.25