$ show google-ai-edge/gallery
Google AI Edge Gallery is an Android application that serves as a showcase and playground for on-device AI models, primarily Gemma 4 and other LiteRT-compatible LLMs. It provides a rich set of interactive tasks including AI Chat, Prompt Lab, Ask Image, Audio Scribe, Tiny Garden (a mini-game powered by a 270M model), Mobile Actions (device control via function calling), and an Agent Skills system with MCP (Model Context Protocol) integration. The app manages the full lifecycle of on-device models: discovery (via HuggingFace), download, initialization, inference, and benchmarking. It features a plugin architecture via the CustomTask interface, allowing new tasks to be registered through Hilt dependency injection. Skills are defined as markdown instruction files paired with JavaScript functions executed in a WebView, enabling extensible tool use. The codebase is well-structured with Jetpack Compose UI, Proto DataStore persistence, Firebase Analytics, and a clean separation of concerns. It is a professional-grade demo application that demonstrates advanced on-device AI capabilities, though some areas (e.g., skill duplication, large ViewModels) show signs of rapid development.
The LLM identified 5 files worth highlighting for reuse:
Defines the CustomTask interface that enables a plugin system for adding new tasks (e.g., Tiny Garden, Mobile Actions, Agent Chat). Tasks are registered via Hilt @IntoSet bindings, making the system extensible without modifying core code. This pattern is reusable for any Android app needing pluggable features.
Provides a declarative pattern for defining tools (functions) that the LLM can call. Each tool has a name, description, parameters schema, and an execution context. The ToolDispatcher adds a permission layer (ask/always allow/deny) before execution. This pattern is reusable for any agentic system requiring tool registration and permission management.
A sealed class hierarchy representing all events in the agent execution loop: tokens, thinking, errors, tool calls, termination. This pattern enables type-safe event handling and is reusable for any streaming or state-machine system.
Implements DataStoreSerializer for Proto DataStore, providing type-safe persistence of app settings. This pattern is reusable for any Android app needing structured, type-safe local storage with Proto buffers.
A custom Jetpack Compose component that renders streaming markdown text with a fading effect for newly added tokens. It buffers incoming text and applies a reveal animation, demonstrating advanced Compose animation and text layout techniques. Reusable for any chat or streaming text UI.