Python scripts exploring LangChain and LangGraph for AI agent development, with a focus on Pokémon card price analysis. These are standalone experiments and learning exercises — not production code.
| Script | Description |
|---|---|
langchain-agent.py |
Basic LangGraph agent using Claude. A starting point for tool-using agents with create_react_agent. |
langchain-agent-v2.py |
Extended version with conversation memory (InMemorySaver) for multi-turn interactions. |
agent-api.py |
LangGraph agent wrapped in a FastAPI server. Accepts chat via REST, maintains state per thread_id. |
price-analysis-agent.py |
Pokémon card price analyzer using the Anthropic SDK directly (not LangChain). Loads historical JSON, runs Claude analysis on trends. |
historic-pricing-script.py |
Fetches historical pricing from the Pokémon TCG API (via RapidAPI) and saves as JSON. |
get-historic-pricing-v2.py |
Updated version of the above with expanded set coverage. |
test_setup.py |
Validates environment setup and API key configuration. |
verify_data_parsing.py |
Tests data parsing logic against sample JSON output. |
LangGraph ReAct pattern — create_react_agent handles the think→act→observe loop automatically,
but you need to be intentional about when to use tool-calling vs. direct completion.
InMemorySaver for conversation state — trivial to add multi-turn memory to a LangGraph agent,
but the state is lost on process restart. For persistent memory, you'd need a database checkpointer.
FastAPI + LangGraph (agent-api.py) — wrapping an agent as an HTTP service is straightforward.
The key insight: thread_id in the config is how LangGraph separates conversation state across
concurrent users.
Direct Anthropic SDK vs. LangChain — price-analysis-agent.py intentionally bypasses LangChain
and calls the Anthropic API directly. It's simpler for single-turn analysis tasks where you don't
need the agent loop overhead.
pip install -r requirements.txtCreate a .env file:
ANTHROPIC_API_KEY=sk-ant-...
POKEMON_TCG_API_KEY=... # Required for historic-pricing-script.py only# Run basic agent
python langchain-agent.py
# Start agent API server
uvicorn agent-api:app --reload
# POST http://localhost:8000/chat
# {"message": "What's a Charizard worth?", "thread_id": "user-1"}
# Run price analysis (uses Anthropic SDK directly)
python price-analysis-agent.py- Python 3.10+
- See
requirements.txt