Skip to content

Commit

Permalink
fix: sanitize runID before countTokens (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt authored Aug 5, 2024
1 parent badaf68 commit d0d4f73
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/backend/src/utils/ingest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,20 @@ export async function cleanEvent(event: any): Promise<Event> {
console.error(event)
}

return {
const cleanedRun = {
...rest,
metadata: cleanMetadata(rest.metadata),
name: typeof name === "string" ? name.replace("models/", "") : undefined,
tags: typeof tags === "string" ? [tags] : tags,
tokensUsage: await completeRunUsageWithTimeout(event),
runId: await ensureIsUUID(runId),
parentRunId: await ensureIsUUID(parentRunId),
timestamp: isoTimestamp,
}

// Do it after because we need the sanitized runId/parentRunId
cleanedRun.tokensUsage = await completeRunUsageWithTimeout(cleanedRun)

return cleanedRun
}

export const clearUndefined = (obj: any): any =>
Expand Down

0 comments on commit d0d4f73

Please sign in to comment.