Skip to content

Commit a3bf9a5

Browse files
Address Copilot and Codex bot feedback: fix regex pattern and enhance reasoning model support
Co-authored-by: PeterDaveHello <[email protected]>
1 parent 08b7cca commit a3bf9a5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/services/apis/openai-api.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ export async function generateAnswersWithChatgptApiCompat(
165165
requestBody.n = 1
166166
requestBody.presence_penalty = 0
167167
requestBody.frequency_penalty = 0
168+
// Disallow tools/functions/function calling in reasoning mode
169+
delete requestBody.tools
170+
delete requestBody.tool_choice
171+
delete requestBody.functions
172+
delete requestBody.function_call
168173
} else {
169174
// Non-reasoning models use the existing behavior
170175
requestBody.stream = true

src/utils/model-name-convert.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ export function isUsingReasoningModel(configOrSession) {
169169
const modelValue = getModelValue(configOrSession)
170170
if (!modelValue) return false
171171

172-
// Explicitly match o1, o3, or o4 with optional dash and suffix (e.g., o1, o1-preview, o3-mini, o4-mini)
173-
if (/^(o1|o3|o4)(?:-|$)/.test(modelValue)) {
172+
// Explicitly match o1, o3, or o4 as standalone or with a dash and valid suffix (e.g., o1, o1-preview, o3-mini, o4-mini)
173+
if (/^(o1|o3|o4)(?:$|-[a-zA-Z][\w-]*)$/.test(modelValue)) {
174174
return true
175175
}
176176

0 commit comments

Comments
 (0)