Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
13 changes: 2 additions & 11 deletions notdiamond/llms/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
MissingLLMConfigs,
)
from notdiamond.llms.config import LLMConfig
from notdiamond.llms.providers import is_o1_model
from notdiamond.llms.request import (
amodel_select,
create_preference_id,
Expand All @@ -43,7 +42,6 @@
from notdiamond.prompts import (
_curly_escape,
inject_system_prompt,
o1_system_prompt_translate,
)
from notdiamond.types import NDApiKeyValidator

Expand Down Expand Up @@ -907,13 +905,11 @@ def invoke(
messages, best_llm.system_prompt
)

messages = o1_system_prompt_translate(messages, best_llm)

self.call_callbacks("on_model_select", best_llm, best_llm.model)

llm = self._llm_from_config(best_llm, callbacks=self.callbacks)

if self.tools and not is_o1_model(best_llm):
if self.tools:
llm = llm.bind_tools(self.tools)

if response_model is not None:
Expand Down Expand Up @@ -1110,13 +1106,11 @@ async def ainvoke(
messages, best_llm.system_prompt
)

messages = o1_system_prompt_translate(messages, best_llm)

self.call_callbacks("on_model_select", best_llm, best_llm.model)

llm = self._llm_from_config(best_llm, callbacks=self.callbacks)

if self.tools and not is_o1_model(best_llm):
if self.tools:
llm = llm.bind_tools(self.tools)

if response_model is not None:
Expand Down Expand Up @@ -1549,9 +1543,6 @@ def _llm_from_config(
"ChatOpenAI",
provider.provider,
)
if is_o1_model(provider):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the new O models support temperature or other reasoning models for that matter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this check from what I see we checked only o1 models (preview and mini), we don't have any O models within this one 🤷

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok actually I recall temperature is no longer a param in the newer models, we can just remove this check and expect the user to get an error if they specify temperature

passed_kwargs["temperature"] = 1.0

return ChatOpenAI(
openai_api_key=provider.api_key,
model_name=provider.model,
Expand Down
15 changes: 0 additions & 15 deletions notdiamond/llms/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class NDLLMProviders(Enum):
GPT_4_1_MINI_2025_04_14 (NDLLMProvider): refers to 'gpt-4.1-mini-2025-04-14' model by OpenAI
GPT_4_1_NANO (NDLLMProvider): refers to 'gpt-4.1-nano' model by OpenAI
GPT_4_1_NANO_2025_04_14 (NDLLMProvider): refers to 'gpt-4.1-nano-2025-04-14' model by OpenAI
O1_PREVIEW (NDLLMProvider): refers to 'o1-preview' model by OpenAI
O1_PREVIEW_2024_09_12 (NDLLMProvider): refers to 'o1-preview-2024-09-12' model by OpenAI
O1_MINI (NDLLMProvider): refers to 'o1-mini' model by OpenAI
O1_MINI_2024_09_12 (NDLLMProvider): refers to 'o1-mini-2024-09-12' model by OpenAI

CLAUDE_2_1 (NDLLMProvider): refers to 'claude-2.1' model by Anthropic
CLAUDE_3_OPUS_20240229 (NDLLMProvider): refers to 'claude-3-opus-20240229' model by Anthropic
Expand Down Expand Up @@ -117,10 +113,6 @@ class NDLLMProviders(Enum):
GPT_4_1_MINI_2025_04_14 = ("openai", "gpt-4.1-mini-2025-04-14")
GPT_4_1_NANO = ("openai", "gpt-4.1-nano")
GPT_4_1_NANO_2025_04_14 = ("openai", "gpt-4.1-nano-2025-04-14")
O1_PREVIEW = ("openai", "o1-preview")
O1_PREVIEW_2024_09_12 = ("openai", "o1-preview-2024-09-12")
O1_MINI = ("openai", "o1-mini")
O1_MINI_2024_09_12 = ("openai", "o1-mini-2024-09-12")
CHATGPT_4o_LATEST = ("openai", "chatgpt-4o-latest")

CLAUDE_2_1 = ("anthropic", "claude-2.1")
Expand Down Expand Up @@ -223,10 +215,3 @@ def __new__(cls, provider, model):
return LLMConfig(provider=provider, model=model)


def is_o1_model(llm: LLMConfig):
return llm in (
NDLLMProviders.O1_PREVIEW,
NDLLMProviders.O1_PREVIEW_2024_09_12,
NDLLMProviders.O1_MINI,
NDLLMProviders.O1_MINI_2024_09_12,
)
17 changes: 0 additions & 17 deletions notdiamond/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import re
from typing import Dict, List

from notdiamond.llms.config import LLMConfig
from notdiamond.llms.providers import is_o1_model

LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.INFO)

Expand Down Expand Up @@ -37,17 +34,3 @@ def _curly_escape(text: str) -> str:
return re.sub(r"(?<!{){([a-zA-Z])}(?!})", r"{{\1}}", text)


def o1_system_prompt_translate(
messages: List[Dict[str, str]], llm: LLMConfig
) -> List[Dict[str, str]]:
if is_o1_model(llm):
translated_messages = []
for msg in messages:
if msg["role"] == "system":
translated_messages.append(
{"role": "user", "content": msg["content"]}
)
else:
translated_messages.append(msg)
return translated_messages
return messages
16 changes: 0 additions & 16 deletions notdiamond/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
"gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano",
"gpt-4.1-nano-2025-04-14",
"o1-preview",
"o1-preview-2024-09-12",
"o1-mini",
"o1-mini-2024-09-12",
"chatgpt-4o-latest",
],
"api_key": OPENAI_API_KEY,
Expand Down Expand Up @@ -89,10 +85,6 @@
"gpt-4-turbo-preview",
"gpt-4-0125-preview",
"gpt-4-1106-preview",
"o1-preview",
"o1-preview-2024-09-12",
"o1-mini",
"o1-mini-2024-09-12",
"chatgpt-4o-latest",
"gpt-4.1",
"gpt-4.1-2025-04-14",
Expand All @@ -112,10 +104,6 @@
"gpt-4o-mini-2024-07-18": "openai/gpt-4o-mini-2024-07-18",
"gpt-4-turbo-preview": "openai/gpt-4-turbo-preview",
"gpt-4-1106-preview": "openai/gpt-4-1106-preview",
"o1-preview": "openai/o1-preview",
"o1-preview-2024-09-12": "openai/o1-preview-2024-09-12",
"o1-mini": "openai/o1-mini",
"o1-mini-2024-09-12": "openai/o1-mini-2024-09-12",
"chatgpt-4o-latest": "openai/chatgpt-4o-latest",
"gpt-4.1": "openai/gpt-4.1",
"gpt-4.1-2025-04-14": "openai/gpt-4.1-2025-04-14",
Expand All @@ -139,10 +127,6 @@
"gpt-4-turbo-preview": {"input": 10.0, "output": 30.0},
"gpt-4-0125-preview": {"input": 10.0, "output": 30.0},
"gpt-4-1106-preview": {"input": 10.0, "output": 30.0},
"o1-preview": {"input": 15.0, "output": 60.0},
"o1-preview-2024-09-12": {"input": 15.0, "output": 60.0},
"o1-mini": {"input": 3.0, "output": 12.0},
"o1-mini-2024-09-12": {"input": 3.0, "output": 12.0},
"chatgpt-4o-latest": {"input": 5.0, "output": 15.0},
"gpt-4.1": {"input": 2.0, "output": 8.0},
"gpt-4.1-mini": {"input": 0.5, "output": 1.6},
Expand Down

This file was deleted.

Loading
Loading