はじめに
このプラグインのインストール手順と全マークダウンガイドを含む設定用の質問をコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-llm`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/llm/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」のセクションbun add @capgo/capacitor-llmbunx cap syncインポート
「インポート」のセクションimport { CapgoLLM } from '@capgo/capacitor-llm';API __Overview__
セクション「API __Overview__」createChat
セクション「createChat」新しいチャットセッションを作成します
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.createChat();sendMessage
セクション「sendMessage」特定のチャットセッション内でAIにメッセージを送信します
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.sendMessage({} as { chatId: string; message: string });getReadiness
セクション「getReadiness」LLMのリードネス状態を取得します
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.getReadiness();setModel
セクション「setModel」モデル設定を設定します
- iOS: Apple Intelligence をシステムモデルとしてパスに使用するか、MediaPipe モデルへのパスを指定します
- Android: アセットまたはファイルディレクトリ内の MediaPipe モデルファイルへのパス
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({} as ModelOptions);downloadModel
ダウンロードモデルURL からモデルをダウンロードし、適切な場所に保存します
- iOS: アプリのドキュメントディレクトリにダウンロード
- Android: アプリのファイルディレクトリにダウンロード
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.downloadModel({} as DownloadModelOptions);型参照
型参照ModelOptions
モデルオプションモデル設定オプション。
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;}DownloadModelOptions
ダウンロードモデルオプションモデルをダウンロードするためのオプション。
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;}DownloadModelResult
ダウンロードモデル結果モデルダウンロードの結果。
export interface DownloadModelResult { /** Path where the model was saved */ path: string; /** Path where the companion file was saved (if applicable) */ companionPath?: string;}TextFromAiEvent
テキストからAIイベント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;}DownloadProgressEvent
ダウンロード進行イベントのセクションダウンロード進行のイベントデータ。
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パブリック API がアップストリームで変更された場合に再度同期を実行してください。