Passer à la navigation principale

Getting Started

GitHub

Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plug-in. Ajoutez les Capgo compétences à votre outil IA à l'aide de la commande suivante :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Ensuite, utilisez 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 plug-in en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :

Fenêtre de terminal
bun add @capgo/capacitor-llm
bunx cap sync
import { CapgoLLM } from '@capgo/capacitor-llm';

Crée une nouvelle session de chat

import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.createChat();

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 });

Obtient l'état de disponibilité de l'LLM

import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.getReadiness();

Configure la configuration du modèle

  • iOS : Utilisez « Intelligence Apple » en tant que chemin pour le modèle système, ou fournissez le chemin vers le modèle MediaPipe
  • Android : Chemin vers un fichier de modèle MediaPipe (dans le répertoire assets ou files)
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({} as ModelOptions);

Télécharge un modèl’à partir d'une URL et le sauvegarde dans le répertoire approprié

  • iOS : Télécharge dans le répertoire de documents de l'application
  • Android : Télécharge dans le répertoire de fichiers de l'application
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.downloadModel({} as DownloadModelOptions);

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;
}

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;
}

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;
}

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;
}

Données d'événement pour la fin de l'IA.

export interface AiFinishedEvent {
/** The chat session ID that finished */
chatId: string;
}

Données d'événement pour le téléchargement en cours.

export interface DownloadProgressEvent {
/** Percentage of download completed (0-100) */
progress: number;
/** Total bytes to download */
totalBytes?: number;
/** Bytes downloaded so far */
downloadedBytes?: number;
}

Données d'événement pour les changements de statut de disponibilité.

export interface ReadinessChangeEvent {
/** The readiness status */
readiness: string;
}

Cette page est générée à partir du plugin’s src/definitions.tsRe-réexécutez la synchronisation lorsque les informations publiques API changent en amont.

Continuez de la section « Prise en main »

Section intitulée « Continuez de l'Accueil »

Si vous utilisez Accueil pour planifier votre tableau de bord et les opérations API Using @capgo/capacitor-llm Utilisation de @capgo/capacitor-llm pour la capacité native dans Utilisation de @API/__CAPGO_KEEP_1__-llm, Vue d'ensemble de API pour le détail d'implémentation dans Vue d'ensemble de __CAPGO_KEEP_0__, Introduction API Keys Clés de API Appareils pour le détail d'implémentation dans Appareils.