handle-custom-models

This commit is contained in:
aadarshkt 2025-04-02 07:41:26 +05:30
parent 9e3e28d153
commit 6d927bced9
2 changed files with 17 additions and 15 deletions

View file

@ -1,22 +1,22 @@
{
"name": "@continuedev/openai-adapters",
"version": "1.0.12",
"version": "1.0.18",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@continuedev/openai-adapters",
"version": "1.0.12",
"version": "1.0.18",
"license": "Apache-2.0",
"dependencies": {
"@azure/openai": "^1.0.0-beta.12",
"@continuedev/config-types": "^1.0.5",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "^1.0.51",
"@continuedev/fetch": "^1.0.3",
"json-schema": "^0.4.0",
"node-fetch": "^3.3.2",
"openai": "^4.76.0",
"zod": "^3.23.8"
"zod": "^3.24.2"
},
"devDependencies": {
"@types/follow-redirects": "^1.14.4",
@ -712,13 +712,14 @@
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.31",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.31.tgz",
"integrity": "sha512-HNj+z7UTTARgsJTI0A1buM09fS4HoWVnn6Hbl6kJ2tZmOOm1OgogbcKP68AzHb4fy5H18MWnKS7XuseZpHFzHQ==",
"version": "1.0.68",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.68.tgz",
"integrity": "sha512-rCegSGkv7Ws7LLnYVVGwXsoVZFpNFJnG6b1dVrj/u+2ZsFdA2leQUNtFGoeE/ixyfhUfBpMlgjEyPrmmy7gLjw==",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.23.8"
"zod": "^3.24.2"
}
},
"node_modules/@continuedev/fetch": {
@ -4541,9 +4542,10 @@
}
},
"node_modules/zod": {
"version": "3.23.8",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
"version": "3.24.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz",
"integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}

View file

@ -1,5 +1,4 @@
import { streamSse } from "@continuedev/fetch";
import fetch from "node-fetch";
import { OpenAI } from "openai/index";
import {
ChatCompletion,
@ -14,7 +13,7 @@ import {
} from "openai/resources/index";
import { z } from "zod";
import { OpenAIConfigSchema } from "../types.js";
import { customFetch, maybeCustomFetch } from "../util.js";
import { customFetch } from "../util.js";
import {
BaseLlmApi,
CreateRerankResponse,
@ -36,8 +35,9 @@ export class OpenAIApi implements BaseLlmApi {
}
modifyChatBody<T extends ChatCompletionCreateParams>(body: T): T {
// o-series models
if (body.model.startsWith("o")) {
// o-series models - only apply for official OpenAI API
const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/";
if (isOfficialOpenAIAPI && body.model.startsWith("o")) {
// a) use max_completion_tokens instead of max_tokens
body.max_completion_tokens = body.max_tokens;
body.max_tokens = undefined;