diff --git a/vocode/streaming/agent/token_utils.py b/vocode/streaming/agent/token_utils.py index bf014b2b7..80b130c24 100644 --- a/vocode/streaming/agent/token_utils.py +++ b/vocode/streaming/agent/token_utils.py @@ -57,6 +57,7 @@ "gpt-4-turbo": 127940, "gpt-4o": 127940, "gpt-4o-2024-05-13": 127940, + "gpt-4o-mini":127940, } @@ -83,6 +84,8 @@ def get_chat_gpt_max_tokens(model_name: str): def get_tokenizer_info(model: str) -> Optional[TokenizerInfo]: if "gpt-35-turbo" in model: model = "gpt-3.5-turbo" + elif "gpt-4o-mini" in model: + model = "gpt-4o-mini" elif "gpt-4o" == model: model = "gpt-4o" elif "gpt4" in model or "gpt-4" in model: @@ -111,6 +114,18 @@ def get_tokenizer_info(model: str) -> Optional[TokenizerInfo]: ) tokens_per_message = 3 tokens_per_name = 1 + elif "gpt-4o-mini" in model: + logger.debug( + "Warning: gpt-4o-mini may update over time. Returning num tokens assuming gpt-4o-mini-2024-07-18." + ) + tokens_per_message = 3 + tokens_per_name = 1 + elif "gpt-4o" in model: + logger.debug( + "Warning: gpt-4o may update over time. Returning num tokens assuming gpt-4o-2024-05-13" + ) + tokens_per_message = 3 + tokens_per_name = 1 elif "gpt-4" in model: logger.debug( "Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613." diff --git a/vocode/streaming/models/agent.py b/vocode/streaming/models/agent.py index aa9b63c8f..3aaeefd9b 100644 --- a/vocode/streaming/models/agent.py +++ b/vocode/streaming/models/agent.py @@ -26,6 +26,7 @@ OPENAI_GPT_4_MODEL_NAME = "gpt-4" OPENAI_GPT_4_32K_MODEL_NAME = "gpt-4-32k" OPENAI_GPT_4_O_MODEL_NAME = "gpt-4o" +OPENAI_GPT_4_O_MINI_MODEL_NAME = "gpt-4o-mini" OPENAI_GPT_35_TURBO_1106_MODEL_NAME = "gpt-3.5-turbo-1106" OPENAI_GPT_4_1106_PREVIEW_MODEL_NAME = "gpt-4-1106-preview" ANTHROPIC_CLAUDE_3_HAIKU_MODEL_NAME = "claude-3-haiku-20240307"