Three implementations of the same travel planning AI agent, each built with a different approach:
| File | Approach |
|---|---|
agent_python.py |
Plain Python — manual agent loop, no framework |
agent_langchain.py |
LangChain — framework handles the loop |
agent_pydantic_ai.py |
Pydantic AI — minimal, decorator-based |
Each agent can search the web (via Serper) and answer travel planning questions.
python3 -m venv .venvActivate it:
# macOS / Linux
source .venv/bin/activate
# Windows
.venv\Scripts\activatepip install -r requirements.txtYou need two API keys:
- GROQ_API_KEY — free LLM inference. Get one at console.groq.com
- SERPER_API_KEY — Google search API. Get one at serper.dev
Open each Python file and replace the placeholder values near the top (under STEP 0 — Configuration):
os.environ["GROQ_API_KEY"] = "your-groq-api-key"
os.environ["SERPER_API_KEY"] = "your-serper-api-key"Plain Python agent:
python agent_python.pyLangChain agent:
python agent_langchain.pyPydantic AI agent:
python agent_pydantic_ai.py