@capgo/capacitor-llm
Version:
Adds support for LLM locally runned for Capacitor
493 lines • 14.8 kB
JSON
{
"api": {
"name": "LLMPlugin",
"slug": "llmplugin",
"docs": "LLM Plugin interface for interacting with on-device language models",
"tags": [],
"methods": [
{
"name": "createChat",
"signature": "() => Promise<{ id: string; instructions?: string; }>",
"parameters": [],
"returns": "Promise<{ id: string; instructions?: string | undefined; }>",
"tags": [
{
"name": "returns",
"text": "Promise with chat id and optional instructions"
}
],
"docs": "Creates a new chat session",
"complexTypes": [],
"slug": "createchat"
},
{
"name": "sendMessage",
"signature": "(options: { chatId: string; message: string; }) => Promise<void>",
"parameters": [
{
"name": "options",
"docs": "- The chat id and message to send",
"type": "{ chatId: string; message: string; }"
}
],
"returns": "Promise<void>",
"tags": [
{
"name": "param",
"text": "options - The chat id and message to send"
},
{
"name": "returns",
"text": "Promise that resolves when message is sent"
}
],
"docs": "Sends a message to the AI in a specific chat session",
"complexTypes": [],
"slug": "sendmessage"
},
{
"name": "getReadiness",
"signature": "() => Promise<{ readiness: string; }>",
"parameters": [],
"returns": "Promise<{ readiness: string; }>",
"tags": [
{
"name": "returns",
"text": "Promise with readiness status string"
}
],
"docs": "Gets the readiness status of the LLM",
"complexTypes": [],
"slug": "getreadiness"
},
{
"name": "setModel",
"signature": "(options: ModelOptions) => Promise<void>",
"parameters": [
{
"name": "options",
"docs": "- The model configuration",
"type": "ModelOptions"
}
],
"returns": "Promise<void>",
"tags": [
{
"name": "param",
"text": "options - The model configuration"
},
{
"name": "returns",
"text": "Promise that resolves when model is loaded"
}
],
"docs": "Sets the model configuration\n- iOS: Use \"Apple Intelligence\" as path for system model, or provide path to MediaPipe model\n- Android: Path to a MediaPipe model file (in assets or files directory)",
"complexTypes": [
"ModelOptions"
],
"slug": "setmodel"
},
{
"name": "downloadModel",
"signature": "(options: DownloadModelOptions) => Promise<DownloadModelResult>",
"parameters": [
{
"name": "options",
"docs": "- The download configuration",
"type": "DownloadModelOptions"
}
],
"returns": "Promise<DownloadModelResult>",
"tags": [
{
"name": "param",
"text": "options - The download configuration"
},
{
"name": "returns",
"text": "Promise with download result including the saved path"
}
],
"docs": "Downloads a model from a URL and saves it to the appropriate location\n- iOS: Downloads to the app's documents directory\n- Android: Downloads to the app's files directory",
"complexTypes": [
"DownloadModelResult",
"DownloadModelOptions"
],
"slug": "downloadmodel"
},
{
"name": "addListener",
"signature": "(eventName: 'textFromAi', listenerFunc: (event: TextFromAiEvent) => void) => Promise<{ remove: () => Promise<void>; }>",
"parameters": [
{
"name": "eventName",
"docs": "- Event name 'textFromAi'",
"type": "'textFromAi'"
},
{
"name": "listenerFunc",
"docs": "- Callback function for text events",
"type": "(event: TextFromAiEvent) => void"
}
],
"returns": "Promise<{ remove: () => Promise<void>; }>",
"tags": [
{
"name": "param",
"text": "eventName - Event name 'textFromAi'"
},
{
"name": "param",
"text": "listenerFunc - Callback function for text events"
},
{
"name": "returns",
"text": "Promise with remove function to unsubscribe"
}
],
"docs": "Adds a listener for text received from AI",
"complexTypes": [
"TextFromAiEvent"
],
"slug": "addlistenertextfromai-"
},
{
"name": "addListener",
"signature": "(eventName: 'aiFinished', listenerFunc: (event: AiFinishedEvent) => void) => Promise<{ remove: () => Promise<void>; }>",
"parameters": [
{
"name": "eventName",
"docs": "- Event name 'aiFinished'",
"type": "'aiFinished'"
},
{
"name": "listenerFunc",
"docs": "- Callback function for finish events",
"type": "(event: AiFinishedEvent) => void"
}
],
"returns": "Promise<{ remove: () => Promise<void>; }>",
"tags": [
{
"name": "param",
"text": "eventName - Event name 'aiFinished'"
},
{
"name": "param",
"text": "listenerFunc - Callback function for finish events"
},
{
"name": "returns",
"text": "Promise with remove function to unsubscribe"
}
],
"docs": "Adds a listener for AI completion events",
"complexTypes": [
"AiFinishedEvent"
],
"slug": "addlisteneraifinished-"
},
{
"name": "addListener",
"signature": "(eventName: 'downloadProgress', listenerFunc: (event: DownloadProgressEvent) => void) => Promise<{ remove: () => Promise<void>; }>",
"parameters": [
{
"name": "eventName",
"docs": "- Event name 'downloadProgress'",
"type": "'downloadProgress'"
},
{
"name": "listenerFunc",
"docs": "- Callback function for progress events",
"type": "(event: DownloadProgressEvent) => void"
}
],
"returns": "Promise<{ remove: () => Promise<void>; }>",
"tags": [
{
"name": "param",
"text": "eventName - Event name 'downloadProgress'"
},
{
"name": "param",
"text": "listenerFunc - Callback function for progress events"
},
{
"name": "returns",
"text": "Promise with remove function to unsubscribe"
}
],
"docs": "Adds a listener for model download progress events",
"complexTypes": [
"DownloadProgressEvent"
],
"slug": "addlistenerdownloadprogress-"
},
{
"name": "addListener",
"signature": "(eventName: 'readinessChange', listenerFunc: (event: ReadinessChangeEvent) => void) => Promise<{ remove: () => Promise<void>; }>",
"parameters": [
{
"name": "eventName",
"docs": "- Event name 'readinessChange'",
"type": "'readinessChange'"
},
{
"name": "listenerFunc",
"docs": "- Callback function for readiness events",
"type": "(event: ReadinessChangeEvent) => void"
}
],
"returns": "Promise<{ remove: () => Promise<void>; }>",
"tags": [
{
"name": "param",
"text": "eventName - Event name 'readinessChange'"
},
{
"name": "param",
"text": "listenerFunc - Callback function for readiness events"
},
{
"name": "returns",
"text": "Promise with remove function to unsubscribe"
}
],
"docs": "Adds a listener for readiness status changes",
"complexTypes": [
"ReadinessChangeEvent"
],
"slug": "addlistenerreadinesschange-"
},
{
"name": "getPluginVersion",
"signature": "() => Promise<{ version: string; }>",
"parameters": [],
"returns": "Promise<{ version: string; }>",
"tags": [
{
"name": "returns",
"text": "Promise that resolves with the plugin version"
},
{
"name": "throws",
"text": "Error if getting the version fails"
},
{
"name": "since",
"text": "1.0.0"
},
{
"name": "example",
"text": "```typescript\nconst { version } = await CapgoLLM.getPluginVersion();\nconsole.log('Plugin version:', version);\n```"
}
],
"docs": "Get the native Capacitor plugin version.",
"complexTypes": [],
"slug": "getpluginversion"
}
],
"properties": []
},
"interfaces": [
{
"name": "ModelOptions",
"slug": "modeloptions",
"docs": "Model configuration options",
"tags": [],
"methods": [],
"properties": [
{
"name": "path",
"tags": [],
"docs": "Model path or \"Apple Intelligence\" for iOS system model",
"complexTypes": [],
"type": "string"
},
{
"name": "modelType",
"tags": [],
"docs": "Model file type/extension (e.g., \"task\", \"bin\", \"litertlm\"). If not provided, will be extracted from path.",
"complexTypes": [],
"type": "string | undefined"
},
{
"name": "maxTokens",
"tags": [],
"docs": "Maximum number of tokens the model handles",
"complexTypes": [],
"type": "number | undefined"
},
{
"name": "topk",
"tags": [],
"docs": "Number of tokens the model considers at each step",
"complexTypes": [],
"type": "number | undefined"
},
{
"name": "temperature",
"tags": [],
"docs": "Amount of randomness in generation (0.0-1.0)",
"complexTypes": [],
"type": "number | undefined"
},
{
"name": "randomSeed",
"tags": [],
"docs": "Random seed for generation",
"complexTypes": [],
"type": "number | undefined"
}
]
},
{
"name": "DownloadModelResult",
"slug": "downloadmodelresult",
"docs": "Result of model download",
"tags": [],
"methods": [],
"properties": [
{
"name": "path",
"tags": [],
"docs": "Path where the model was saved",
"complexTypes": [],
"type": "string"
},
{
"name": "companionPath",
"tags": [],
"docs": "Path where the companion file was saved (if applicable)",
"complexTypes": [],
"type": "string | undefined"
}
]
},
{
"name": "DownloadModelOptions",
"slug": "downloadmodeloptions",
"docs": "Options for downloading a model",
"tags": [],
"methods": [],
"properties": [
{
"name": "url",
"tags": [],
"docs": "URL of the model file to download",
"complexTypes": [],
"type": "string"
},
{
"name": "companionUrl",
"tags": [],
"docs": "Optional: URL of companion file (e.g., .litertlm for Android)",
"complexTypes": [],
"type": "string | undefined"
},
{
"name": "filename",
"tags": [],
"docs": "Optional: Custom filename (defaults to filename from URL)",
"complexTypes": [],
"type": "string | undefined"
}
]
},
{
"name": "TextFromAiEvent",
"slug": "textfromaievent",
"docs": "Event data for text received from AI",
"tags": [],
"methods": [],
"properties": [
{
"name": "text",
"tags": [],
"docs": "The text content from AI - this is an incremental chunk, not the full text",
"complexTypes": [],
"type": "string"
},
{
"name": "chatId",
"tags": [],
"docs": "The chat session ID",
"complexTypes": [],
"type": "string"
},
{
"name": "isChunk",
"tags": [],
"docs": "Whether this is a complete chunk (true) or partial streaming data (false)",
"complexTypes": [],
"type": "boolean | undefined"
}
]
},
{
"name": "AiFinishedEvent",
"slug": "aifinishedevent",
"docs": "Event data for AI completion",
"tags": [],
"methods": [],
"properties": [
{
"name": "chatId",
"tags": [],
"docs": "The chat session ID that finished",
"complexTypes": [],
"type": "string"
}
]
},
{
"name": "DownloadProgressEvent",
"slug": "downloadprogressevent",
"docs": "Event data for download progress",
"tags": [],
"methods": [],
"properties": [
{
"name": "progress",
"tags": [],
"docs": "Percentage of download completed (0-100)",
"complexTypes": [],
"type": "number"
},
{
"name": "totalBytes",
"tags": [],
"docs": "Total bytes to download",
"complexTypes": [],
"type": "number | undefined"
},
{
"name": "downloadedBytes",
"tags": [],
"docs": "Bytes downloaded so far",
"complexTypes": [],
"type": "number | undefined"
}
]
},
{
"name": "ReadinessChangeEvent",
"slug": "readinesschangeevent",
"docs": "Event data for readiness status changes",
"tags": [],
"methods": [],
"properties": [
{
"name": "readiness",
"tags": [],
"docs": "The readiness status",
"complexTypes": [],
"type": "string"
}
]
}
],
"enums": [],
"typeAliases": [],
"pluginConfigs": []
}