* feat: add model caching and benchmarking utilities - Add modelCache.ts for disk caching of model lists - Add benchmark.ts for testing model speed/quality * fix: address review feedback - async fs, multi-provider support, error handling * feat: add /benchmark slash command and unit tests * feat: add /benchmark slash command and unit tests
30 lines
952 B
TypeScript
30 lines
952 B
TypeScript
import { describe, expect, it, beforeEach, afterEach, vi } from 'bun:test'
|
|
import { isModelCacheValid, getCachedModelsFromDisk, saveModelsToCache } from '../model/modelCache.js'
|
|
|
|
vi.mock('../model/ollamaModels.js', () => ({
|
|
isOllamaProvider: vi.fn(() => true),
|
|
}))
|
|
|
|
describe('modelCache', () => {
|
|
const mockModel = { value: 'llama3', label: 'Llama 3', description: 'Test model' }
|
|
|
|
describe('isModelCacheValid', () => {
|
|
it('returns false for non-existent cache', async () => {
|
|
const result = await isModelCacheValid('ollama')
|
|
expect(result).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('getCachedModelsFromDisk', () => {
|
|
it('returns null when not cache available', async () => {
|
|
const result = await getCachedModelsFromDisk()
|
|
expect(result).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('saveModelsToCache', () => {
|
|
it('has saveModelsToCache function', () => {
|
|
expect(typeof saveModelsToCache).toBe('function')
|
|
})
|
|
})
|
|
}) |