Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions api/config/generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"gpt-5-mini": {
"temperature": 1.0
},
"gpt-5.2": {
"temperature": 1.0
},
"gpt-5.2-pro": {},
"gpt-4o": {
"temperature": 0.7,
"top_p": 0.8
Expand Down
6 changes: 4 additions & 2 deletions api/simple_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,11 @@ async def chat_completions_stream(request: ChatCompletionRequest):
model_kwargs = {
"model": request.model,
"stream": True,
"temperature": model_config["temperature"]
}
# Only add top_p if it exists in the model config
# Only add temperature/top_p if they exist in the model config
# (reasoning models like gpt-5.2-pro do not support these parameters)
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]
if "top_p" in model_config:
model_kwargs["top_p"] = model_config["top_p"]

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.

medium

To improve maintainability and make it easier to add more optional parameters in the future, you could use a loop to iterate over the optional parameters and add them to model_kwargs if they exist in model_config. This avoids repeating the if ... in ... block for each parameter.

Suggested change
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]
if "top_p" in model_config:
model_kwargs["top_p"] = model_config["top_p"]
for param in ["temperature", "top_p"]:
if param in model_config:
model_kwargs[param] = model_config[param]


Expand Down
6 changes: 4 additions & 2 deletions api/websocket_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,11 @@ async def handle_websocket_chat(websocket: WebSocket):
model_kwargs = {
"model": request.model,
"stream": True,
"temperature": model_config["temperature"]
}
# Only add top_p if it exists in the model config
# Only add temperature/top_p if they exist in the model config
# (reasoning models like gpt-5.2-pro do not support these parameters)
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]
if "top_p" in model_config:
model_kwargs["top_p"] = model_config["top_p"]

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.

medium

Similar to the other file, you can use a loop here to handle optional parameters. This will make the code more concise and easier to maintain if more optional parameters are added later.

Suggested change
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]
if "top_p" in model_config:
model_kwargs["top_p"] = model_config["top_p"]
for param in ["temperature", "top_p"]:
if param in model_config:
model_kwargs[param] = model_config[param]


Expand Down