feat: add model caching and benchmarking utilities (#671)
* 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
This commit is contained in:
committed by
GitHub
parent
6a62e3ff76
commit
2b15e16421
30
src/utils/model/modelCache.test.ts
Normal file
30
src/utils/model/modelCache.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user