fix: cherry-pick improvements from feature/semantic_caching
- semantic-cache.ts: use upsert instead of add to avoid duplicate-ID errors - semantic-cache.ts: add crypto.randomUUID() fallback for constrained runtimes - ollama-client.ts: JSON.stringify non-string Ollama errors to avoid [object Object] - tests: update semantic-cache mocks and assertions for upsert
This commit is contained in:
@@ -10,6 +10,7 @@ jest.mock('chromadb', () => ({
|
||||
getOrCreateCollection: jest.fn().mockResolvedValue({
|
||||
query: jest.fn(),
|
||||
add: jest.fn(),
|
||||
upsert: jest.fn(),
|
||||
reset: jest.fn(),
|
||||
}),
|
||||
deleteCollection: jest.fn(),
|
||||
@@ -135,13 +136,13 @@ describe('SemanticCacheService', () => {
|
||||
|
||||
await disabledCacheService.setCache('test query', 'test response');
|
||||
|
||||
expect(mockCollection.add).not.toHaveBeenCalled();
|
||||
expect(mockCollection.upsert).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should add content to cache', async () => {
|
||||
await cacheService.setCache('test query', 'test response');
|
||||
|
||||
expect(mockCollection.add).toHaveBeenCalled();
|
||||
expect(mockCollection.upsert).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user