Skip to content

Commit

Permalink
tests: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jan 17, 2024
1 parent 9c8b90f commit 7d7d411
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 84 deletions.
75 changes: 0 additions & 75 deletions packages/backend/src/ai.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
}
],
"models": [
{
"id": "my-model",
"name": "My Model",
"description": "Llama 2 is a family of state-of-the-art open-access large language models released by Meta today, and we’re excited to fully support the launch with comprehensive integration in Hugging Face. Llama 2 is being released with a very permissive community license and is available for commercial use. The code, pretrained models, and fine-tuned models are all being released today 🔥",
"hw": "CPU",
"registry": "Hugging Face",
"popularity": 3,
"license": "?",
"url": "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf"
},
{
"id": "llama-2-7b-chat.Q5_K_S",
"name": "Llama-2-7B-Chat-GGUF",
Expand Down
19 changes: 10 additions & 9 deletions packages/backend/src/studio-api-impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { expect, test, vi } from 'vitest';
import content from './ai-test.json';
import content from './catalog-test.json';
import { ApplicationManager } from './managers/applicationManager';
import { RecipeStatusRegistry } from './registries/RecipeStatusRegistry';
import { StudioApiImpl } from './studio-api-impl';
import { PlayGroundManager } from './playground';
import { TaskRegistry } from './registries/TaskRegistry';

vi.mock('./ai.json', () => {
return {
default: content
};
import * as fs from 'node:fs';

vi.mock('node:fs');
vi.spyOn(fs, 'readFileSync').mockImplementation(() => {
return JSON.stringify(content);
});

const studioApiImpl = new StudioApiImpl(
Expand All @@ -40,9 +41,9 @@ const studioApiImpl = new StudioApiImpl(
)

test('expect correct model is returned with valid id', async () => {
const model = await studioApiImpl.getModelById('llama-2-7b-chat.Q5_K_S');
const model = await studioApiImpl.getModelById('my-model');
expect(model).toBeDefined();
expect(model.name).toEqual('Llama-2-7B-Chat-GGUF');
expect(model.name).toEqual('My Model');
expect(model.registry).toEqual('Hugging Face');
expect(model.url).toEqual('https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf')
});
Expand All @@ -54,10 +55,10 @@ test('expect error if id does not correspond to any model', async () => {
})

test('expect array of models based on list of ids', async () => {
const models = await studioApiImpl.getModelsByIds(['llama-2-7b-chat.Q5_K_S', 'albedobase-xl-1.3']);
const models = await studioApiImpl.getModelsByIds(['my-model', 'albedobase-xl-1.3']);
expect(models).toBeDefined();
expect(models.length).toBe(2);
expect(models[0].name).toEqual('Llama-2-7B-Chat-GGUF');
expect(models[0].name).toEqual('My Model');
expect(models[0].registry).toEqual('Hugging Face');
expect(models[0].url).toEqual('https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf');
expect(models[1].name).toEqual('AlbedoBase XL 1.3');
Expand Down

0 comments on commit 7d7d411

Please sign in to comment.