Passer à la navigation

Getting Started

GitHub

Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA en utilisant la commande suivante :

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

Utilisez 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 :

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';
const result = await CapgoLLM.createChat();
console.log(result);

Envoie un message à l'IA dans une session de chat spécifique

import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.sendMessage({
chatId: 'chat-id-123',
message: 'Hello from Capacitor',
});

Obtient l'état de préparation de l'LLM

import { CapgoLLM } from '@capgo/capacitor-llm';
const result = await CapgoLLM.getReadiness();
console.log(result);

Définit la configuration du modèle

  • iOS : Utilisez « Intelligence Apple » comme 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({
path: 'path/to/file',
modelType: 'task',
});

Télécharge un modèl’à partir d'une URL et le sauvegarde dans le bon emplacement

  • iOS : Téléchargé dans le répertoire documents de l'application
  • Android : Téléchargé dans le répertoire fichiers de l'application
import { CapgoLLM } from '@capgo/capacitor-llm';
const result = await CapgoLLM.downloadModel({ url: 'https://example.com' });
console.log(result);

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

Événement de données 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;
}

Événement de données pour la fin de l'IA.

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

Event data for download progress.

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

Event data for readiness status changes.

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

Cette page est générée à partir du plugin's src/definitions.tsRe-faire la synchronisation lorsque la publication API change en amont.

If vous utilisez Prise en main pour planifier votre tableau de bord et les opérations API, connectez-l’à En utilisant @capgo/capacitor-llm pour la capacité native dans En utilisant @capgo/capacitor-llm, API : Présentation pour les détails d'implémentation dans API : Présentation, Introduction pour les détails d'implémentation dans Introduction, Les clés API pour les détails d'implémentation dans Les clés API, et Les appareils pour les détails d'implémentation sur les appareils.