From 0bfa7c1c458625b3d503a94a2ac09fa645491a03 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sat, 1 Feb 2025 02:29:44 +0530 Subject: [PATCH] Add support for o3 mini model by openai --- src/khoj/processor/conversation/openai/utils.py | 4 ++++ src/khoj/processor/conversation/utils.py | 1 + src/khoj/utils/constants.py | 1 + 3 files changed, 6 insertions(+) diff --git a/src/khoj/processor/conversation/openai/utils.py b/src/khoj/processor/conversation/openai/utils.py index 76b175b5..7d21662f 100644 --- a/src/khoj/processor/conversation/openai/utils.py +++ b/src/khoj/processor/conversation/openai/utils.py @@ -71,6 +71,8 @@ def completion_with_backoff( elif model_name.startswith("o1"): temperature = 1 model_kwargs.pop("response_format", None) + elif model_name.startswith("o3-"): + temperature = 1 if os.getenv("KHOJ_LLM_SEED"): model_kwargs["seed"] = int(os.getenv("KHOJ_LLM_SEED")) @@ -181,6 +183,8 @@ def llm_thread( elif model_name.startswith("o1-"): temperature = 1 model_kwargs.pop("response_format", None) + elif model_name.startswith("o3-"): + temperature = 1 elif model_name.startswith("deepseek-reasoner"): # Two successive messages cannot be from the same role. Should merge any back-to-back messages from the same role. # The first message should always be a user message (except system message). diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index 1ab06fae..695ad5e4 100644 --- a/src/khoj/processor/conversation/utils.py +++ b/src/khoj/processor/conversation/utils.py @@ -55,6 +55,7 @@ model_to_prompt_size = { "gpt-4o-mini": 60000, "o1": 20000, "o1-mini": 60000, + "o3-mini": 60000, # Google Models "gemini-1.5-flash": 60000, "gemini-1.5-pro": 60000, diff --git a/src/khoj/utils/constants.py b/src/khoj/utils/constants.py index 6e89594d..b3ff1f97 100644 --- a/src/khoj/utils/constants.py +++ b/src/khoj/utils/constants.py @@ -40,6 +40,7 @@ model_to_cost: Dict[str, Dict[str, float]] = { "gpt-4o-mini": {"input": 0.15, "output": 0.60}, "o1": {"input": 15.0, "output": 60.00}, "o1-mini": {"input": 3.0, "output": 12.0}, + "o3-mini": {"input": 1.10, "output": 4.40}, # Gemini Pricing: https://ai.google.dev/pricing "gemini-1.5-flash": {"input": 0.075, "output": 0.30}, "gemini-1.5-flash-002": {"input": 0.075, "output": 0.30},