|
1 |
| -import re |
2 | 1 | import time
|
3 | 2 | from datetime import datetime
|
4 | 3 | from typing import Any
|
|
8 | 7 | from dspy.clients.provider import Provider, TrainingJob
|
9 | 8 | from dspy.clients.utils_finetune import TrainDataFormat, TrainingStatus, save_data
|
10 | 9 |
|
11 |
| -_OPENAI_MODELS = [ |
12 |
| - "gpt-4-turbo", |
13 |
| - "gpt-4-turbo-2024-04-09", |
14 |
| - "tts-1", |
15 |
| - "tts-1-1106", |
16 |
| - "chatgpt-4o-latest", |
17 |
| - "dall-e-2", |
18 |
| - "whisper-1", |
19 |
| - "gpt-3.5-turbo-instruct", |
20 |
| - "gpt-3.5-turbo", |
21 |
| - "gpt-3.5-turbo-0125", |
22 |
| - "babbage-002", |
23 |
| - "davinci-002", |
24 |
| - "gpt-4o-mini-2024-07-18", |
25 |
| - "gpt-4o", |
26 |
| - "dall-e-3", |
27 |
| - "gpt-4o-mini", |
28 |
| - "gpt-4o-2024-08-06", |
29 |
| - "gpt-4o-2024-05-13", |
30 |
| - "o1-preview", |
31 |
| - "gpt-4o-audio-preview-2024-10-01", |
32 |
| - "o1-mini-2024-09-12", |
33 |
| - "gpt-4o-audio-preview", |
34 |
| - "tts-1-hd", |
35 |
| - "tts-1-hd-1106", |
36 |
| - "o1-preview-2024-09-12", |
37 |
| - "o1-mini", |
38 |
| - "gpt-4-1106-preview", |
39 |
| - "text-embedding-ada-002", |
40 |
| - "gpt-3.5-turbo-16k", |
41 |
| - "text-embedding-3-small", |
42 |
| - "text-embedding-3-large", |
43 |
| - "gpt-4o-realtime-preview-2024-10-01", |
44 |
| - "gpt-4o-realtime-preview", |
45 |
| - "gpt-3.5-turbo-1106", |
46 |
| - "gpt-4-0613", |
47 |
| - "gpt-4-turbo-preview", |
48 |
| - "gpt-4-0125-preview", |
49 |
| - "gpt-4", |
50 |
| - "gpt-3.5-turbo-instruct-0914", |
51 |
| -] |
52 |
| - |
53 | 10 |
|
54 | 11 | class TrainingJobOpenAI(TrainingJob):
|
55 | 12 | def __init__(self, *args, **kwargs):
|
@@ -90,24 +47,9 @@ def __init__(self):
|
90 | 47 |
|
91 | 48 | @staticmethod
|
92 | 49 | def is_provider_model(model: str) -> bool:
|
93 |
| - model = OpenAIProvider._remove_provider_prefix(model) |
94 |
| - |
95 |
| - # Check if the model is a base OpenAI model |
96 |
| - # TODO(enhance) The following list can be replaced with |
97 |
| - # openai.models.list(), but doing so might require a key. Is there a |
98 |
| - # way to get the list of models without a key? |
99 |
| - if model in _OPENAI_MODELS: |
100 |
| - return True |
101 |
| - |
102 |
| - # Check if the model is a fine-tuned OpenAI model. Fine-tuned OpenAI |
103 |
| - # models have the prefix "ft:<BASE_MODEL_NAME>:", followed by a string |
104 |
| - # specifying the fine-tuned model. The following RegEx pattern is used |
105 |
| - # to match the base model name. |
106 |
| - # TODO(enhance): This part can be updated to match the actual fine-tuned |
107 |
| - # model names by making a call to the OpenAI API to be more exact, but |
108 |
| - # this might require an API key with the right permissions. |
109 |
| - match = re.match(r"ft:([^:]+):", model) |
110 |
| - if match and match.group(1) in _OPENAI_MODELS: |
| 50 | + if model.startswith("openai/") or model.startswith("ft:"): |
| 51 | + # Althought it looks strange, `ft:` is a unique identifer for openai finetuned models in litellm context: |
| 52 | + # https://github.com/BerriAI/litellm/blob/cd893134b7974d9f21477049a373b469fff747a5/litellm/utils.py#L4495 |
111 | 53 | return True
|
112 | 54 |
|
113 | 55 | return False
|
|
0 commit comments