Getting Started
Copiez un prompt de configuration avec les étapes d'installation et la guide markdown complet pour ce 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.
Installer
Section intitulée « Installer »Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA à l'aide de la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsUtilisez ensuite la prompt suivante :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-llm` plugin in my project.Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :
bun add @capgo/capacitor-llmbunx cap syncImporter
Section intitulée « Importer »import { CapgoLLM } from '@capgo/capacitor-llm';API Vue d'ensemble
Section intitulée « API Vue d'ensemble »createChat
Section intitulée « createChat »Crée une nouvelle session de chat
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.createChat();sendMessage
Section intitulée “envoyer un message”Envoie un message à l'IA dans une session de chat spécifique
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.sendMessage({} as { chatId: string; message: string });getReadiness
Section intitulée “préparation”Obtient l'état de préparation du modèle de langage
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.getReadiness();Configure la configuration du modèle
- iOS : Utilisez “Intelligence Apple” comme chemin pour le modèle système, ou fournissez un chemin vers un modèle MediaPipe
- Android : Chemin vers un fichier de modèle MediaPipe (dans les dossiers assets ou fichiers)
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({} as ModelOptions);downloadModel
Section intitulée “downloadModel”Télécharge un modèle à partir d'une URL et le sauvegarde dans le répertoire approprié
- iOS : Télécharge dans le répertoire des documents de l'application
- Android : Télécharge dans le répertoire des fichiers de l'application
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.downloadModel({} as DownloadModelOptions);Référence de type
Section intitulée “Type Reference”ModelOptions
Section intitulée “ModelOptions”Options de configuration du modèle.
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
Section intitulée “DownloadModelOptions”Options pour télécharger un modèle.
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
Section intitulée “DownloadModelResult”Résultat du téléchargement du modèle.
export interface DownloadModelResult { /** Path where the model was saved */ path: string; /** Path where the companion file was saved (if applicable) */ companionPath?: string;}TextFromAiEvent
Section intitulée “TextFromAiEvent”Données d'événement pour le texte reçu de l'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
Section intitulée “AiFinishedEvent”Données d'événement pour la fin de l'IA.
export interface AiFinishedEvent { /** The chat session ID that finished */ chatId: string;}DownloadProgressEvent
Section intitulée “DownloadProgressEvent”Données d'événement pour la progression de téléchargement.
export interface DownloadProgressEvent { /** Percentage of download completed (0-100) */ progress: number; /** Total bytes to download */ totalBytes?: number; /** Bytes downloaded so far */ downloadedBytes?: number;}ReadinessChangeEvent
Section intitulée « ReadinessChangeEvent »Données d'événement pour les changements de statut de disponibilité.
export interface ReadinessChangeEvent { /** The readiness status */ readiness: string;}Source De Vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin's src/definitions.tsRe-faire la synchronisation lorsque les public API changent en amont.
Continuer depuis Getting Started
Section intitulée « Continuer depuis Getting Started »Si vous utilisez Démarrage pour planifier le tableau de bord et les opérations API, connectez-le à En utilisant @capgo/capacitor-llm pour la capacité native dans En utilisant @capgo/capacitor-llm, Présentation de API pour le détail d'implémentation dans Présentation de API, Introduction pour le détail d'implémentation dans Introduction, Clés de API pour le détail d'implémentation dans Clés de API, et Appareils pour le détail d'implémentation dans Appareils.