These examples show how to make chatbots with marimo, using mo.ui.chat
.
custom.py
shows how to make a custom chatbot.openai_example.py
shows how to make a chatbot powered by OpenAI models.anthropic_example.py
shows how to make a chatbot powered by Anthropic models.gemini.py
shows how to make a chatbot powered by Google models like Gemini.groq_example.py
shows how to make a chatbot powered by Groq models.mlx_chat.py
shows a simple chatbot using local on-device models with Apple's MLX, a machine learning framework from Apple that is similar to JAX and PyTorch. This specific example uses the mlx-lm library. Note that Apple Silicon chips are required for using MLX.llm_datasette.py
shows how to make a chatbot powered by Simon W's LLM library.dagger_code_interpreter.py
shows how to make a basic code-interpreter chatbot powered by Dagger containers.recipe_bot.py
shows how to make a chatbot that can parse recipes from images.simplemind_example.py
shows how to integrate simplemind.generative_ui.py
shows how to make a chatbot that can generate UI code.
Chatbot's in marimo are reactive: when the chatbot responds with a message,
all other cells referencing the chatbot are automatically run or marked
stale, with the chatbot's response stored in the object's value
attribute.
You can use this to make notebooks that respond to the chatbot's response
in arbitrary ways. For example, you can make agentic notebooks!
Once you understand the basics, for a more interesting example, check out
our notebook that lets you talk to any GitHub repo,
powered by storia-ai/sage. This example demonstrates advanced usage
of ui.chat
, using langchain
to construct a RAG-powered chatbot, served by
an async generator callback function.
The requirements of each notebook are serialized in them as a top-level comment. Here are the steps to open an example notebook:
- Install marimo
- Install
uv
- Open an example with
marimo edit --sandbox <notebook.py>
.
Tip
The --sandbox
flag opens the notebook in an isolated virtual environment,
automatically installing the notebook's dependencies 📦
You can also open notebooks without uv
, with just marimo edit <notebook.py>
;
however, you'll need to install the requirements yourself.