fix inception/deepseek openai-adapters and test
This commit is contained in:
parent
8b418165d9
commit
91ea2da585
4 changed files with 53 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.22",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@ import { OpenAIApi } from "./OpenAI.js";
|
|||
import { FimCreateParamsStreaming } from "./base.js";
|
||||
|
||||
export class DeepSeekApi extends OpenAIApi {
|
||||
apiBase: string = "https://api.deepseek.com/";
|
||||
static apiBase: string = "https://api.deepseek.com/";
|
||||
|
||||
constructor(config: DeepseekConfig) {
|
||||
super({
|
||||
...config,
|
||||
provider: "openai",
|
||||
apiBase: config.apiBase ?? DeepSeekApi.apiBase,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +20,7 @@ export class DeepSeekApi extends OpenAIApi {
|
|||
body: FimCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const endpoint = new URL("beta/completions", this.apiBase);
|
||||
const endpoint = new URL("beta/completions", DeepSeekApi.apiBase);
|
||||
const resp = await customFetch(this.config.requestOptions)(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@ import { OpenAIApi } from "./OpenAI.js";
|
|||
import { FimCreateParamsStreaming } from "./base.js";
|
||||
|
||||
export class InceptionApi extends OpenAIApi {
|
||||
apiBase: string = "https://api.inceptionlabs.ai/v1/";
|
||||
static apiBase: string = "https://api.inceptionlabs.ai/v1/";
|
||||
|
||||
constructor(config: InceptionConfig) {
|
||||
super({
|
||||
...config,
|
||||
provider: "openai",
|
||||
apiBase: config.apiBase ?? InceptionApi.apiBase,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +20,7 @@ export class InceptionApi extends OpenAIApi {
|
|||
body: FimCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const endpoint = new URL("completions", this.apiBase);
|
||||
const endpoint = new URL("completions", InceptionApi.apiBase);
|
||||
const resp = await customFetch(this.config.requestOptions)(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { ModelConfig } from "@continuedev/config-yaml";
|
||||
import * as dotenv from "dotenv";
|
||||
import { DeepSeekApi } from "../apis/DeepSeek.js";
|
||||
import { InceptionApi } 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();
|
||||
|
|
@ -108,3 +112,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(DeepSeekApi.apiBase);
|
||||
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(InceptionApi.apiBase);
|
||||
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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue