Skip to content

Commit 3f5cda9

Browse files
author
SentienceDEV
committed
add ml_rerank metadata to snapshot response
1 parent 2c5d236 commit 3f5cda9

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@ export interface GridInfo {
143143
viewport_coverage?: number;
144144
}
145145

146+
export interface MlRerankTags {
147+
repeated: boolean;
148+
sponsored_ish: boolean;
149+
non_sponsored: boolean;
150+
pos: boolean;
151+
occ: boolean;
152+
vocc: boolean;
153+
short: boolean;
154+
action_ish: boolean;
155+
nav_ish: boolean;
156+
}
157+
158+
export interface MlRerankInfo {
159+
enabled: boolean;
160+
applied: boolean;
161+
reason?: string | null;
162+
candidate_count?: number | null;
163+
top_probability?: number | null;
164+
min_confidence?: number | null;
165+
is_high_confidence?: boolean | null;
166+
tags?: MlRerankTags | null;
167+
error?: string | null;
168+
}
169+
146170
export interface Snapshot {
147171
status: 'success' | 'error';
148172
timestamp?: string;
@@ -162,6 +186,8 @@ export interface Snapshot {
162186
modal_detected?: boolean;
163187
/** Array of GridInfo for detected modal grids */
164188
modal_grids?: GridInfo[];
189+
/** ML rerank metadata (optional) */
190+
ml_rerank?: MlRerankInfo;
165191
}
166192

167193
export interface StepHookContext {

tests/snapshot.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,36 @@ describe('Element ML Fields', () => {
145145
expect(element).not.toHaveProperty('ml_score');
146146
});
147147
});
148+
149+
describe('Snapshot ML Rerank Metadata', () => {
150+
it('should accept snapshot with ml_rerank metadata', () => {
151+
const snap = {
152+
status: 'success' as const,
153+
url: 'https://example.com',
154+
elements: [],
155+
ml_rerank: {
156+
enabled: true,
157+
applied: false,
158+
reason: 'low_confidence',
159+
candidate_count: 25,
160+
top_probability: 0.42,
161+
min_confidence: 0.6,
162+
is_high_confidence: false,
163+
tags: {
164+
repeated: true,
165+
sponsored_ish: true,
166+
non_sponsored: false,
167+
pos: true,
168+
occ: true,
169+
vocc: false,
170+
short: true,
171+
action_ish: false,
172+
nav_ish: false,
173+
},
174+
},
175+
};
176+
177+
expect(snap.ml_rerank.enabled).toBe(true);
178+
expect(snap.ml_rerank.is_high_confidence).toBe(false);
179+
});
180+
});

0 commit comments

Comments
 (0)