Mesop — Build AI Apps Fast with Python UI
Google's Python UI framework for rapidly building AI demos and internal tools. Declarative components, hot reload. 6.5K+ stars.
What it is
Mesop is an open-source Python UI framework created by Google for building AI applications quickly. It provides pre-built components for common AI app patterns -- chat interfaces, text input/output flows, and interactive dashboards -- that you compose with Python decorators and functions. The framework runs a web server and renders the UI in the browser.
It targets AI engineers and researchers who want to build interactive demos and internal tools for their models without learning frontend development.
How it saves time or tokens
Mesop provides ready-made AI app patterns out of the box. A chat interface that would take hours to build in React takes a few lines of Mesop code. The framework handles state management, event handling, and rendering automatically. For AI teams, this means faster prototyping: you can wrap any model behind a user-friendly interface in minutes and share it with stakeholders.
How to use
- Install and create an app:
pip install mesop
- Build a simple page:
import mesop as me
@me.page(path='/')
def home():
me.text('Welcome to my AI App')
me.button('Get Started', on_click=lambda e: me.navigate('/chat'))
me.run()
- Build a chat interface:
import mesop as me
import mesop.labs as mel
def respond(query: str, history: list) -> str:
# Connect to your LLM here
return f'You asked: {query}'
@me.page(path='/chat')
def chat_page():
mel.chat(respond, title='AI Assistant')
Example
import mesop as me
import mesop.labs as mel
from openai import OpenAI
client = OpenAI()
def ai_respond(query: str, history: list) -> str:
messages = [{'role': 'user', 'content': query}]
for h in history:
messages.insert(0, {'role': h['role'], 'content': h['content']})
response = client.chat.completions.create(
model='gpt-4o',
messages=messages
)
return response.choices[0].message.content
@me.page(path='/')
def main():
mel.chat(
ai_respond,
title='AI Chat Demo',
bot_user='Assistant'
)
Related on TokRepo
- AI tools for coding -- Developer tools for AI applications
- Featured workflows -- Curated tools and frameworks
Common pitfalls
- Mesop is optimized for prototyping and internal tools. For high-traffic production apps with complex UIs, a full framework like Next.js or Reflex may be more appropriate.
- The component library is focused on common AI app patterns. Custom or highly styled UIs may require workarounds or CSS overrides.
- Mesop's state model re-renders the entire page on state changes. For apps with frequent updates (like streaming), this can cause flickering if not handled carefully.
Frequently Asked Questions
Yes. Mesop is an open-source project created by Google engineers. It is used internally at Google for building AI demos and prototypes. The project is open-source and available on GitHub for anyone to use.
Both are Python UI frameworks for building AI apps. Mesop provides a component-based architecture with explicit state management, while Streamlit uses a simpler script-based model. Mesop offers more control over layout and interaction patterns, especially for chat interfaces.
Yes. Mesop supports streaming through its chat component. You can yield partial responses to update the UI progressively as the LLM generates output. This creates a natural chat experience where the user sees the response appear word by word.
Yes. You define multiple pages using the @me.page decorator with different path parameters. Mesop handles routing between pages. You can create multi-page apps with navigation menus, sidebars, and shared layout components.
Yes. Mesop apps are standard Python web servers that can be deployed to any cloud platform. Google Cloud Run, Railway, Render, and Docker-based deployments all work. The app serves on a configurable port and works behind reverse proxies.
Citations (3)
- Mesop GitHub Repository— Mesop is an open-source Python UI framework by Google
- Mesop Documentation— Mesop provides pre-built AI app patterns including chat interfaces
- Google AI Blog— Rapid prototyping frameworks accelerate AI application development
Related on TokRepo
Source & Thanks
Created by Google / Mesop Dev. Licensed under Apache-2.0.
mesop — ⭐ 6,500+
Discussion
Related Assets
code-simplifier — Anthropic Official Cleanup Subagent
Anthropic's open-source post-task cleanup agent that Boris Cherny runs after every Claude Code session. Refactors for clarity without changing behavior.
Ralph Wiggum — Anthropic Official Autonomous Loop Plugin
Official Anthropic plugin that turns Claude Code into an autonomous loop. Adds /ralph-loop and /cancel-ralph for long-running self-improving task execution.