Iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-llm`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/llm/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installazione
Sezione intitolata “Installazione”bun add @capgo/capacitor-llmbunx cap syncImporta
Sezione intitolata “Importa”import { CapgoLLM } from '@capgo/capacitor-llm';API Panoramica
Sezione intitolata “API Panoramica”createChat
Sezione intitolata “createChat”Crea una nuova sessione di chat
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.createChat();sendMessage
Sezione intitolata “inviareMessaggio”Invia un messaggio all'IA in una sessione di chat specifica
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.sendMessage({} as { chatId: string; message: string });getReadiness
Sezione intitolata “ottenereStatoDiProntezza”Ottiene lo stato di prontezza del modello
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.getReadiness();setModel
Sezione intitolata “setModel”Imposta la configurazione del modello
- iOS: Utilizza "Intelligenza di Apple" come percorso per il modello del sistema, oppure fornisce il percorso al modello MediaPipe
- Android: Percorso a un file del modello MediaPipe (nella directory degli asset o dei file)
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({} as ModelOptions);downloadModel
Sezione intitolata “downloadModel”Scarica un modello da un URL e salvalo nella posizione appropriata
- iOS: Scarica nella directory dei documenti dell'app
- Android: Scarica nella directory dei file dell'app
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.downloadModel({} as DownloadModelOptions);Riferimento di tipo
Sezione intitolata “Type Reference”ModelOptions
Sezione intitolata “ModelOptions”Opzioni di configurazione del modello.
export interface ModelOptions { /** Model path or "Apple Intelligence" for iOS system model */ path: string; /** Model file type/extension (e.g., "task", "bin", "litertlm"). If not provided, will be extracted from path. */ modelType?: string; /** Maximum number of tokens the model handles */ maxTokens?: number; /** Number of tokens the model considers at each step */ topk?: number; /** Amount of randomness in generation (0.0-1.0) */ temperature?: number; /** Random seed for generation */ randomSeed?: number;}DownloadModelOptions
Sezione intitolata “DownloadModelOptions”Opzioni per il download di un modello.
export interface DownloadModelOptions { /** URL of the model file to download */ url: string; /** Optional: URL of companion file (e.g., .litertlm for Android) */ companionUrl?: string; /** Optional: Custom filename (defaults to filename from URL) */ filename?: string;}DownloadModelResult
Sezione intitolata “DownloadModelResult”Risultato del download del modello.
export interface DownloadModelResult { /** Path where the model was saved */ path: string; /** Path where the companion file was saved (if applicable) */ companionPath?: string;}TextFromAiEvent
Sezione intitolata “TextFromAiEvent”Dati dell'evento per il testo ricevuto dall'IA.
export interface TextFromAiEvent { /** The text content from AI - this is an incremental chunk, not the full text */ text: string; /** The chat session ID */ chatId: string; /** Whether this is a complete chunk (true) or partial streaming data (false) */ isChunk?: boolean;}AiFinishedEvent
Sezione intitolata “AiFinishedEvent”Dati evento per completamento AI.
export interface AiFinishedEvent { /** The chat session ID that finished */ chatId: string;}DownloadProgressEvent
Sezione intitolata “DownloadProgressEvent”Dati evento per progresso download.
export interface DownloadProgressEvent { /** Percentage of download completed (0-100) */ progress: number; /** Total bytes to download */ totalBytes?: number; /** Bytes downloaded so far */ downloadedBytes?: number;}ReadinessChangeEvent
Sezione intitolata “ReadinessChangeEvent”Dati evento per cambiamenti di stato di disponibilità.
export interface ReadinessChangeEvent { /** The readiness status */ readiness: string;}Fonte di Verità
Sezione intitolata “Fonte di Verità”Questa pagina è generata dal plugin. src/definitions.ts. Riavvia la sincronizzazione quando i dati pubblici API cambiano in fase di sviluppo.