fix the rest of the tests
This commit is contained in:
parent
74c1b10c33
commit
71b93d49d7
3 changed files with 61 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ class NCompass extends OpenAI {
|
|||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "https://api.ncompass.tech/v1/",
|
||||
};
|
||||
static embeddingsApiEndpoint: "https://api.gcp.ncompass.tech/v1/embeddings";
|
||||
static embeddingsApiEndpoint = "https://api.gcp.ncompass.tech/v1/embeddings";
|
||||
|
||||
private static modelConversion: { [key: string]: string } = {
|
||||
"qwen2.5-coder-7b": "Qwen/Qwen2.5-Coder-7B-Instruct",
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ createOpenAISubclassTests(Together, {
|
|||
"mistral-8x7b": "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
||||
},
|
||||
modelConversionContent: "hello",
|
||||
customStreamCompleteEndpoint: "completions",
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(Deepseek, {
|
||||
|
|
@ -316,11 +317,28 @@ createOpenAISubclassTests(Cerebras, {
|
|||
createOpenAISubclassTests(DeepInfra, {
|
||||
providerName: "deepinfra",
|
||||
defaultApiBase: "https://api.deepinfra.com/v1/openai/",
|
||||
customEmbeddingsUrl: "https://api.deepinfra.com/v1/inference/text-embedding-ada-002",
|
||||
customEmbeddingsHeaders: {
|
||||
"Authorization": "bearer test-api-key",
|
||||
},
|
||||
customEmbeddingsBody: {
|
||||
inputs: ["Hello", "World"],
|
||||
},
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(Nvidia, {
|
||||
providerName: "nvidia",
|
||||
defaultApiBase: "https://integrate.api.nvidia.com/v1/",
|
||||
customEmbeddingsHeaders: {
|
||||
"Authorization": "Bearer test-api-key",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
customEmbeddingsBody: {
|
||||
input: ["Hello", "World"],
|
||||
model: "text-embedding-ada-002",
|
||||
input_type: "passage",
|
||||
truncate: "END",
|
||||
},
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(SambaNova, {
|
||||
|
|
@ -346,6 +364,7 @@ createOpenAISubclassTests(Moonshot, {
|
|||
createOpenAISubclassTests(Novita, {
|
||||
providerName: "novita",
|
||||
defaultApiBase: "https://api.novita.ai/v3/openai/",
|
||||
customStreamCompleteEndpoint: "completions",
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(SiliconFlow, {
|
||||
|
|
@ -366,6 +385,11 @@ createOpenAISubclassTests(Azure, {
|
|||
createOpenAISubclassTests(Inception, {
|
||||
providerName: "inception",
|
||||
defaultApiBase: "https://api.inception.ai/v1/",
|
||||
customBodyOptions: {
|
||||
temperature: 0.0,
|
||||
presence_penalty: 1.5,
|
||||
stop: ["<|endoftext|>"],
|
||||
},
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(Docker, {
|
||||
|
|
@ -391,11 +415,24 @@ createOpenAISubclassTests(TextGenWebUI, {
|
|||
createOpenAISubclassTests(FunctionNetwork, {
|
||||
providerName: "function-network",
|
||||
defaultApiBase: "https://api.function.network/v1/",
|
||||
customEmbeddingsHeaders: {
|
||||
"Authorization": "Bearer test-api-key",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(NCompass, {
|
||||
providerName: "ncompass",
|
||||
defaultApiBase: "https://api.ncompass.tech/v1",
|
||||
defaultApiBase: "https://api.ncompass.tech/v1/",
|
||||
customEmbeddingsUrl: "https://api.gcp.ncompass.tech/v1/embeddings",
|
||||
customEmbeddingsHeaders: {
|
||||
"Authorization": "Bearer test-api-key",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
customEmbeddingsBody: {
|
||||
input: ["Hello", "World"],
|
||||
model: "text-embedding-ada-002",
|
||||
},
|
||||
});
|
||||
|
||||
createOpenAISubclassTests(LlamaStack, {
|
||||
|
|
|
|||
|
|
@ -140,6 +140,17 @@ export interface OpenAISubclassConfig {
|
|||
customEmbeddingsUrl?: string;
|
||||
customEmbeddingsHeaders?: { [key: string]: string };
|
||||
customEmbeddingsBody?: any;
|
||||
customBodyOptions?: any;
|
||||
}
|
||||
|
||||
function getExpectedUrl(config: OpenAISubclassConfig, endpoint: string, model: string = "gpt-4") {
|
||||
let baseUrl = config.defaultApiBase;
|
||||
if (config.providerName === "azure") {
|
||||
return `${baseUrl}openai/deployments/${model}/${endpoint}?api-version=2023-07-01-preview`;
|
||||
} else if (config.providerName === "ncompass") {
|
||||
return `${baseUrl}${endpoint}`;
|
||||
}
|
||||
return `${baseUrl}${endpoint}`;
|
||||
}
|
||||
|
||||
export const createOpenAISubclassTests = (
|
||||
|
|
@ -174,7 +185,7 @@ export const createOpenAISubclassTests = (
|
|||
new AbortController().signal,
|
||||
],
|
||||
expectedRequest: {
|
||||
url: `${config.defaultApiBase}chat/completions`,
|
||||
url: getExpectedUrl(config, "chat/completions"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -186,6 +197,7 @@ export const createOpenAISubclassTests = (
|
|||
messages: [{ role: "user", content: "hello" }],
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
...config.customBodyOptions,
|
||||
},
|
||||
},
|
||||
mockStream: [
|
||||
|
|
@ -210,7 +222,7 @@ export const createOpenAISubclassTests = (
|
|||
new AbortController().signal,
|
||||
],
|
||||
expectedRequest: {
|
||||
url: `${config.defaultApiBase}chat/completions`,
|
||||
url: getExpectedUrl(config, "chat/completions"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -222,6 +234,7 @@ export const createOpenAISubclassTests = (
|
|||
messages: [{ role: "user", content: "hello" }],
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
...config.customBodyOptions,
|
||||
},
|
||||
},
|
||||
mockStream: [
|
||||
|
|
@ -243,7 +256,7 @@ export const createOpenAISubclassTests = (
|
|||
methodToTest: "streamComplete",
|
||||
params: ["Hello", new AbortController().signal],
|
||||
expectedRequest: {
|
||||
url: `${config.defaultApiBase}${config.customStreamCompleteEndpoint || "chat/completions"}`,
|
||||
url: getExpectedUrl(config, config.customStreamCompleteEndpoint || "chat/completions"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -255,11 +268,13 @@ export const createOpenAISubclassTests = (
|
|||
prompt: "Hello",
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
...config.customBodyOptions,
|
||||
} : {
|
||||
model: "gpt-4",
|
||||
messages: [{ role: "user", content: "Hello" }],
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
...config.customBodyOptions,
|
||||
},
|
||||
},
|
||||
mockStream: [
|
||||
|
|
@ -281,7 +296,7 @@ export const createOpenAISubclassTests = (
|
|||
methodToTest: "complete",
|
||||
params: ["Hello", new AbortController().signal],
|
||||
expectedRequest: {
|
||||
url: `${config.defaultApiBase}chat/completions`,
|
||||
url: getExpectedUrl(config, "chat/completions"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -293,6 +308,7 @@ export const createOpenAISubclassTests = (
|
|||
messages: [{ role: "user", content: "Hello" }],
|
||||
stream: true,
|
||||
max_tokens: 2048,
|
||||
...config.customBodyOptions,
|
||||
},
|
||||
},
|
||||
mockStream: [
|
||||
|
|
@ -322,7 +338,7 @@ export const createOpenAISubclassTests = (
|
|||
new AbortController().signal,
|
||||
],
|
||||
expectedRequest: {
|
||||
url: `${config.defaultApiBase}chat/completions`,
|
||||
url: getExpectedUrl(config, "chat/completions", testModel),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -334,6 +350,7 @@ export const createOpenAISubclassTests = (
|
|||
messages: [{ role: "user", content: config.modelConversionContent || "[INST] hello [/INST]" }],
|
||||
stream: true,
|
||||
max_tokens: config.modelConversionMaxTokens || 4096,
|
||||
...config.customBodyOptions,
|
||||
},
|
||||
},
|
||||
mockStream: [{ choices: [{ delta: { content: "Hello" } }] }],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue