don't use static property
This commit is contained in:
parent
d13583ab3a
commit
b9f901bf7b
4 changed files with 11 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.22",
|
||||
"version": "1.0.23",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -5,14 +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 {
|
||||
static apiBase: string = "https://api.deepseek.com/";
|
||||
|
||||
constructor(config: DeepseekConfig) {
|
||||
super({
|
||||
...config,
|
||||
provider: "openai",
|
||||
apiBase: config.apiBase ?? DeepSeekApi.apiBase,
|
||||
apiBase: config.apiBase ?? DEEPSEEK_API_BASE,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +19,7 @@ export class DeepSeekApi extends OpenAIApi {
|
|||
body: FimCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const endpoint = new URL("beta/completions", DeepSeekApi.apiBase);
|
||||
const endpoint = new URL("beta/completions", this.config.apiBase);
|
||||
const resp = await customFetch(this.config.requestOptions)(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
|
|||
|
|
@ -5,14 +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 {
|
||||
static apiBase: string = "https://api.inceptionlabs.ai/v1/";
|
||||
|
||||
constructor(config: InceptionConfig) {
|
||||
super({
|
||||
...config,
|
||||
provider: "openai",
|
||||
apiBase: config.apiBase ?? InceptionApi.apiBase,
|
||||
apiBase: config.apiBase ?? INCEPTION_API_BASE,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +19,7 @@ export class InceptionApi extends OpenAIApi {
|
|||
body: FimCreateParamsStreaming,
|
||||
signal: AbortSignal,
|
||||
): AsyncGenerator<ChatCompletionChunk, any, unknown> {
|
||||
const endpoint = new URL("completions", InceptionApi.apiBase);
|
||||
const endpoint = new URL("completions", this.config.apiBase);
|
||||
const resp = await customFetch(this.config.requestOptions)(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ModelConfig } from "@continuedev/config-yaml";
|
||||
import * as dotenv from "dotenv";
|
||||
import { DeepSeekApi } from "../apis/DeepSeek.js";
|
||||
import { InceptionApi } from "../apis/Inception.js";
|
||||
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";
|
||||
|
|
@ -120,7 +120,7 @@ describe("Configuration", () => {
|
|||
apiKey: "sk-xxx",
|
||||
});
|
||||
|
||||
expect((deepseek as OpenAIApi).openai.baseURL).toBe(DeepSeekApi.apiBase);
|
||||
expect((deepseek as OpenAIApi).openai.baseURL).toBe(DEEPSEEK_API_BASE);
|
||||
expect((deepseek as OpenAIApi).openai.apiKey).toBe("sk-xxx");
|
||||
|
||||
const deepseek2 = constructLlmApi({
|
||||
|
|
@ -139,7 +139,7 @@ describe("Configuration", () => {
|
|||
apiKey: "sk-xxx",
|
||||
});
|
||||
|
||||
expect((inception as OpenAIApi).openai.baseURL).toBe(InceptionApi.apiBase);
|
||||
expect((inception as OpenAIApi).openai.baseURL).toBe(INCEPTION_API_BASE);
|
||||
expect((inception as OpenAIApi).openai.apiKey).toBe("sk-xxx");
|
||||
|
||||
const inception2 = constructLlmApi({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue