Picture this: uncomment → Run → report (optional PDF)
The capstone is the stack from Module 3 with three student wires and a docked Kodin browser.
STEP 1ChatGroq
+
STEP 2research_web
+
STEP 3create_react_agent
→
RunFlask :7860
→
Researchin-app UI
→
STEP 4Convert to PDF
STEP 4 stays commented until you want the PDF button. The viewer is Kodin’s built-in PDF, not a Windows dialog.
🚀 Your Mission
Build the Kodin Research Agent: a Flask app that uses GPT-OSS 20B, one search tool, and LangGraph’s ReAct agent. You uncomment three lines in app.py, click Run, and chat in the in-app browser. Files are saved to Desktop/Kodin/AI-Workshop/research-agent.
Project Options
1
Research Agent (this lab)
Required. Uncomment STEP 1–3 in app.py. The agent searches the web, reasons with GPT-OSS 20B, and writes a short report in Kodin’s browser.
2
Same stack, new tool
After class: add a second @tool (calculator, date, or notes) using Modules 3 and 5. Keep one search call per question so you avoid rate limits.
3
Your own idea
Optional stretch: tutor or code-reviewer. Reuse ChatGroq, bind_tools / create_react_agent, and a tiny Flask UI like this project.
Project Specification
✓ Core Components
Agent Foundation: Uncomment ChatGroq with openai/gpt-oss-20b (STEP 1)
Tool Integration: Uncomment tools = [research_web] (STEP 2). Search is already written.
Agent Loop: Uncomment create_react_agent(llm, tools) (STEP 3)
Run in Kodin: Click Run so the UI docks in the editor (not a separate window)
Groq key: Paste gsk_… in the agent page, then click Research
Ask a question: You should get 3–5 bullets and a one-paragraph summary
Standalone: After class, run.bat / run.sh in Desktop/Kodin/AI-Workshop/research-agent
⭐ Extra Credit
Multi-agent collaboration (multiple specialized agents)
Web interface or API endpoint
Deployment to cloud (AWS/GCP/Azure)
Advanced memory features (semantic search, summarization)
Implementation Timeline
Minute 1–2: Open Practice
Confirm app.py is open and you can see STEP 1, STEP 2, STEP 3
Minute 3–5: Uncomment
Uncomment the three lines, save, click Run
Minute 6–8: Key + question
Paste Groq key, ask one research question, read the report
If it fails
Still commented STEPs → “not wired yet”. 429 → wait 10s and retry
After class
Run run.bat or run.sh from the Desktop folder without Kodin
Stretch
Add another tool or a Worker/Reviewer graph from Module 7
📚 Resources & Support
- Starter: app.py on Desktop — uncomment only, do not rewrite search
- Documentation: Review modules 1-7 for patterns and concepts
- Stack: Flask + LangGraph + langchain-groq (GPT-OSS 20B)
- Help: Re-read Modules 3 (tools) and 5 (create_react_agent)
- Path: Desktop/Kodin/AI-Workshop/research-agent
🎓 Ready to Build?
You now have all the knowledge needed to build production-grade AI agents. Start with planning, implement incrementally, test thoroughly, and iterate based on feedback.
The future of AI is agentic. Build something amazing! 🚀
Before you click Practice — Module 8 Research Agent
This capstone is an editor project, not a Jupyter notebook. Practice opens app.py on your Desktop. You uncomment three lines, click Run, and chat in Kodin’s docked browser.
Uncomment STEP 1–3→Run in Kodin→Paste Groq key in UI→Ask a research question
Files live at Desktop/Kodin/AI-Workshop/research-agent. After class you can run run.bat (Windows) or run.sh (Mac/Linux) in that folder.
Practice task 1
Open the editor project (not the leftover notebook)
AI Workshop → AI Agents → Module 8 → Practice. Kodin creates or restores the project and opens app.py. Ignore any old Module 8 notebook — the real lab is this Flask + LangGraph app.
Desktop/Kodin/AI-Workshop/research-agent/
app.py ← you edit STEP 1, 2, 3 here
templates/index.html
run.bat / run.sh ← run after closing Kodin
Expected: app.py is open in the Kodin editor with three commented STEP lines.
Why this cell: The visualizer you are reading is the briefing. Practice is wiring a real agent that searches the web and writes a short report with GPT-OSS 20B.
Practice task 2
STEP 1 — create the LLM
Find create_research_agent. Uncomment the ChatGroq line. This is the same brain as every earlier module.
def create_research_agent(api_key: str):
os.environ["GROQ_API_KEY"] = api_key
llm = None
tools = []
# STEP 1 >>> UNCOMMENT the next line
llm = ChatGroq(model="openai/gpt-oss-20b", temperature=0)
Expected: The STEP 1 line is active (no # at the start).
Why this cell: If this stays commented, there is no model. The UI will still load, but Research will fail until all three steps are live.
Practice task 3
STEP 2 — hand the agent a search tool
research_web is already written above this function (DuckDuckGo, then Wikipedia, with rate-limit handling). You only attach it to the agent.
# STEP 2 >>> UNCOMMENT the next line
tools = [research_web]
Expected: tools is a one-item list, not empty.
Why this cell: This is Module 3’s idea in production: one tool, called at most once per question so Groq 429s are less likely. You do not rewrite the search function.
Practice task 4
STEP 3 — build the ReAct agent and return it
Same helper as Module 5. Until you return it, create_research_agent returns None and the Flask route tells you to uncomment the steps.
# STEP 3 >>> UNCOMMENT the next line
return create_react_agent(llm, tools)
return None # this line is skipped once STEP 3 returns
Expected: Run succeeds and the Research Agent page appears in the in-app panel.
Why this cell: Save the file. Click Run in Kodin (not a separate browser window). The agent UI docks beside the editor at http://127.0.0.1:7860.
Practice task 5
Use the app: Groq key + Research button
Paste a Groq key in the password box (starts with gsk_). Type a question. Click Research. The key is stored in the page’s localStorage for the next question.
# Flask /ask (already written — you do not edit this)
agent = create_research_agent(api_key)
result = agent.invoke(
{"messages": [("user", "...Question: {question}")]},
config={"recursion_limit": 6},
)
- Model:
openai/gpt-oss-20b (same as notebooks 1–7).
- Tool:
research_web — at most one search per question.
- After Kodin: double-click
run.bat in the same folder.
Expected: A short report with 3–5 bullets and a summary paragraph.
Why this cell: If you see “agent is not wired yet”, a STEP line is still commented. If you see 429, wait ~10 seconds and click Research again. Search is best-effort: if the web is rate-limited, the model still writes a report from general knowledge.
Practice task 6
Optional — Convert the summary to PDF
After STEPs 1–3 work, uncomment STEP 4 in app.py. Save and click Run. A Convert to PDF button appears. It calls summary_to_pdf() and opens the report in Kodin’s built-in PDF viewer (same viewer as View in the editor). Native print/save dialogs are not used.
# STEP 4 >>> UNCOMMENT the next line to show Convert to PDF
ENABLE_PDF_EXPORT = True
Expected: Convert to PDF appears, then the formatted report opens in the Kodin PDF viewer.
Why this cell: The PDF function is already written. You only turn the button on. The file is saved as research-report.pdf next to app.py.