Skip to content

Commit 934549b

Browse files
committed
feat(chore): fix tests
1 parent cbc0718 commit 934549b

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/__tests__/db-query/acceptance/dataset.controller.acceptance.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {DataSet} from '../../../components/db-query/models';
66
import {DataSetRepository} from '../../../components/db-query/repositories';
77
import {AiIntegrationBindings} from '../../../keys';
88
import {PermissionKey} from '../../../permissions';
9-
import {EmbeddingProvider, LLMProvider} from '../../../types';
9+
import {EmbeddingProvider} from '../../../types';
1010
import {TestApp} from '../../fixtures/test-app';
1111
import {buildToken, seedEmployees, setupApplication} from '../../test-helper';
1212

@@ -19,22 +19,14 @@ describe('DatasetController', () => {
1919
before('setupApplication', async () => {
2020
({app, client} = await setupApplication({
2121
noKnowledgeGraph: true,
22+
llmStub: sinon.stub(),
2223
}));
2324
llmStub = sinon.stub();
2425
llmStub.resolves([[0.1, 0.2, 0.3]]);
2526

2627
app.bind(AiIntegrationBindings.EmbeddingModel).to({
2728
embedDocuments: llmStub,
2829
} as unknown as EmbeddingProvider);
29-
app
30-
.bind(AiIntegrationBindings.SmartLLM)
31-
.to(llmStub as unknown as LLMProvider);
32-
app
33-
.bind(AiIntegrationBindings.CheapLLM)
34-
.to(llmStub as unknown as LLMProvider);
35-
app
36-
.bind(AiIntegrationBindings.FileLLM)
37-
.to(llmStub as unknown as LLMProvider);
3830
await seedEmployees(app);
3931
await seedDataset(app);
4032
});

src/__tests__/fixtures/test-app.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,22 @@ export class TestApp extends BootMixin(
4444
this.bind(AiIntegrationBindings.CheapLLM).toProvider(Ollama);
4545
this.bind(AiIntegrationBindings.SmartLLM).toProvider(Ollama);
4646
this.bind(AiIntegrationBindings.FileLLM).toProvider(Ollama);
47-
} else {
47+
this.bind(AiIntegrationBindings.EmbeddingModel).toProvider(
48+
OllamaEmbedding,
49+
);
50+
} else if (process.env.CEREBRAS === '1') {
4851
this.bind(AiIntegrationBindings.CheapLLM).toProvider(Cerebras);
4952
this.bind(AiIntegrationBindings.SmartLLM).toProvider(Cerebras);
5053
this.bind(AiIntegrationBindings.FileLLM).toProvider(Cerebras);
54+
this.bind(AiIntegrationBindings.EmbeddingModel).toProvider(
55+
OllamaEmbedding,
56+
);
57+
} else if (options.llmStub) {
58+
this.bind(AiIntegrationBindings.CheapLLM).to(options.llmStub);
59+
this.bind(AiIntegrationBindings.SmartLLM).to(options.llmStub);
60+
this.bind(AiIntegrationBindings.FileLLM).to(options.llmStub);
61+
this.bind(AiIntegrationBindings.EmbeddingModel).to(options.llmStub);
5162
}
52-
this.bind(AiIntegrationBindings.EmbeddingModel).toProvider(OllamaEmbedding);
5363
this.bind('datasources.db').to(
5464
new juggler.DataSource({
5565
connector: 'sqlite3',

src/__tests__/test-helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ config();
2727

2828
export async function setupApplication(options: {
2929
noKnowledgeGraph?: boolean;
30+
llmStub?: sinon.SinonStub;
3031
}): Promise<AppWithClient> {
3132
const restConfig = givenHttpServerConfig({
3233
// Customize the server configuration here.

0 commit comments

Comments
 (0)