Skip to content

Commit

Permalink
Add new options to test script, enable togetherai testing and small c…
Browse files Browse the repository at this point in the history
…hanges for clarity.
  • Loading branch information
LeonRuggiero committed Oct 30, 2024
1 parent c690844 commit 91af894
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions drivers/test/all-models.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AIModel, AbstractDriver } from '@llumiverse/core';
import { AIModel, AbstractDriver, ExecutionOptions } from '@llumiverse/core';
import 'dotenv/config';
import { GoogleAuth } from 'google-auth-library';
import { describe, expect, test } from "vitest";
Expand Down Expand Up @@ -60,8 +60,8 @@ if (process.env.TOGETHER_API_KEY) {
apiKey: process.env.TOGETHER_API_KEY as string
}),
models: [
//"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
//"mistralai/Mixtral-8x7B-Instruct-v0.1" too slow in tests for now
"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
//"mistralai/Mixtral-8x7B-Instruct-v0.1" //too slow in tests for now
]
}
)
Expand Down Expand Up @@ -165,11 +165,23 @@ if (process.env.WATSONX_API_KEY) {

describe.concurrent.each(drivers)("Driver $name", ({ name, driver, models }) => {

let fetchedModels: AIModel[]
let fetchedModels: AIModel[];

let test_options: ExecutionOptions = {
model: "",
max_tokens: 64,
temperature: 0.5,
top_k: 40,
top_p: 1.0,
top_logprobs: 5, //Currently not supported, option will be ignored
presence_penalty: 0.0,
frequency_penalty: 0.0,
};

test(`${name}: list models`, { timeout: TIMEOUT, retry: 1 }, async () => {
const r = await driver.listModels();
fetchedModels = r;
console.log(r)
expect(r.length).toBeGreaterThan(0);
});

Expand All @@ -191,27 +203,27 @@ describe.concurrent.each(drivers)("Driver $name", ({ name, driver, models }) =>
});

test.each(models)(`${name}: execute prompt on %s`, { timeout: TIMEOUT, retry: 3 }, async (model) => {
const r = await driver.execute(testPrompt_color, { model, temperature: 0.5, max_tokens: 1024 });
console.debug("Result for " + model, JSON.stringify(r));
const r = await driver.execute(testPrompt_color, {...test_options, model: model} as ExecutionOptions);
console.log("Result for execute " + model, JSON.stringify(r));
assertCompletionOk(r);
});

test.each(models)(`${name}: execute prompt with streaming on %s`, { timeout: TIMEOUT, retry: 3 }, async (model) => {
const r = await driver.stream(testPrompt_color, { model, temperature: 0.5, max_tokens: 1024 })
const r = await driver.stream(testPrompt_color, {...test_options, model: model} as ExecutionOptions);
const out = await assertStreamingCompletionOk(r);
console.log("Result for " + model, JSON.stringify(out));
console.log("Result for streaming " + model, JSON.stringify(out));
});

test.each(models)(`${name}: execute prompt with schema on %s`, { timeout: TIMEOUT, retry: 3 }, async (model) => {
const r = await driver.execute(testPrompt_color, { model, temperature: 0.5, max_tokens: 1024, result_schema: testSchema_color });
console.log("Result for " + model, JSON.stringify(r.result));
const r = await driver.execute(testPrompt_color, {...test_options, model: model, result_schema: testSchema_color } as ExecutionOptions);
console.log("Result for execute with schema " + model, JSON.stringify(r.result));
assertCompletionOk(r);
});

test.each(models)(`${name}: execute prompt with streaming and schema on %s`, { timeout: TIMEOUT, retry: 3 }, async (model) => {
const r = await driver.stream(testPrompt_color, { model, temperature: 0.5, max_tokens: 1024, result_schema: testSchema_color })
const r = await driver.stream(testPrompt_color, {...test_options, model: model, result_schema: testSchema_color } as ExecutionOptions);
const out = await assertStreamingCompletionOk(r, true);
console.log("Result for prompt with streaming and schema" + model, JSON.stringify(out));
console.log("Result for streaming with schema " + model, JSON.stringify(out));
});


Expand All @@ -235,6 +247,4 @@ describe.concurrent.each(drivers)("Driver $name", ({ name, driver, models }) =>
console.log("Result", r)
assertCompletionOk(r);
});


});

0 comments on commit 91af894

Please sign in to comment.