From 1dfa5d12f6af6ca964bdfa911809a061ffdf36c2 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Fri, 26 Dec 2025 11:14:17 +0000 Subject: chore: add a tool for comparing perf of different models --- tools/compare-models/src/bookmarkProcessor.ts | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tools/compare-models/src/bookmarkProcessor.ts (limited to 'tools/compare-models/src/bookmarkProcessor.ts') diff --git a/tools/compare-models/src/bookmarkProcessor.ts b/tools/compare-models/src/bookmarkProcessor.ts new file mode 100644 index 00000000..910957fe --- /dev/null +++ b/tools/compare-models/src/bookmarkProcessor.ts @@ -0,0 +1,56 @@ +import type { InferenceClient } from "./inferenceClient"; +import type { Bookmark } from "./types"; + +export async function extractBookmarkContent( + bookmark: Bookmark, +): Promise { + if (bookmark.content.type === "link") { + const parts = []; + + if (bookmark.content.url) { + parts.push(`URL: ${bookmark.content.url}`); + } + + if (bookmark.title) { + parts.push(`Title: ${bookmark.title}`); + } + + if (bookmark.content.description) { + parts.push(`Description: ${bookmark.content.description}`); + } + + if (bookmark.content.htmlContent) { + parts.push(`Content: ${bookmark.content.htmlContent}`); + } + + return parts.join("\n"); + } + + if (bookmark.content.type === "text" && bookmark.content.text) { + return bookmark.content.text; + } + + return ""; +} + +export async function runTaggingForModel( + bookmark: Bookmark, + model: string, + inferenceClient: InferenceClient, + lang: string = "english", +): Promise { + const content = await extractBookmarkContent(bookmark); + + if (!content) { + return []; + } + + try { + const tags = await inferenceClient.inferTags(content, model, lang, []); + return tags; + } catch (error) { + throw new Error( + `Failed to generate tags with ${model}: ${error instanceof Error ? error.message : String(error)}`, + ); + } +} -- cgit v1.2.3-70-g09d2