Skip to content

Commit dcb30e1

Browse files
committed
fix
1 parent b55af84 commit dcb30e1

8 files changed

Lines changed: 24 additions & 22 deletions

File tree

src/compare/compare.module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ import { StaticModule } from '../static/static.module';
1111

1212
@Module({
1313
controllers: [OllamaController],
14-
providers: [CompareService, PixelmatchService, LookSameService, OdiffService, VlmService, OllamaService, GeminiService],
14+
providers: [
15+
CompareService,
16+
PixelmatchService,
17+
LookSameService,
18+
OdiffService,
19+
VlmService,
20+
OllamaService,
21+
GeminiService,
22+
],
1523
imports: [StaticModule],
1624
exports: [CompareService],
1725
})

src/compare/libs/vlm/providers/gemini/gemini.service.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('GeminiService', () => {
8282

8383
const callArgs = mockGenerateContent.mock.calls[0][0];
8484
expect(callArgs.contents.length).toBe(expectedPartsCount);
85-
85+
8686
// Verify first image is base64 encoded
8787
if (images.length > 0) {
8888
const imagePart = callArgs.contents[1];
@@ -116,13 +116,12 @@ describe('GeminiService', () => {
116116
['SDK call fails', { apiKey: 'test-api-key' }, 'API Error'],
117117
])('should throw error when %s', async (_, overrides, expectedError) => {
118118
const config = createConfig(overrides);
119-
119+
120120
if (expectedError === 'API Error') {
121121
mockGenerateContent.mockRejectedValue(new Error(expectedError));
122122
}
123-
123+
124124
await expect(service.generate(config, [])).rejects.toThrow(expectedError);
125125
});
126126
});
127127
});
128-

src/compare/libs/vlm/providers/gemini/gemini.service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ export class GeminiService implements VlmProvider {
3939
},
4040
}));
4141

42-
const parts = [
43-
{ text: geminiConfig.prompt },
44-
...imageParts,
45-
];
42+
const parts = [{ text: geminiConfig.prompt }, ...imageParts];
4643

4744
const result = await genAI.models.generateContent({
4845
model: geminiConfig.model,

src/compare/libs/vlm/providers/ollama/ollama.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ export class OllamaController {
6161
return this.ollamaService.generate(config, images);
6262
}
6363
}
64-

src/compare/libs/vlm/providers/ollama/ollama.service.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ describe('OllamaService', () => {
122122
});
123123
});
124124

125-
126125
describe('listModels', () => {
127126
it('should return list of models', async () => {
128127
const mockDate = new Date('2024-01-01');
@@ -179,4 +178,3 @@ describe('OllamaService', () => {
179178
});
180179
});
181180
});
182-

src/compare/libs/vlm/vlm-provider.interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ export interface VlmProviderResponse {
2727
*/
2828
thinking?: string;
2929
}
30-

src/compare/libs/vlm/vlm.service.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,11 @@ const createImageMocks = () => {
5555
return {
5656
image,
5757
diffImage,
58-
getImageMock: jest
59-
.fn()
60-
.mockReturnValueOnce(image)
61-
.mockReturnValueOnce(image)
62-
.mockReturnValueOnce(diffImage),
58+
getImageMock: jest.fn().mockReturnValueOnce(image).mockReturnValueOnce(image).mockReturnValueOnce(diffImage),
6359
};
6460
};
6561

6662
describe('VlmService', () => {
67-
6863
it('should return NO_BASELINE_RESULT when pixelmatch returns no baseline', async () => {
6964
const pixelmatchGetDiffMock = jest.fn().mockResolvedValue(NO_BASELINE_RESULT);
7065
const service = await initService({ pixelmatchGetDiffMock });
@@ -109,7 +104,10 @@ describe('VlmService', () => {
109104
],
110105
[
111106
'keep unresolved when VLM confirms noticeable',
112-
{ identical: false, description: 'Button text changed from Submit to Send, and user count changed from 12 to 15.' },
107+
{
108+
identical: false,
109+
description: 'Button text changed from Submit to Send, and user count changed from 12 to 15.',
110+
},
113111
TestStatus.unresolved,
114112
{ pixelMisMatchCount: 500, diffPercent: 12.5 },
115113
],
@@ -138,7 +136,11 @@ describe('VlmService', () => {
138136
});
139137

140138
it.each([
141-
['invalid JSON response', { content: 'Invalid JSON response from model' }, { pixelMisMatchCount: 200, diffPercent: 5 }],
139+
[
140+
'invalid JSON response',
141+
{ content: 'Invalid JSON response from model' },
142+
{ pixelMisMatchCount: 200, diffPercent: 5 },
143+
],
142144
['API error', null, { pixelMisMatchCount: 300, diffPercent: 7.5 }],
143145
])('should handle %s gracefully and return pixelmatch result', async (_, vlmResponse, pixelmatchOverrides) => {
144146
const pixelmatchResult = createPixelmatchResult(pixelmatchOverrides);

src/compare/libs/vlm/vlm.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { OllamaService } from './providers/ollama/ollama.service';
1111
import { GeminiService } from './providers/gemini/gemini.service';
1212
import { PixelmatchService, DEFAULT_CONFIG as PIXELMATCH_DEFAULT_CONFIG } from '../pixelmatch/pixelmatch.service';
1313
import { PNG } from 'pngjs';
14-
import z from 'zod/v3';
14+
import z from 'zod/v3';
1515

1616
export const DEFAULT_PROMPT = `You are provided with three images:
1717
1. First image: baseline screenshot

0 commit comments

Comments
 (0)