Skip to content

Commit

Permalink
fix: add missing hardcodings for popular OpenAI models (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacker authored Oct 10, 2024
1 parent dba25c3 commit 60b51b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions letta/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@
LLM_MAX_TOKENS = {
"DEFAULT": 8192,
## OpenAI models: https://platform.openai.com/docs/models/overview
# "o1-preview
"chatgpt-4o-latest": 128000,
# "o1-preview-2024-09-12
"gpt-4o-2024-08-06": 128000,
"gpt-4-turbo-preview": 128000,
"gpt-4o": 128000,
"gpt-3.5-turbo-instruct": 16385,
"gpt-4-0125-preview": 128000,
"gpt-3.5-turbo-0125": 16385,
# "babbage-002": 128000,
# "davinci-002": 128000,
"gpt-4-turbo-2024-04-09": 128000,
# "gpt-4o-realtime-preview-2024-10-01
"gpt-4-turbo": 8192,
"gpt-4o-2024-05-13": 128000,
# "o1-mini
# "o1-mini-2024-09-12
# "gpt-3.5-turbo-instruct-0914
"gpt-4o-mini": 128000,
# "gpt-4o-realtime-preview
"gpt-4o-mini-2024-07-18": 128000,
# gpt-4
"gpt-4-1106-preview": 128000,
"gpt-4": 8192,
Expand Down
6 changes: 6 additions & 0 deletions letta/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def list_llm_models(self) -> List[LLMConfig]:
configs.append(
LLMConfig(model=model_name, model_endpoint_type="openai", model_endpoint=self.base_url, context_window=context_window_size)
)

# for OpenAI, sort in reverse order
if self.base_url == "https://api.openai.com/v1":
# alphnumeric sort
configs.sort(key=lambda x: x.model, reverse=True)

return configs

def list_embedding_models(self) -> List[EmbeddingConfig]:
Expand Down

0 comments on commit 60b51b4

Please sign in to comment.