Example applicationThis example creates a full web application that provides a chat interface for querying ClickHouse data.
You can find the source code for this example in the examples repository.
Prerequisites
- You’ll need to have Python installed on your system.
You’ll need to have
uvinstalled - You’ll need an Anthropic API key, or API key from another LLM provider
1
Install libraries
Install the required libraries by running the following commands:
2
Create utilities file
Create a
utils.py file with two utility functions. The first is an
asynchronous function generator for handling stream responses from the
Agno agent. The second is a function for applying styles to the Streamlit
application:utils.py
3
Setup credentials
Set your Anthropic API key as an environment variable:
Using another LLM providerIf you don’t have an Anthropic API key, and want to use another LLM provider,
you can find the instructions for setting up your credentials in the Agno “Integrations” docs
4
Import required libraries
Start by creating your main Streamlit application file (e.g.,
app.py) and add the imports:5
Define the agent streaming function
Add the main agent function that connects to ClickHouse’s SQL playground and streams responses:
6
Add synchronous wrapper functions
Add helper functions to handle async streaming in Streamlit:
7
Create the Streamlit interface
Add the Streamlit UI components and chat functionality:
8
Run the application
To start your ClickHouse AI agent web application you can run the
following command from your terminal:This will open your web browser and navigate to
http://localhost:8501 where you
can interact with your AI agent and ask it questions about the example datasets
available in ClickHouse’s SQL playground.