tests for LLM classes
This commit is contained in:
parent
c959617f57
commit
82bbbc5918
2 changed files with 75 additions and 66 deletions
23
.github/workflows/pr_checks.yaml
vendored
23
.github/workflows/pr_checks.yaml
vendored
|
|
@ -96,7 +96,7 @@ jobs:
|
|||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
|
||||
install-gui:
|
||||
needs: [ install-root, install-core ]
|
||||
needs: [install-root, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -157,7 +157,7 @@ jobs:
|
|||
npx tsc --noEmit
|
||||
|
||||
binary-checks:
|
||||
needs: [ install-root, install-core ]
|
||||
needs: [install-root, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -193,7 +193,7 @@ jobs:
|
|||
npx tsc --noEmit
|
||||
|
||||
install-vscode:
|
||||
needs: [ install-root, install-core ]
|
||||
needs: [install-root, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -274,10 +274,15 @@ jobs:
|
|||
run: |
|
||||
cd core
|
||||
npm test
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
|
||||
|
||||
vscode-get-test-file-matrix:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ install-root, install-vscode ]
|
||||
needs: [install-root, install-vscode]
|
||||
outputs:
|
||||
test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}
|
||||
steps:
|
||||
|
|
@ -306,7 +311,7 @@ jobs:
|
|||
|
||||
vscode-package-extension:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ install-vscode, install-core ]
|
||||
needs: [install-vscode, install-core]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
|
@ -338,7 +343,7 @@ jobs:
|
|||
|
||||
vscode-download-e2e-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ install-vscode, install-core ]
|
||||
needs: [install-vscode, install-core]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
|
@ -445,7 +450,7 @@ jobs:
|
|||
path: extensions/vscode/e2e/storage/screenshots
|
||||
|
||||
gui-tests:
|
||||
needs: [ install-gui, install-core ]
|
||||
needs: [install-gui, install-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -476,7 +481,7 @@ jobs:
|
|||
npm test
|
||||
|
||||
jetbrains-tests:
|
||||
needs: [ install-root, core-checks ]
|
||||
needs: [install-root, core-checks]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -573,5 +578,3 @@ jobs:
|
|||
name: jb-failure-report
|
||||
path: |
|
||||
${{ github.workspace }}/extensions/intellij/build/reports
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
import * as dotenv from "dotenv";
|
||||
|
||||
import { CompletionOptions } from "..";
|
||||
import { BaseLLM } from ".";
|
||||
|
||||
import OpenAI from "./llms/OpenAI";
|
||||
|
||||
import { BaseLLM } from ".";
|
||||
import Anthropic from "./llms/Anthropic";
|
||||
import Gemini from "./llms/Gemini";
|
||||
import Mistral from "./llms/Mistral";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
|
||||
temperature: 0.5,
|
||||
// temperature: 0.5,
|
||||
topP: 1,
|
||||
topK: 40,
|
||||
presencePenalty: 0,
|
||||
|
|
@ -16,12 +21,19 @@ const COMPLETION_OPTIONS: Partial<CompletionOptions> = {
|
|||
// maxTokens: 5,
|
||||
};
|
||||
|
||||
function testLLM(llm: BaseLLM) {
|
||||
function testLLM(
|
||||
llm: BaseLLM,
|
||||
{ skip, testFim }: { skip?: boolean; testFim?: boolean },
|
||||
) {
|
||||
if (skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
llm.completionOptions = { ...llm.completionOptions, ...COMPLETION_OPTIONS };
|
||||
});
|
||||
|
||||
describe(llm.providerName, () => {
|
||||
describe(llm.providerName + "/" + llm.model, () => {
|
||||
test("Stream Chat works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamChat(
|
||||
|
|
@ -54,62 +66,56 @@ function testLLM(llm: BaseLLM) {
|
|||
expect(completion.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
|
||||
if (testFim) {
|
||||
test("FIM works", async () => {
|
||||
let total = "";
|
||||
for await (const chunk of llm.streamFim(
|
||||
"Hi",
|
||||
"name is ChatGPT.",
|
||||
new AbortController().signal,
|
||||
)) {
|
||||
total += chunk;
|
||||
}
|
||||
|
||||
expect(total.length).toBeGreaterThan(0);
|
||||
return;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe.skip("LLM", () => {
|
||||
// testLLM(
|
||||
// new FreeTrial({
|
||||
// model: "gpt-3.5-turbo",
|
||||
// }),
|
||||
// );
|
||||
// testLLM(
|
||||
// new Anthropic({
|
||||
// model: "claude-2",
|
||||
// apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
// }),
|
||||
// );
|
||||
describe("LLM", () => {
|
||||
testLLM(
|
||||
new Anthropic({
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
}),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "gpt-3.5-turbo" }),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(
|
||||
new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1-preview" }),
|
||||
{ skip: false },
|
||||
);
|
||||
// testLLM(new OpenAI({ apiKey: process.env.OPENAI_API_KEY, model: "o1" }), {
|
||||
// skip: false,
|
||||
// });
|
||||
testLLM(
|
||||
new Gemini({
|
||||
model: "gemini-2.0-flash-exp",
|
||||
apiKey: process.env.GEMINI_API_KEY,
|
||||
}),
|
||||
{ skip: false },
|
||||
);
|
||||
testLLM(
|
||||
new Mistral({
|
||||
apiKey: process.env.MISTRAL_API_KEY,
|
||||
model: "codestral-latest",
|
||||
}),
|
||||
{ testFim: true, skip: false },
|
||||
);
|
||||
// TODO: Fix Replicate
|
||||
// testLLM(
|
||||
// new Replicate({
|
||||
// apiKey: process.env.REPLICATE_API_KEY,
|
||||
// model: "codellama-7b",
|
||||
// })
|
||||
// );
|
||||
// testLLM(new LMStudio({ model: "codellama-7b" }));
|
||||
// testLLM(new Ollama({ model: "codellama-7b" }));
|
||||
// testLLM(
|
||||
// new Together({
|
||||
// apiKey: process.env.TOGETHER_API_KEY,
|
||||
// model: "codellama-7b",
|
||||
// })
|
||||
// );
|
||||
// testLLM(new LlamaCpp({ model: "deepseek-7b" }));
|
||||
// testLLM(new Llamafile({ model: "mistral-7b" }));
|
||||
// TODO: Test these
|
||||
// testLLM(new TextGenWebUI({ model: "codellama-7b" }));
|
||||
// testLLM(new HuggingFaceTGI({ model: "codellama-7b" }));
|
||||
// testLLM(new HuggingFaceInferenceAPI({ model: "codellama-7b" }));
|
||||
// testLLM(
|
||||
// new Gemini({
|
||||
// model: "gemini-pro",
|
||||
// // model: "chat-bison-001",
|
||||
// apiKey: process.env.GOOGLE_PALM_API_KEY,
|
||||
// })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Gemini({ model: "gemini-pro", apiKey: process.env.GOOGLE_PALM_API_KEY })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Mistral({ apiKey: process.env.MISTRAL_API_KEY, model: "mistral-small" })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Flowise({ apiKey: process.env.FLOWISE_API_KEY, model: "gpt-3.5-turbo" })
|
||||
// );
|
||||
// testLLM(
|
||||
// new Nebius({ apiKey: process.env.NEBIUS_API_KEY, model: "llama3.1-8b" })
|
||||
// );
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue