Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/EllisYuan/ChatAgents/llms.txt

Use this file to discover all available pages before exploring further.

By the end of this guide you will have both the FastAPI backend and the Streamlit frontend running on your machine, your API keys wired in, and a live conversation with an AI agent that can search the web, extract page content, and crawl sites in real time — all in under five minutes.
Prefer a one-command start? Docker Compose brings up both services with a single docker-compose up -d --build. See the Docker Deployment page for details.

Setup

1

Clone the repository

Pull the source code from GitHub and change into the project directory:
git clone https://github.com/EllisYuan/ChatAgents.git
cd ChatAgents
2

Create and activate a virtual environment

Isolating dependencies in a virtual environment avoids conflicts with other Python projects on your machine.
python3 -m venv venv
source venv/bin/activate
Your shell prompt will gain a (venv) prefix once the environment is active.
3

Install dependencies

Install all required Python packages from the pinned requirements file:
pip install -r requirements.txt
This installs Streamlit, FastAPI, LangGraph, Tavily client libraries, Anthropic SDK, and all transitive dependencies.
4

Configure environment variables

Copy the provided sample file and fill in your API keys:
cp .env.sample .env
Open .env in your editor. The file looks like this:
# ==================== API Keys ====================
# Anthropic Claude API key
ANTHROPIC_API_KEY=填你claude API

# Tavily API key (used for web search)
TAVILY_API_KEY=填你tavily API

# OpenAI API key (optional — only needed for OpenAI models)
OPENAI_API_KEY=sk-your-key-here

# Groq API key (optional — only needed for Groq models)
GROQ_API_KEY=gsk_your-key-here

# ==================== Service Port Configuration ====================
# Host ports Docker maps to (optional — defaults shown)
# BACKEND_PORT=8080
# FRONTEND_PORT=8501

# ==================== Frontend → Backend URL ====================
# docker-compose.yml sets BACKEND_URL=http://backend:8080 automatically.
# For local development (non-Docker), use:
# BACKEND_URL=http://localhost:8080
VariableDescriptionRequired
ANTHROPIC_API_KEYYour Claude API key (sk-ant-api-…)✅ Yes
TAVILY_API_KEYYour Tavily search key (tvly-…)✅ Yes
OPENAI_API_KEYOpenAI key for GPT models❌ Optional
GROQ_API_KEYGroq key for Groq-hosted models❌ Optional
PORTPort the FastAPI backend listens onDefaults to 8080
BACKEND_PORTHost port Docker maps to the backendDefaults to 8080
FRONTEND_PORTHost port Docker maps to the frontendDefaults to 8501
BACKEND_URLURL the frontend uses to reach the backendDefaults to http://localhost:8080
5

Start the backend

In your first terminal, launch the FastAPI server:
python app.py
The server starts on port 8080 by default (controlled by the PORT environment variable). You should see log output confirming the Web Agent has initialised:
INFO:     Started server process
INFO:     Waiting for application startup.
INFO:     正在初始化 Web 智能体...
INFO:     Web 智能体初始化完成
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8080
6

Start the frontend

Open a second terminal (keep the first one running the backend), activate the virtual environment again, then launch Streamlit:
streamlit run streamlit_app.py
Streamlit starts on port 8501. Your default browser should open automatically, or you will see:
You can now view your Streamlit app in your browser.
Local URL:  http://localhost:8501
7

Open the app in your browser

Navigate to the following URLs to confirm everything is running:
ServiceURL
Chat interface (Streamlit)http://localhost:8501
Backend API root (FastAPI)http://localhost:8080
Interactive API docs (Swagger UI)http://localhost:8080/docs
The FastAPI backend auto-generates a Swagger UI at http://localhost:8080/docs. You can use it to inspect every endpoint, view request/response schemas, and send test requests — no extra tooling needed.

Using the Chat Interface

Once the app is open in your browser, here is how to get your first response:

1. Enter your API keys in the sidebar

If you pre-configured .env, your keys are already loaded and the sidebar will show the backend as Running. If not, paste your Claude and Tavily API keys directly into the sidebar input fields — they are sent as request headers and are never stored server-side.

2. Select an agent mode

Use the mode selector in the sidebar to choose between:
  • ⚡ Fast Modebasic search depth, 3 results, crawl limit 5 pages. Best for quick factual lookups.
  • 🧠 Deep Thinking Modeadvanced search depth, 5 results, crawl limit 15 pages, image support. Best for in-depth research.

3. Choose a language model

Pick a Claude model from the dropdown:
ModelCharacteristics
HaikuFastest, most economical
SonnetBalanced performance — recommended
OpusHighest capability, highest cost
OpenAI and Groq models are also available if you supplied those API keys.

4. Start chatting

Type your question in the input box and press Enter. The agent will:
  1. Decide which tools (if any) it needs — TavilySearch, TavilyExtract, or TavilyCrawl.
  2. Display each tool call inline as it happens, showing the tool name, inputs, and a summary of outputs with source links.
  3. Stream the final answer token-by-token directly into the chat window.
To start a fresh conversation without the previous context, click New Session in the sidebar.

Build docs developers (and LLMs) love