Utilisez l’API LLM locale lorsqu’un script a besoin de génération de texte, classification, extraction ou résumé.
// Ask the LLM — Use a local AI model for analysis//// This script sends a prompt to the configured LLM// and logs the response.// Requires an LLM provider configured in Settings > AI.
g.log("Sending prompt to LLM...");
// Simple text generation (specify your model name)const model = "llama3"; // Change to your installed modelconst response = await g.llm.promptLocalLlm( model, "Explain what a web scraper does in two sentences.");
g.log("LLM response:");g.log(response);
// You can also combine LLM with page content// (requires a browser tab with a loaded page)const tabs = g.tabs.getTabs();if (tabs && tabs.length > 0) { const pageText = await g.dom.extractContent("body");
if (pageText && pageText.length > 0) { // Trim to first 500 chars to stay within context limits const snippet = pageText.substring(0, 500);
const summary = await g.llm.promptLocalLlm( model, "Summarize this web page in one paragraph:\n\n" + snippet );
g.log("Page summary: " + summary); } else { g.log("Page has no text content to summarize."); }}