From e760f7ab753403e9d856dc45666b0fb4bac48fc5 Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Mon, 16 Jun 2025 16:13:13 -0700 Subject: [PATCH] revert main.ts --- .../openai-adapters/src/test/main.test.ts | 148 +++++++++++++++--- 1 file changed, 123 insertions(+), 25 deletions(-) diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index eec06cb27..9b3885b14 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -1,8 +1,10 @@ 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, testEmbed, testFim } from "./util.js"; +import { getLlmApi, testChat, testEmbed } from "./util.js"; dotenv.config(); @@ -31,30 +33,99 @@ function testConfig(_config: ModelConfig & { options?: TestConfigOptions }) { if (config.roles?.includes("embed")) { testEmbed(api, model); } - if (config.roles?.includes("autocomplete")) { - testFim(api, model); + + if (config.roles?.includes("embed")) { + testEmbed(api, model); } - } + const TESTS: Omit[] = [ - { - provider: "llamastack", - model: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", - apiBase: "http://localhost:8321/v1/openai/v1/", - roles: ["apply", "chat", "edit"], - options: { skipTools: false }, + { + provider: "openai", + model: "gpt-4o", + apiKey: process.env.OPENAI_API_KEY!, + roles: ["chat"], }, { - provider: "llamastack", - model: "all-MiniLM-L6-v2", - apiBase: "http://localhost:8321/v1/openai/v1/", + provider: "anthropic", + model: "claude-3-5-haiku-latest", + apiKey: process.env.ANTHROPIC_API_KEY!, + roles: ["chat"], + }, + { + provider: "gemini", + model: "gemini-1.5-flash-latest", + apiKey: process.env.GEMINI_API_KEY!, + roles: ["chat"], + }, + { + provider: "mistral", + model: "codestral-latest", + apiKey: process.env.MISTRAL_API_KEY!, + apiBase: "https://api.mistral.ai/v1", + roles: ["autocomplete"], + }, + { + provider: "deepseek", + model: "deepseek-coder", + apiKey: process.env.DEEPSEEK_API_KEY!, + roles: ["autocomplete"], + }, + { + provider: "openai", + model: "text-embedding-3-small", + apiKey: process.env.OPENAI_API_KEY!, roles: ["embed"], }, - { - provider: "llamastack", - model: "qwen2.5-coder:1.5b", - apiBase: "http://localhost:8321/v1/openai/v1/", - roles: ["autocomplete"], + { + provider: "voyage", + model: "voyage-code-3", + apiKey: process.env.VOYAGE_API_KEY!, + roles: ["embed"], + }, + // { + // provider: "cohere", + // model: "embed-v4.0", + // apiKey: process.env.COHERE_API_KEY!, + // roles: ["embed"], + // }, + // { + // provider: "gemini", + // model: "models/text-embedding-004", + // apiKey: process.env.GEMINI_API_KEY!, + // roles: ["embed"], + // }, + { + provider: "voyage", + model: "rerank-lite-1", + apiKey: process.env.VOYAGE_API_KEY!, + roles: ["rerank"], + }, + // { + // provider: "cohere", + // model: "rerank-v3.5", + // apiKey: process.env.COHERE_API_KEY!, + // roles: ["rerank"], + // }, + { + provider: "azure", + model: "gpt-4.1", + apiBase: "https://continue-openai.openai.azure.com", + apiKey: process.env.AZURE_OPENAI_GPT41_API_KEY, + env: { + deployment: "gpt-4.1", + apiVersion: "2024-02-15-preview", + apiType: "azure-openai", + }, + roles: ["chat"], + }, + { + provider: "azure", + model: "mistral-small-2503", + apiBase: "https://nate-0276-resource.services.ai.azure.com/models", + apiKey: process.env.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY, + roles: ["chat"], + options: { skipTools: true }, }, ]; @@ -65,14 +136,41 @@ TESTS.forEach((config) => { }); describe("Configuration", () => { - it("should configure OpenAI client with correct apiBase and apiKey", () => { - const openai = constructLlmApi({ - provider: "openai", + it("should configure DeepSeek OpenAI client with correct apiBase and apiKey", () => { + const deepseek = constructLlmApi({ + provider: "deepseek", apiKey: "sk-xxx", - apiBase: "http://localhost:8321/v1/openai/v1/", }); - expect((openai as OpenAIApi).openai.baseURL).toBe("http://localhost:8321/v1/openai/v1/"); - expect((openai as OpenAIApi).openai.apiKey).toBe("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", + ); + }); +}); \ No newline at end of file