chatbot-app
Multi-provider LangChain reference app
A conversational AI stack you can actually read
One LangChain/LangGraph core, four interchangeable chat providers, a CLI and a FastAPI service, optional local RAG, and an agent whose tool calls never run without your approval.
$
python
src/main.py
--agent
LLM_PROVIDER=gemini | tools: web_search, calculator, read_doc
You: What's 12 * 37, and check docs/sample-faq.md for the refund policy?
Pending tool calls:
1. calculator(expression="12 * 37")
2. read_doc(path="sample-faq.md")
Approve tool call? [y/N]: y
calculator → 444
read_doc → 3 matching chunks
Assistant: 12 * 37 is 444. Per [source: sample-faq.md], refunds are accepted within 30 days of purchase.
How it works
From one env var to a grounded, approved reply
The same LCEL chain and agent graph power both the CLI and the REST API.
01
Configure provider
LLM_PROVIDER selects Gemini, OpenAI, Anthropic, or Ollama. llm_provider.get_llm() validates only that provider's own requirements and fails fast if unmet.02
Build the chain
chain_builder.py assembles the shared LCEL prompt-and-model pipeline used by both the CLI and api/main.py.03
Optional RAG retrieval
Pass
--rag to ground answers in local docs/ files via a persisted Chroma store, cited as [source: filename].04
Optional agent tool use
Pass
--agent to let the model call web_search, calculator, or read_doc — nothing executes until you approve it.05
Response
The reply returns to the CLI or REST client, and the turn is saved to
sessions/<id>.json.Providers
One interface, four chat model backends
Every provider validates only its own requirements at startup and fails fast with an actionable message if something's missing.
GEMINI
Google Gemini (default)
Requires
GEMINI_API_KEY and either --model or GEMINI_LLM_MODEL — the only provider with no hardcoded default.Default model: none — must be set explicitly
OPENAI
OpenAI
Requires
OPENAI_API_KEY — the same key also covers OpenAI-backed RAG embeddings.Default model: gpt-4o-mini
ANTHROPIC
Anthropic
Requires
ANTHROPIC_API_KEY, via the langchain-anthropic integration.Default model: claude-3-5-haiku-latest
OLLAMA
Ollama (local)
No cloud key — checks the server is reachable and the model is pulled, failing fast with the exact
ollama pull fix if not.Default model: llama3.2:3b
Installation
Up and running in four commands
Prerequisites: Python 3.11+ and a credential for one cloud provider — or a local Ollama install.
# 1. Create and activate a virtual environment python -m venv .venv source .venv/bin/activate # 2. Install runtime dependencies pip install -r requirements.txt # 3. Configure a provider cp .env.example .env # 4. Start the CLI python src/main.py
Reference
Endpoints, tools, and how it stays safe
Full details live in the docs so this page stays a landing page, not a manual.