Skip to content

Commit 71ab065

Browse files
Merge pull request #75 from FormulaMonks/feat/add-support-to-latest-gpt-models
feat: updated OpenAI GPT supported models
2 parents d870c23 + 44fd0bb commit 71ab065

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

packages/kurt-open-ai/src/KurtOpenAI.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ import { BadRequestError } from "openai"
4444

4545
// These models support function calling.
4646
const COMPATIBLE_MODELS = [
47+
"o4-mini",
48+
"o4-mini-2025-04-16",
49+
"o3-mini",
50+
"o3-mini-2025-01-31",
51+
"o3",
52+
"o3-2025-04-16",
53+
"o3-pro",
54+
"o3-pro-2025-06-10",
55+
"o1-pro",
56+
"o1-pro-2025-03-19",
57+
"o1",
58+
"o1-2024-12-17",
4759
"gpt-4.1",
4860
"gpt-4.1-2025-04-14",
4961
"gpt-4.1-mini",
@@ -160,13 +172,14 @@ export class KurtOpenAI implements KurtAdapterV1<KurtOpenAiAdapterTypeParams> {
160172
tools: { [key: string]: OpenAITool }
161173
forceTool?: string
162174
}): AsyncIterable<OpenAIResponseChunk> {
175+
const sampling = adjustSampling(this.options.model, options.sampling)
163176
const req: OpenAIRequest = {
164177
stream: true,
165178
store: false,
166179
model: this.options.model,
167-
max_output_tokens: options.sampling.maxOutputTokens,
168-
temperature: options.sampling.temperature,
169-
top_p: options.sampling.topP,
180+
max_output_tokens: sampling.maxOutputTokens,
181+
temperature: sampling.temperature,
182+
top_p: sampling.topP,
170183
input: options.messages,
171184
}
172185

@@ -706,3 +719,18 @@ function withInjectedSystemPromptLine(
706719
: message
707720
)
708721
}
722+
723+
function adjustSampling(
724+
model: KurtOpenAISupportedModel,
725+
sampling: Required<KurtSamplingOptions>
726+
) {
727+
if (model.startsWith("o")) {
728+
return {
729+
temperature: null,
730+
topP: null,
731+
maxOutputTokens: sampling.maxOutputTokens,
732+
forceSchemaConstrainedTokens: sampling.forceSchemaConstrainedTokens,
733+
}
734+
}
735+
return sampling
736+
}

0 commit comments

Comments
 (0)