This repo was originally created for a talk at droidcon SF 2023. The session page has details of what was presented.
The chat demo is based on the Jetpack Compose Jetchat sample from Google.
You'll need to add various service keys to Constants.kt to light everything up:
- jetchat-ai - open chat with weather function. Start message with "image of" to generate a picture.
- droidcon-chat - guided chat with embeddings and functions based on the droidcon SF conference schedule.
- There's also a PaLM-based chat channel hiding in there too ๐
The Jetchat-AI demo has been built up over a few months to be a 'first principles' demonstration of incorporating an LLM chat into an Android app using Kotlin. Over time it has grown to include image generation API, function calling, embeddings and RAG pattern, sliding window for token limit, and conversation memory.
Blogpost | Notes |
---|---|
Jetchat with OpenAI on Android | Build an OpenAI-powered chat with the Jetchat Jetpack Compose sample using the chat and image APIs |
JetchatAI improvements: error handling and animations | Add error handling and useability tweaks to JetchatAI |
JetchatAI gets smarter with embeddings | Generate embeddings for an entire conference so we can chat about the schedule |
OpenAI chat functions on Android | Implement the canonical getWeather chat function in Kotlin |
Coming OpenAI function calls with embeddings | Add date/time grounding and implement functions to return conference info by time |
Chat memory with OpenAI functions | Add a Sqlite database to store 'favorite sessions' and implement chat functions to store, delete, and retrieve the favorites list |
Embedding vector caching | Store embedding vectors in Sqlite on device |
Dynamic Sqlite queries with OpenAI chat functions | Implement the canonical askDatabase chat function using a simple conference sessions schema |
Prompt engineering tips | Some prompt engineering lessons learned on the JetchatAI project |
OpenAI and token limits | Brief discussion on tokens which leads into the next few posts on managing limited context |
Infinite chat using a sliding window | Avoid token limit errors with a sliding window on the chat history |
De-duplicating context in the sliding window | Make the sliding window a little more efficient by removing duplicate grounding info |
"Infinite" chat with history summarization | Squeeze more historical context in by summarizing the oldest messages to fit more in the window |
Infinite chat with history embeddings | Create embeddings of the messages to act as conversation memory |