Skip to content

Commit

Permalink
fix: o3-mini doesn't support temperature (#266)
Browse files Browse the repository at this point in the history
* fix: o3-mini doesn't support temperature
* fix: only add temperature if it exists
  • Loading branch information
joshua-mo-143 authored Feb 12, 2025
1 parent 1b71738 commit 08bed8c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions rig-core/src/providers/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,18 +901,30 @@ impl completion::CompletionModel for CompletionModel {
json!({
"model": self.model,
"messages": full_history,
"temperature": completion_request.temperature,

})
} else {
json!({
"model": self.model,
"messages": full_history,
"temperature": completion_request.temperature,
"tools": completion_request.tools.into_iter().map(ToolDefinition::from).collect::<Vec<_>>(),
"tool_choice": "auto",
})
};

// only include temperature if it exists
// because some models don't support temperature
let request = if let Some(temperature) = completion_request.temperature {
json_utils::merge(
request,
json!({
"temperature": temperature,
}),
)
} else {
request
};

let response = self
.client
.post("/chat/completions")
Expand Down

0 comments on commit 08bed8c

Please sign in to comment.