Skip to content

Commit cbf7e11

Browse files
committed
fix gpt-5
1 parent c3662b1 commit cbf7e11

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

config/agent_gaia-validation-gpt5.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ main_agent:
88
prompt_class: MainAgentPrompt_GAIA
99
llm:
1010
provider_class: "GPT5OpenAIClient"
11-
model_name: "gpt-5-2025-08-07"
11+
model_name: "gpt-5"
1212
async_client: true
1313
temperature: 1.0
1414
top_p: 1.0
1515
min_p: 0.0
1616
top_k: -1
1717
max_tokens: 128000
1818
reasoning_effort: "high"
19-
openrouter_api_key: "${oc.env:OPENAI_API_KEY,???}"
20-
openrouter_base_url: "${oc.env:OPENAI_BASE_URL,https://api.openai.com/v1}"
19+
openai_api_key: "${oc.env:OPENAI_API_KEY,???}"
20+
openai_base_url: "${oc.env:OPENAI_BASE_URL,https://api.openai.com/v1}"
2121
openrouter_provider: ""
2222
disable_cache_control: true
2323
keep_tool_result: -1
@@ -30,11 +30,13 @@ main_agent:
3030
max_tool_calls_per_turn: 10 # Maximum number of tool calls per turn
3131

3232
input_process:
33-
o3_hint: true
33+
hint_generation: true
34+
hint_llm_base_url: "${oc.env:HINT_LLM_BASE_URL,https://api.openai.com/v1}"
3435
output_process:
35-
o3_final_answer: true
36+
final_answer_extraction: true
37+
final_answer_llm_base_url: "${oc.env:FINAL_ANSWER_LLM_BASE_URL,https://api.openai.com/v1}"
3638

37-
openai_api_key: "${oc.env:OPENAI_API_KEY,???}" # used for o3 hints and final answer extraction
39+
openai_api_key: "${oc.env:OPENAI_API_KEY,???}" # used for hint generation and final answer extraction
3840
add_message_id: true
3941
keep_tool_result: -1
4042
chinese_context: "${oc.env:CHINESE_CONTEXT,false}"
@@ -44,16 +46,17 @@ sub_agents:
4446
agent-worker:
4547
prompt_class: SubAgentWorkerPrompt
4648
llm:
47-
provider_class: "ClaudeOpenRouterClient"
48-
model_name: "gpt-5-2025-08-07"
49+
provider_class: "GPT5OpenAIClient"
50+
model_name: "gpt-5"
4951
async_client: true
5052
temperature: 1.0
5153
top_p: 1.0
5254
min_p: 0.0
5355
top_k: -1
5456
max_tokens: 128000
55-
openrouter_api_key: "${oc.env:OPENAI_API_KEY,???}"
56-
openrouter_base_url: "${oc.env:OPENAI_BASE_URL,https://api.openai.com/v1}"
57+
reasoning_effort: "medium"
58+
openai_api_key: "${oc.env:OPENAI_API_KEY,???}"
59+
openai_base_url: "${oc.env:OPENAI_BASE_URL,https://api.openai.com/v1}"
5760
openrouter_provider: ""
5861
disable_cache_control: true
5962
keep_tool_result: -1

src/llm/providers/gpt5_openai_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ def _create_client(self, config: DictConfig):
3737
"""Create configured OpenAI client"""
3838
if self.async_client:
3939
return AsyncOpenAI(
40-
api_key=self.cfg.llm.openrouter_api_key,
41-
base_url=self.cfg.llm.openrouter_base_url,
40+
api_key=self.cfg.llm.openai_api_key,
41+
base_url=self.cfg.llm.openai_base_url,
4242
timeout=1800,
4343
)
4444
else:
4545
return OpenAI(
46-
api_key=self.cfg.llm.openrouter_api_key,
47-
base_url=self.cfg.llm.openrouter_base_url,
46+
api_key=self.cfg.llm.openai_api_key,
47+
base_url=self.cfg.llm.openai_base_url,
4848
timeout=1800,
4949
)
5050

src/llm/providers/gpt_openai_client.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
LOGGER_LEVEL = os.getenv("LOGGER_LEVEL", "INFO")
2020
# OPENAI reasoning models only support temperature=1
21-
OPENAI_REASONING_MODEL_SET = set(["o1", "o3", "o3-mini", "o4-mini"])
21+
OPENAI_REASONING_MODEL_SET = set(["o1", "o3", "o3-mini", "o4-mini", "gpt-5", "gpt-5-2025-08-07"])
2222

2323
logger = bootstrap_logger(level=LOGGER_LEVEL)
2424

@@ -29,13 +29,15 @@ def _create_client(self, config: DictConfig):
2929
"""Create configured OpenAI client"""
3030
if self.async_client:
3131
return AsyncOpenAI(
32-
api_key=config.env.openai_api_key,
33-
base_url=config.env.openai_base_url,
32+
api_key=self.cfg.llm.openai_api_key,
33+
base_url=self.cfg.llm.openai_base_url,
34+
timeout=1800,
3435
)
3536
else:
3637
return OpenAI(
37-
api_key=config.env.openai_api_key,
38-
base_url=config.env.openai_base_url,
38+
api_key=self.cfg.llm.openai_api_key,
39+
base_url=self.cfg.llm.openai_base_url,
40+
timeout=1800,
3941
)
4042

4143
@retry(wait=wait_fixed(10), stop=stop_after_attempt(5))
@@ -58,6 +60,7 @@ async def _create_message(
5860
or self.model_name.startswith("o4")
5961
or self.model_name.startswith("gpt-4.1")
6062
or self.model_name.startswith("gpt-4o")
63+
or self.model_name.startswith("gpt-5")
6164
)
6265
logger.debug(f" Calling LLM ({'async' if self.async_client else 'sync'})")
6366
# put the system prompt in the first message since OpenAI API does not support system prompt in
@@ -88,21 +91,28 @@ async def _create_message(
8891
tool_list = await self.convert_tool_definition_to_tool_call(tools_definitions)
8992

9093
try:
91-
# Set temperature=1 for reasoning models
92-
temperature = (
93-
1.0
94-
if self.model_name in OPENAI_REASONING_MODEL_SET
95-
else self.temperature
96-
)
97-
98-
params = {
99-
"model": self.model_name,
100-
"temperature": temperature,
101-
"max_completion_tokens": self.max_tokens,
102-
"messages": messages_copy,
103-
"tools": tool_list,
104-
"stream": False,
105-
}
94+
# Set temperature and reasoning_effort for reasoning models
95+
if self.model_name in OPENAI_REASONING_MODEL_SET:
96+
temperature = 1.0
97+
params = {
98+
"model": self.model_name,
99+
"temperature": temperature,
100+
"max_completion_tokens": self.max_tokens,
101+
"messages": messages_copy,
102+
"reasoning_effort": self.reasoning_effort,
103+
"tools": tool_list,
104+
"stream": False,
105+
}
106+
else:
107+
temperature = self.temperature
108+
params = {
109+
"model": self.model_name,
110+
"temperature": temperature,
111+
"max_completion_tokens": self.max_tokens,
112+
"messages": messages_copy,
113+
"tools": tool_list,
114+
"stream": False,
115+
}
106116

107117
if self.top_p != 1.0:
108118
params["top_p"] = self.top_p

0 commit comments

Comments
 (0)