Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: update model match algo to support larger updates (#1806)

Max Deichmann7a22b0c3bfa3
diff --git a/web/scripts/model-match.ts b/web/scripts/model-match.ts
index 8cdb3d6a2f..88499fa18a 100644
--- a/web/scripts/model-match.ts
+++ b/web/scripts/model-match.ts
@@ -235,14 +235,23 @@ export async function modelMatch() {
}
}
- await prisma.observation.updateMany({
- where: {
- internalModel: "LANGFUSETMPNOMODEL",
- },
- data: {
- internalModel: null,
- },
- });
+ let updatedCount;
+ do {
+ console.log(`Updating LANGFUSETMPNOMODEL ${updatedCount}`);
+ const result = await prisma.$queryRaw<[{ id: string }]>`
+ WITH to_update AS (
+ SELECT id
+ FROM observations
+ WHERE internal_model = 'LANGFUSETMPNOMODEL'
+ AND "type" = 'GENERATION'
+ LIMIT 50000
+ )
+ UPDATE observations
+ set internal_model = NULL
+ WHERE id IN (SELECT id FROM to_update)
+ RETURNING id;`;
+ updatedCount = result.length;
+ } while (updatedCount > 0);
const end = Date.now();