Some neat little utilities relied upon by Regreso clients. Right now, these can be used to:
- Get metadata info about websites (for prefilling destination details automatically)
- AI-generate a list of practically-usable, relevant tags to describe a location based on metadata (supports provided, self-hostable AI instance URL)
Let's say you wanted to use this module in your own regreso client (or something entirely different), here's how:
-
SiteTagger(config) - A class used to control AI-based website tagging behaviors.
import { SiteTagger } from "@regreso/utils"; async function demo() { const tagger = new SiteTagger({ maxTags: 3, aiInstance: "https://ai.hackclub.com", maxRetries: 2, requestDelay: 1000, }); const demoSites = [ { url: "https://github.com/microsoft/vscode", headline: "Visual Studio Code", description: "A lightweight but powerful source code editor", }, { url: "https://css-tricks.com/snippets/css/a-guide-to-flexbox/", headline: "A Complete Guide to Flexbox", description: "CSS Flexbox layout guide with examples", }, ]; const result = await tagger.generateTags(demoSites[0]); if (result.success) { console.log( `tags: ${result.tags.join(", ")} in ${result.metadata?.processingTime} ms.`, ); } else { console.log(`error: ${result.error}`); } const batchResults = await tagger.generateTagsBatch(demoSites); console.log( batchResults .filter((r) => r.result.success) .map((r) => `${r.headline}: [${r.result.tags.join(", ")}]`) .join("\n"), ); } demo();
-
getWebDetails(url: String) - Gets the web details scraped from meta tags of specified website's URL. Returns multiple versions if relevant (title, og:title, twitter:title to be specific)
import { getWebDetails } from "@regreso/utils"; async function demo() { const webDetailsResult = await getWebDetails("fbi.gov"); console.log({ url: webDetailsResult.url, // with protocol appended if missing title: webDetailsResult.title[0] ?? webDetailsResult.title[1] ?? webDetailsResult.title[2], description: webDetailsResult.description[0] ?? webDetailsResult.description[1] ?? webDetailsResult.description[2], }); } demo();
- Add site metadata scraping
- Add AI-tagging
- Document package
- Basic Usage Demo
- Support scraping image metadata