pocketflow/cookbook/pocketflow-agent
zachary62 1d560e7737 add demo notebook 2025-03-23 12:07:37 -04:00
..
README.md add supervisor 2025-03-20 17:59:34 -04:00
demo.ipynb add demo notebook 2025-03-23 12:07:37 -04:00
flow.py add tutorial 2025-03-19 12:50:49 -04:00
main.py add tutorial 2025-03-19 12:50:49 -04:00
nodes.py Fixed yaml formatting issues, save context for action = answer 2025-03-22 03:08:28 +05:30
requirements.txt update rag tutorial 2025-03-21 13:37:28 -04:00
utils.py add tutorial 2025-03-19 12:50:49 -04:00

README.md

Research Agent

This project demonstrates a simple yet powerful LLM-powered research agent. This implementation is based directly on the tutorial: LLM Agents are simply Graph — Tutorial For Dummies.

Features

  • Performs web searches to gather information
  • Makes decisions about when to search vs. when to answer
  • Generates comprehensive answers based on research findings

Getting Started

  1. Install the packages you need with this simple command:
pip install -r requirements.txt
  1. Let's get your OpenAI API key ready:
export OPENAI_API_KEY="your-api-key-here"
  1. Let's do a quick check to make sure your API key is working properly:
python utils.py

This will test both the LLM call and web search features. If you see responses, you're good to go!

  1. Try out the agent with the default question (about Nobel Prize winners):
python main.py
  1. Got a burning question? Ask anything you want by using the -- prefix:
python main.py --"What is quantum computing?"

How It Works?

The magic happens through a simple but powerful graph structure with three main parts:

graph TD
    A[DecideAction] -->|"search"| B[SearchWeb]
    A -->|"answer"| C[AnswerQuestion]
    B -->|"decide"| A

Here's what each part does:

  1. DecideAction: The brain that figures out whether to search or answer
  2. SearchWeb: The researcher that goes out and finds information
  3. AnswerQuestion: The writer that crafts the final answer

Here's what's in each file:

  • main.py: The starting point - runs the whole show!
  • flow.py: Connects everything together into a smart agent
  • nodes.py: The building blocks that make decisions and take actions
  • utils.py: Helper functions for talking to the LLM and searching the web