Skip to content

Commit

Permalink
Revert "Add support for o1-preview & o1-mini"
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko authored Dec 12, 2024
1 parent 3e8996c commit 42641d1
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 118 deletions.
44 changes: 8 additions & 36 deletions daras_ai_v2/language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,10 @@ class LLMSpec(typing.NamedTuple):
is_vision_model: bool = False
is_deprecated: bool = False
supports_json: bool = False
supports_temperature: bool = True


class LargeLanguageModels(Enum):
# https://platform.openai.com/docs/models#o1
o1_preview = LLMSpec(
label="o1-preview (openai)",
model_id="o1-preview-2024-09-12",
llm_api=LLMApis.openai,
context_window=128_000,
price=50,
is_vision_model=False,
supports_json=False,
supports_temperature=False,
)

# https://platform.openai.com/docs/models#o1
o1_mini = LLMSpec(
label="o1-mini (openai)",
model_id="o1-mini-2024-09-12",
llm_api=LLMApis.openai,
context_window=128_000,
price=13,
is_vision_model=False,
supports_json=False,
supports_temperature=False,
)

# https://platform.openai.com/docs/models#gpt-4o
# https://platform.openai.com/docs/models/gpt-4o
gpt_4_o = LLMSpec(
label="GPT-4o (openai)",
model_id="gpt-4o-2024-08-06",
Expand All @@ -109,7 +84,7 @@ class LargeLanguageModels(Enum):
is_vision_model=True,
supports_json=True,
)
# https://platform.openai.com/docs/models#gpt-4o-mini
# https://platform.openai.com/docs/models/gpt-4o-mini
gpt_4_o_mini = LLMSpec(
label="GPT-4o-mini (openai)",
model_id="gpt-4o-mini",
Expand Down Expand Up @@ -521,7 +496,6 @@ def __init__(self, *args):
self.is_chat_model = spec.is_chat_model
self.is_vision_model = spec.is_vision_model
self.supports_json = spec.supports_json
self.supports_temperature = spec.supports_temperature

@property
def value(self):
Expand Down Expand Up @@ -625,8 +599,6 @@ def run_language_model(
messages[0]["content"] = "\n\n".join(
[get_entry_text(messages[0]), DEFAULT_JSON_PROMPT]
)
if not model.supports_temperature:
temperature = None
result = _run_chat_model(
api=model.llm_api,
model=model.model_id,
Expand Down Expand Up @@ -763,7 +735,7 @@ def _run_chat_model(
messages: list[ConversationEntry],
max_tokens: int,
num_outputs: int,
temperature: float | None,
temperature: float,
stop: list[str] | None,
avoid_repetition: bool,
tools: list[LLMTool] | None,
Expand All @@ -778,7 +750,7 @@ def _run_chat_model(
return _run_openai_chat(
model=model,
avoid_repetition=avoid_repetition,
max_completion_tokens=max_tokens,
max_tokens=max_tokens,
messages=messages,
num_outputs=num_outputs,
stop=stop,
Expand Down Expand Up @@ -1031,9 +1003,9 @@ def _run_openai_chat(
*,
model: str,
messages: list[ConversationEntry],
max_completion_tokens: int,
max_tokens: int,
num_outputs: int,
temperature: float | None = None,
temperature: float,
stop: list[str] | None = None,
avoid_repetition: bool = False,
tools: list[LLMTool] | None = None,
Expand All @@ -1055,10 +1027,10 @@ def _run_openai_chat(
_get_chat_completions_create(
model=model_str,
messages=messages,
max_completion_tokens=max_completion_tokens,
max_tokens=max_tokens,
stop=stop or NOT_GIVEN,
n=num_outputs,
temperature=temperature if temperature is not None else NOT_GIVEN,
temperature=temperature,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty,
tools=[tool.spec for tool in tools] if tools else NOT_GIVEN,
Expand Down
Loading

0 comments on commit 42641d1

Please sign in to comment.