8
8
import { GenkitRunner } from '../../codegen/genkit/genkit-runner.js' ;
9
9
import defaultVisualRaterPrompt from './visual-rating-prompt.js' ;
10
10
import { Environment } from '../../configuration/environment.js' ;
11
+ import { screenshotUrlToPngBuffer } from '../../utils/screenshots.js' ;
11
12
12
13
/**
13
14
* Automatically rate the appearance of a screenshot using an LLM.
@@ -16,7 +17,7 @@ import { Environment } from '../../configuration/environment.js';
16
17
* @param model Model to use for the rating.
17
18
* @param environment Environment in which the rating is running.
18
19
* @param appPrompt Prompt to be used for the rating.
19
- * @param screenshotBase64 Screenshot to be rated.
20
+ * @param screenshotPngUrl Screenshot PNG URL to be rated.
20
21
* @param label Label for the rating, used for logging.
21
22
*/
22
23
export async function autoRateAppearance (
@@ -25,7 +26,7 @@ export async function autoRateAppearance(
25
26
model : string ,
26
27
environment : Environment ,
27
28
appPrompt : string ,
28
- screenshotBase64 : string ,
29
+ screenshotPngUrl : string ,
29
30
label : string
30
31
) : Promise < AutoRateResult > {
31
32
const prompt = environment . renderPrompt ( defaultVisualRaterPrompt , null , {
@@ -38,8 +39,10 @@ export async function autoRateAppearance(
38
39
content : [
39
40
{
40
41
media : {
41
- base64PngImage : screenshotBase64 ,
42
- url : `data:image/png;base64,${ screenshotBase64 } ` ,
42
+ base64PngImage : (
43
+ await screenshotUrlToPngBuffer ( screenshotPngUrl )
44
+ ) . toString ( 'base64' ) ,
45
+ url : screenshotPngUrl ,
43
46
} ,
44
47
} ,
45
48
] ,
0 commit comments