Skip to content

Commit 202bea0

Browse files
committed
refactor: convert relabelUsingFullFilesForUser, relabelWithRelace, and relabelWithClaudeWithFullFileContext to use object parameters
1 parent 3ef0c5f commit 202bea0

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

backend/src/admin/relabelRuns.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export async function relabelForUserHandler(req: Request, res: Response) {
140140

141141
const allResults = []
142142

143-
const relaceResults = relabelUsingFullFilesForUser(userId, limit)
143+
const relaceResults = relabelUsingFullFilesForUser({ userId, limit })
144144

145145
// Process each model
146146
for (const model of modelsToRelabel) {
@@ -250,7 +250,11 @@ export async function relabelForUserHandler(req: Request, res: Response) {
250250
}
251251
}
252252

253-
async function relabelUsingFullFilesForUser(userId: string, limit: 10) {
253+
async function relabelUsingFullFilesForUser(params: {
254+
userId: string
255+
limit: number
256+
}) {
257+
const { userId, limit } = params
254258
// TODO: We need to figure out changing _everything_ to use `getTracesAndAllDataForUser`
255259
const tracesBundles = await getTracesAndAllDataForUser(userId)
256260

@@ -274,7 +278,7 @@ async function relabelUsingFullFilesForUser(userId: string, limit: 10) {
274278
}
275279

276280
if (!traceBundle.relabels.some((r) => r.model === 'relace-ranker')) {
277-
relabelPromises.push(relabelWithRelace(trace, fileBlobs))
281+
relabelPromises.push(relabelWithRelace({ trace, fileBlobs }))
278282
didRelabel = true
279283
}
280284
for (const model of [
@@ -287,7 +291,7 @@ async function relabelUsingFullFilesForUser(userId: string, limit: 10) {
287291
)
288292
) {
289293
relabelPromises.push(
290-
relabelWithClaudeWithFullFileContext(trace, fileBlobs, model),
294+
relabelWithClaudeWithFullFileContext({ trace, fileBlobs, model }),
291295
)
292296
didRelabel = true
293297
}
@@ -308,10 +312,11 @@ async function relabelUsingFullFilesForUser(userId: string, limit: 10) {
308312
return relabeled
309313
}
310314

311-
async function relabelWithRelace(
312-
trace: GetRelevantFilesTrace,
313-
fileBlobs: GetExpandedFileContextForTrainingBlobTrace,
314-
) {
315+
async function relabelWithRelace(params: {
316+
trace: GetRelevantFilesTrace
317+
fileBlobs: GetExpandedFileContextForTrainingBlobTrace
318+
}) {
319+
const { trace, fileBlobs } = params
315320
logger.info(`Relabeling ${trace.id} with Relace`)
316321
const messages = trace.payload.messages || []
317322
const queryBody =
@@ -357,12 +362,13 @@ async function relabelWithRelace(
357362
return relaced
358363
}
359364

360-
export async function relabelWithClaudeWithFullFileContext(
361-
trace: GetRelevantFilesTrace,
362-
fileBlobs: GetExpandedFileContextForTrainingBlobTrace,
363-
model: string,
364-
dataset?: string,
365-
) {
365+
export async function relabelWithClaudeWithFullFileContext(params: {
366+
trace: GetRelevantFilesTrace
367+
fileBlobs: GetExpandedFileContextForTrainingBlobTrace
368+
model: string
369+
dataset?: string
370+
}) {
371+
const { trace, fileBlobs, model, dataset } = params
366372
if (dataset) {
367373
await setupBigQuery({ dataset, logger })
368374
}

scripts/ft-file-selection/relabel-traces-with-context.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ async function runTraces() {
9090
console.log(`Processing trace ${trace.id}`)
9191

9292
try {
93-
await relabelWithClaudeWithFullFileContext(
93+
await relabelWithClaudeWithFullFileContext({
9494
trace,
9595
fileBlobs,
96-
MODEL_TO_TEST,
97-
DATASET,
98-
)
96+
model: MODEL_TO_TEST,
97+
dataset: DATASET,
98+
})
9999
console.log(`Successfully stored relabel for trace ${trace.id}`)
100100
} catch (error) {
101101
console.error(`Error processing trace ${trace.id}:`, error)

0 commit comments

Comments
 (0)