__CAPGO_KEEP_2__

Getting Started

GitHub

CapgoのAIアシストセットアップを使用してプラグインをインストールできます。次のコマンドを使用して、CapgoスキルをAIツールに追加します。

ターミナルウィンドウ
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次のプロンプトを使用してください:

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

手動セットアップを使用する場合は、以下のコマンドを実行して、下記のプラットフォーム固有の指示に従ってください。

ターミナルウィンドウ
bun add @capgo/capacitor-llm
bunx cap sync
import { CapgoLLM } from '@capgo/capacitor-llm';

新しいチャットセッションを作成します

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

特定のチャットセッション内でAIにメッセージを送信します

import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.sendMessage({} as { chatId: string; message: string });

LLMのリードネス状態を取得します

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

モデル設定を設定します

  • iOS: Apple Intelligence をシステムモデルとしてパスに使用するか、MediaPipe モデルへのパスを指定します。
  • Android: アセットまたはファイルディレクトリ内の MediaPipe モデルファイルへのパスを指定します。
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({} as ModelOptions);

URL からモデルをダウンロードし、適切な場所に保存します。

  • iOS: アプリのドキュメント ディレクトリにダウンロードします。
  • Android: アプリのファイル ディレクトリにダウンロードします。
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.downloadModel({} as DownloadModelOptions);

モデル設定オプション。

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

モデルをダウンロードするためのオプション

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

モデルダウンロードの結果

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

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

AI完了のイベントデータ

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

ダウンロード進行イベントのイベントデータ

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

リードネスステータス変更イベントのデータ

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

ソースオブトゥルース

ソースオブトゥルース

このページはプラグインの src/definitions.tsパブリックAPIがアップストリームで変更されたときに、再度同期を実行してください。

続けて、Getting Startedから

「始めから続ける」

あなたが「」を使用している場合 「」 「」を使用してダッシュボードとAPIの操作を計画する場合、APIと接続します 「@capgo/capacitor-llm」を使用して、@「@capgo/capacitor-llm」のネイティブ機能 for the native capability in Using @capgo/capacitor-llm, 「APIの概要」の実装詳細 for the implementation detail in API Overview, 「導入」の実装詳細 「__CAPGO_KEEP_0__のキー」 「APIのキー」の実装詳細 for the implementation detail in API Keys, and デバイス デバイスの実装詳細について