Package-level declarations

Types

Link copied to clipboard
sealed interface AgentTurn

One turn of the conversation:

Link copied to clipboard
object AiMetrics

Lightweight, on-device assistant metrics (SoT §36/§37). Tracks how often the deterministic path handles a request vs. how often we fall back to the model, plus model latency — so we can verify "deterministic commands cost 0 LLM calls" and later judge whether prefix-caching actually helps. No data leaves the device; only aggregate counters are logged.

Link copied to clipboard
class Assistant(prepareFn: suspend () -> Boolean, generateFn: suspend (prefix: String, suffix: String) -> String?, aliasesFn: () -> Map<String, String> = { emptyMap() })
Link copied to clipboard

The chat template the downloaded model was trained with.

Link copied to clipboard

The judge's verdict on raw input — the explicit first step of every model turn. Every verdict is logged at INFO on AI_TAG, so a demo (adb logcat -s FoyerAI) shows the decision the moment the text arrives.

Link copied to clipboard
class LlmEngine(context: Context, modelPath: String, template: ChatTemplate = ChatTemplate.GEMMA)

On-device text generation via MediaPipe LLM Inference, backed by whatever .task model the user downloaded (Qwen, Gemma, …) — fully local, no network at inference time.

Link copied to clipboard

Streams a model file to local storage with progress. Follows redirects manually so a Hugging Face resolve URL (which 302s to a signed CDN link) works, and only sends the auth token to the first host — never to the CDN.

Properties

Link copied to clipboard
const val AI_TAG: String

Functions

Link copied to clipboard
suspend fun classifyInput(generate: suspend (String, String) -> String?, query: String): InputKind

Asks the model for a one-word verdict; anything unparseable is InputKind.UNCLEAR.

Link copied to clipboard
suspend fun decideIntent(generate: suspend (String, String) -> String?, query: String, index: AppIndex): Plan

Model-driven decision: given a text generator, ask the model to pick one or more actions. The prompt is generated from the capability CAPABILITIES catalog and grounded with the actual installed apps that look relevant, so the model selects a real app instead of guessing a name. The model decides; we only parse + execute.

Link copied to clipboard
suspend fun extractPairs(generate: suspend (String, String) -> String?, query: String): List<ActionPair>

Cycle-2 call: the model names the pairs; empty on a dud reply.

Link copied to clipboard
fun modelFile(context: Context): File

Where the active model lives — downloaded or copied in from local storage.

Link copied to clipboard

Builds the Assistant over the downloaded model, or null if AI is off or no model is set up.