Merge pull request #5612 from continuedev/nate/fix-openai-adapters

Nate/fix-openai-adapters
This commit is contained in:
Tomasz Stefaniak 2025-06-02 13:34:07 -07:00 • committed by GitHub
commit 2655ca8f84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 2 deletions

View file

@ -5,12 +5,13 @@ import { chatChunk, customFetch } from "../util.js";
import { OpenAIApi } from "./OpenAI.js";
import { FimCreateParamsStreaming } from "./base.js";
export const DEEPSEEK_API_BASE = "https://api.deepseek.com/";
export class DeepSeekApi extends OpenAIApi {
apiBase: string = "https://api.deepseek.com/";
constructor(config: DeepseekConfig) {
super({
...config,
provider: "openai",
apiBase: config.apiBase ?? DEEPSEEK_API_BASE,
});
}

View file

@ -5,12 +5,13 @@ import { chatChunk, customFetch } from "../util.js";
import { OpenAIApi } from "./OpenAI.js";
import { FimCreateParamsStreaming } from "./base.js";
export const INCEPTION_API_BASE = "https://api.inceptionlabs.ai/v1/";
export class InceptionApi extends OpenAIApi {
apiBase: string = "https://api.inceptionlabs.ai/v1/";
constructor(config: InceptionConfig) {
super({
...config,
provider: "openai",
apiBase: config.apiBase ?? INCEPTION_API_BASE,
});
}

View file

@ -1,5 +1,9 @@
import { ModelConfig } from "@continuedev/config-yaml";
import * as dotenv from "dotenv";
import { DEEPSEEK_API_BASE } from "../apis/DeepSeek.js";
import { INCEPTION_API_BASE } from "../apis/Inception.js";
import { OpenAIApi } from "../apis/OpenAI.js";
import { constructLlmApi } from "../index.js";
import { getLlmApi, testChat, testCompletion, testEmbed } from "./util.js";
dotenv.config();
@ -109,3 +113,43 @@ TESTS.forEach((config) => {
testConfig({ name: config.model, ...config });
});
});
describe("Configuration", () => {
it("should configure DeepSeek OpenAI client with correct apiBase and apiKey", () => {
const deepseek = constructLlmApi({
provider: "deepseek",
apiKey: "sk-xxx",
});
expect((deepseek as OpenAIApi).openai.baseURL).toBe(DEEPSEEK_API_BASE);
expect((deepseek as OpenAIApi).openai.apiKey).toBe("sk-xxx");
const deepseek2 = constructLlmApi({
provider: "deepseek",
apiKey: "sk-xxx",
apiBase: "https://api.example.com",
});
expect((deepseek2 as OpenAIApi).openai.baseURL).toBe(
"https://api.example.com",
);
});
it("should configure Inception OpenAI client with correct apiBase and apiKey", () => {
const inception = constructLlmApi({
provider: "inception",
apiKey: "sk-xxx",
});
expect((inception as OpenAIApi).openai.baseURL).toBe(INCEPTION_API_BASE);
expect((inception as OpenAIApi).openai.apiKey).toBe("sk-xxx");
const inception2 = constructLlmApi({
provider: "inception",
apiKey: "sk-xxx",
apiBase: "https://api.example.com",
});
expect((inception2 as OpenAIApi).openai.baseURL).toBe(
"https://api.example.com",
);
});
});