メインコンテンツにジャンプ

始めて

GitHub

CapgoのAIアシストセットアップを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

ターミナル画面
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.

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

ターミナル画面
bun add @capgo/capacitor-llm
bunx cap sync

インポート

インポート
import { CapgoLLM } from '@capgo/capacitor-llm';

API オーバービュー

API オーバービュー

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

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

sendMessage

__CAPGO_KEEP_1__

__CAPGO_KEEP_1__

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

getReadiness

__CAPGO_KEEP_2__

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

AiFinishedEvent

AI完了イベント

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

ReadinessChangeEvent

準備状態変更イベント

準備状態の変更イベントデータ。

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

真実の源

真実の源

このページはプラグインから生成されています。 src/definitions.ts. upstream の API が変更された場合に、再度 Sync を実行してください。

Getting Started から続けてください。

Getting Started から続けてください。

あなたが「 Getting Started ダッシュボードと API の作業を計画する場合に、接続してください。 native capability を使用する場合の @capgo/capacitor-llm native capability を使用する場合の @capgo/capacitor-llm API の概要 API の実装詳細 Introduction Introductionの実装詳細について API Keys API Keysの実装詳細について、 Devices Devicesの実装詳細について