Skip to content

Commit

Permalink
Add reasoning_effort for o3
Browse files Browse the repository at this point in the history
  • Loading branch information
RobBlackwell committed Feb 5, 2025
1 parent 806a8ba commit 5f3ac66
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 30 deletions.
4 changes: 4 additions & 0 deletions azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def ask_azure(
max_tokens,
logprobs,
top_logprobs,
reasoning_effort,
):
"""
Make a request to the Azure OpenAI API.
Expand Down Expand Up @@ -75,6 +76,9 @@ def ask_azure(
if top_logprobs is not None:
json_data["top_logprobs"] = top_logprobs

if reasoning_effort is not None:
json_data["reasoning_effort"] = reasoning_effort

request = None
response = None
try:
Expand Down
75 changes: 45 additions & 30 deletions golem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Time-stamp: <2025-01-28 16:02:52 rblackwell>
# Time-stamp: <2025-02-03 20:24:41 rblackwell>

"""Golem
Expand Down Expand Up @@ -80,35 +80,7 @@ def ask(
seed = args.seed
url = args.url
key = args.key

if provider == "azure":
return ask_azure(
model,
url,
key,
messages,
temperature,
seed,
top_p,
max_tokens,
logprobs,
top_logprobs,
)

if provider == "azureai":
if model is not None:
logging.warning("Ignoring model")
return ask_azureai(
url,
key,
messages,
temperature,
seed,
top_p,
max_tokens,
logprobs,
top_logprobs,
)
reasoning_effort = args.reasoning_effort

if provider == "openai":
return ask_openai(
Expand All @@ -123,6 +95,7 @@ def ask(
max_tokens,
logprobs,
top_logprobs,
reasoning_effort,
)

if provider == "deepseek":
Expand All @@ -149,6 +122,7 @@ def ask(
max_tokens,
logprobs,
top_logprobs,
reasoning_effort,
)

if provider == "xai":
Expand All @@ -175,6 +149,40 @@ def ask(
max_tokens,
logprobs,
top_logprobs,
reasoning_effort,
)

if provider == "azure":
return ask_azure(
model,
url,
key,
messages,
temperature,
seed,
top_p,
max_tokens,
logprobs,
top_logprobs,
reasoning_effort,
)

if reasoning_effort is not None:
logging.warning("Ignoring reasoning_effort")

if provider == "azureai":
if model is not None:
logging.warning("Ignoring model")
return ask_azureai(
url,
key,
messages,
temperature,
seed,
top_p,
max_tokens,
logprobs,
top_logprobs,
)

if top_logprobs is not None:
Expand Down Expand Up @@ -345,6 +353,13 @@ def make_parser():
help="Setting the random seed makes some models more deterministic.",
)

parser.add_argument(
"--reasoning_effort",
type=str,
default=None,
help="Constrains effort on reasoning for reasoning models, low, medium, or high.",
)

parser.add_argument(
"--max_tokens", type=int, default=None, help="Maximum number of tokens."
)
Expand Down
4 changes: 4 additions & 0 deletions openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def ask_openai(
max_tokens,
logprobs,
top_logprobs,
reasoning_effort,
):
"""
Make a request to the OpenAI API.
Expand Down Expand Up @@ -60,6 +61,9 @@ def ask_openai(
if top_logprobs is not None:
json_data["top_logprobs"] = top_logprobs

if reasoning_effort is not None:
json_data["reasoning_effort"] = reasoning_effort

request = None
response = None
try:
Expand Down

0 comments on commit 5f3ac66

Please sign in to comment.