Skip to content

Update OpenAI model list #8589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 3 additions & 60 deletions dspy/clients/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,6 @@
from dspy.clients.provider import Provider, TrainingJob
from dspy.clients.utils_finetune import TrainDataFormat, TrainingStatus, save_data

_OPENAI_MODELS = [
"gpt-4-turbo",
"gpt-4-turbo-2024-04-09",
"tts-1",
"tts-1-1106",
"chatgpt-4o-latest",
"dall-e-2",
"whisper-1",
"gpt-3.5-turbo-instruct",
"gpt-3.5-turbo",
"gpt-3.5-turbo-0125",
"babbage-002",
"davinci-002",
"gpt-4o-mini-2024-07-18",
"gpt-4o",
"dall-e-3",
"gpt-4o-mini",
"gpt-4o-2024-08-06",
"gpt-4o-2024-05-13",
"o1-preview",
"gpt-4o-audio-preview-2024-10-01",
"o1-mini-2024-09-12",
"gpt-4o-audio-preview",
"tts-1-hd",
"tts-1-hd-1106",
"o1-preview-2024-09-12",
"o1-mini",
"gpt-4-1106-preview",
"text-embedding-ada-002",
"gpt-3.5-turbo-16k",
"text-embedding-3-small",
"text-embedding-3-large",
"gpt-4o-realtime-preview-2024-10-01",
"gpt-4o-realtime-preview",
"gpt-3.5-turbo-1106",
"gpt-4-0613",
"gpt-4-turbo-preview",
"gpt-4-0125-preview",
"gpt-4",
"gpt-3.5-turbo-instruct-0914",
]


class TrainingJobOpenAI(TrainingJob):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -90,24 +48,9 @@ def __init__(self):

@staticmethod
def is_provider_model(model: str) -> bool:
model = OpenAIProvider._remove_provider_prefix(model)

# Check if the model is a base OpenAI model
# TODO(enhance) The following list can be replaced with
# openai.models.list(), but doing so might require a key. Is there a
# way to get the list of models without a key?
if model in _OPENAI_MODELS:
return True

# Check if the model is a fine-tuned OpneAI model. Fine-tuned OpenAI
# models have the prefix "ft:<BASE_MODEL_NAME>:", followed by a string
# specifying the fine-tuned model. The following RegEx pattern is used
# to match the base model name.
# TODO(enhance): This part can be updated to match the actual fine-tuned
# model names by making a call to the OpenAI API to be more exact, but
# this might require an API key with the right permissions.
match = re.match(r"ft:([^:]+):", model)
if match and match.group(1) in _OPENAI_MODELS:
if model.startswith("openai/") or model.startswith("ft:"):
# Althought it looks strange, `ft:` is a unique identifer for openai finetuned models in litellm context:
# https://github.com/BerriAI/litellm/blob/cd893134b7974d9f21477049a373b469fff747a5/litellm/utils.py#L4495
return True

return False
Expand Down