Zum Inhalt springen

Getting Started

GitHub

Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie den Capgo-Fähigkeiten Ihrer KI-Tool mithilfe der folgenden Befehl hinzu:

Terminal-Fenster
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Dann verwenden Sie die folgende Anfrage:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-llm` plugin in my project.

Wenn Sie eine manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und die unten angegebenen Plattform-spezifischen Anweisungen befolgen:

Terminalfenster
bun add @capgo/capacitor-llm
bunx cap sync
import { CapgoLLM } from '@capgo/capacitor-llm';

Erstellt eine neue Chat-Sitzung

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

Ermittelt eine Nachricht an den AI in einer bestimmten Chat-Sitzung

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

Ermittelt den Bereitschaftsstatus des LLM

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

Setzt die Modellkonfiguration

  • iOS: Verwende “Apple Intelligence” als Pfad für das Systemmodell oder gib den Pfad zum MediaPipe-Modell an
  • Android: Pfad zu einem MediaPipe-Modell-Datei (in assets oder files-Verzeichnis)
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({
path: 'path/to/file',
modelType: 'task',
});

Herunterlädt ein Modell von einer URL und speichert es an der entsprechenden Stelle

  • iOS: Herunterladen in das Dokumentenverzeichnis der App
  • Android: Herunterladen in das Dateiverzeichnis der App
import { CapgoLLM } from '@capgo/capacitor-llm';
const result = await CapgoLLM.downloadModel({ url: 'https://example.com' });
console.log(result);

Optionen für die Modellkonfiguration.

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

Optionen für das Herunterladen eines Modells.

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

Ergebnis des Modellherunterladens.

export interface DownloadModelResult {
/** Path where the model was saved */
path: string;
/** Path where the companion file was saved (if applicable) */
companionPath?: string;
}

Eventdaten für Text von AI.

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

Eventdaten für die AI-Abgeschlossenheit.

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

Eventdaten für den Downloadfortschritt.

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

Daten für die Bereitschaftsstatusänderungen.

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

Diese Seite wird aus dem Plugin generiert. src/definitions.tsRe-run die Synchronisierung, wenn die öffentliche API upstream geändert wird.

Wenn Sie das verwenden Getting Started um das Dashboard und die API-Planung zu organisieren, verbinden Sie es mit Mit @capgo/capacitor-llm Für die native Fähigkeit in @capgo/capacitor-llm, API Übersicht Für die Implementierungsdetails in API Übersicht, Einführung Für die Implementierungsdetails in Einführung, API Schlüssel Für die Implementierungsdetails in API Schlüssel und Geräte für die Implementierungsdetails in Geräten.