Welcome to Phase 3 of the Agentic AI course! This lab focuses on moving from a simple LLM Chatbot to a sophisticated ReAct Agent with industry-standard monitoring.
Copy the .env.example to .env and fill in your API keys:
cp .env.example .envpip install -r requirements.txtsrc/tools/: Extension point for your custom tools.
If you don't want to use OpenAI or Gemini, you can run open-source models (like Phi-3) directly on your CPU using llama-cpp-python.
Download the Phi-3-mini-4k-instruct-q4.gguf (approx 2.2GB) from Hugging Face:
- Phi-3-mini-4k-instruct-GGUF
- Direct Download: phi-3-mini-4k-instruct-q4.gguf
Create a models/ folder in the root and move the downloaded .gguf file there.
Change your DEFAULT_PROVIDER and set the path:
DEFAULT_PROVIDER=local
LOCAL_MODEL_PATH=./models/Phi-3-mini-4k-instruct-q4.gguf- Baseline Chatbot: Observe the limitations of a standard LLM when faced with multi-step reasoning.
- ReAct Loop: Implement the
Thought-Action-Observationcycle insrc/agent/agent.py. - Provider Switching: Swap between OpenAI and Gemini seamlessly using the
LLMProviderinterface. - Failure Analysis: Use the structured logs in
logs/to identify why the agent fails (hallucinations, parsing errors). - Grading & Bonus: Follow the SCORING.md to maximize your points and explore bonus metrics.
The code is designed as a Production Prototype. It includes:
- Telemetry: Every action is logged in JSON format for later analysis.
- Robust Provider Pattern: Easily extendable to any LLM API.
- Clean Skeletons: Focus on the logic that matters—the agent's reasoning process.
This repo now includes a local prototype for processing sales emails that request quotes or orders.
- Tools live in
src/tools/sales_mail_tools.py. - Local fixtures live in
data/. - The baseline chatbot lives in
src/baseline/chatbot.py. - The default demo provider is OpenAI via
OPENAI_API_KEY. - A deterministic mock provider lives in
src/core/mock_provider.py, so the demo can still run without API keys.
Run the demo with OpenAI gpt-4o-mini:
python scripts/run_sales_mail_demo.py --provider openai --model gpt-4o-miniRun one email only:
python scripts/run_sales_mail_demo.py --provider openai --model gpt-4o-mini --email-id email_001Run offline with the mock provider:
python scripts/run_sales_mail_demo.py --provider mockRun tests:
python -m pytest -qThe demo compares the chatbot baseline with the ReAct Agent and writes results to report/sales_mail_demo_results.json.
Happy Coding! Let's build agents that actually work.