__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-llm

ページ/エリア: Capgo マーケティング ウェブサイト。役割: ウェブサイト コピー文。見つける場所: コンポーネント doc/SignupCta.astro、コンポーネント Hero.astro。

GitHub

インストール

ソースガイド

AI-Assisted セットアップを使用してプラグインをインストールできます。次のコマンドを使用して、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.

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

ターミナル画面
bun add @capgo/capacitor-llm
bunx cap sync
import { CapgoLLM } from '@capgo/capacitor-llm';

APIの概要

APIガイド

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

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

sendMessage

sendMessage

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

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

getReadiness

「準備状況」

LLMの準備状態を取得します

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

モデル設定を設定します

  • iOS: Apple Intelligenceをシステムモデルとして使用するか、MediaPipeモデルへのパスを提供します
  • Android: MediaPipe モデルファイルのパス (アセットまたはファイルディレクトリ)
import { CapgoLLM } from '@capgo/capacitor-llm';
await CapgoLLM.setModel({
path: 'path/to/file',
modelType: 'task',
});

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

  • iOS: アプリのドキュメントディレクトリにダウンロード
  • Android: アプリのファイルディレクトリにダウンロード
import { CapgoLLM } from '@capgo/capacitor-llm';
const result = await CapgoLLM.downloadModel({ url: 'https://example.com' });
console.log(result);

モデル設定オプション

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

「ReadinessChangeEvent」

リードネス チェンジ イベント

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

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

ソース オブ トゥース

ソース オブ トゥース src/definitions.ts.APIがアップストリームで変更されたときは、再度同期を実行してください。

パブリック __CAPGO_KEEP_0__ のアップストリームで変更されたときに、再度同期を実行してください。

続けて始めましょう: Getting Started

Capgoを使用している場合 Getting Started 計画ダッシュボードとAPIの運用を、 Using @capgo/capacitor-llm Capgoのネイティブ機能の使用に@capgo/capacitor-llmを使用します。 API まとめ for the API の実装詳細について Introduction 導入の詳細については、導入のページを参照してください。 API キー for API Keys の実装詳細について デバイス デバイスの実装詳細について。