From 1a6861801c4f180532e014a9076ca50e822f9e9d Mon Sep 17 00:00:00 2001 From: zachary62 Date: Wed, 19 Mar 2025 12:55:38 -0400 Subject: [PATCH] update readme --- cookbook/pocketflow-agent/README.md | 70 +++++++++++++++-------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/cookbook/pocketflow-agent/README.md b/cookbook/pocketflow-agent/README.md index 29a1b25..8639597 100644 --- a/cookbook/pocketflow-agent/README.md +++ b/cookbook/pocketflow-agent/README.md @@ -1,77 +1,80 @@ # PocketFlow Research Agent - Tutorial for Dummy -This project demonstrates a simple LLM-powered research agent built with PocketFlow, a minimalist LLM framework in 100 lines. For more information on PocketFlow and how to build LLM agents, check out: +This project demonstrates a simple yet powerful LLM-powered research agent built with PocketFlow, a minimalist LLM framework in just 100 lines of code! -- [LLM Agents are simply Graph — Tutorial For Dummies](https://zacharyhuang.substack.com/p/llm-agent-internal-as-a-graph-tutorial) +> 📝 **Note:** This implementation is based directly on the tutorial post [LLM Agents are simply Graph — Tutorial For Dummies](https://zacharyhuang.substack.com/p/llm-agent-internal-as-a-graph-tutorial). Check it out for a better understanding of the concepts! + +Want to learn more about PocketFlow and building cool LLM agents? Check out: - [PocketFlow GitHub](https://github.com/the-pocket/PocketFlow) - [PocketFlow Documentation](https://the-pocket.github.io/PocketFlow/) -## What It Does +## ✨ What Can This Agent Do? -This agent can: -1. Answer questions by searching for information when needed -2. Make decisions about when to search and when to answer -3. Generate helpful responses based on collected research +This friendly little agent can: +1. 🔎 Search the web for information when it needs more context +2. 🧠 Decide intelligently when to search and when it has enough info to answer +3. 📝 Generate helpful, informative responses based on its research -## Setting Up +## 🚀 Getting Started -### Prerequisites -- Python 3.8+ -- OpenAI API key +### What You'll Need +- Python 3.8 or newer +- An OpenAI API key (don't worry, we'll help you set this up!) -### Installation +### Easy Installation -1. Install the required packages: +1. Install the packages you need with this simple command: ```bash pip install -r requirements.txt ``` -## Structure +## 📂 Project Structure -- [`main.py`](./main.py): Entry point and user interface -- [`flow.py`](./flow.py): Creates and connects the agent flow -- [`nodes.py`](./nodes.py): Defines the decision and action nodes -- [`utils.py`](./utils.py): Contains utility functions for LLM calls and web searches +Here's what's in each file: +- [`main.py`](./main.py): The starting point - runs the whole show! +- [`flow.py`](./flow.py): Connects everything together into a smart agent +- [`nodes.py`](./nodes.py): The building blocks that make decisions and take actions +- [`utils.py`](./utils.py): Helper functions for talking to the LLM and searching the web -## Quick Start Guide +## 🏃‍♂️ Quick Start Guide -### Step 1: Set Up Your OpenAI API Key +### Step 1: Set Up Your API Key -First, you must provide your OpenAI API key: +First, let's get your OpenAI API key ready: ```bash export OPENAI_API_KEY="your-api-key-here" ``` -### Step 2: Test Utilities +### Step 2: Make Sure Everything Works -Verify that your API key is working by testing the utilities: +Let's do a quick check to make sure your API key is working properly: ```bash python utils.py ``` -This will test both the LLM call functionality and the web search capability. +This will test both the LLM call and web search features. If you see responses, you're good to go! -### Step 3: Run the Agent +### Step 3: Run Your Agent -Run the agent with the default question ("Who won the Nobel Prize in Physics 2024?"): +Try out the agent with the default question (about Nobel Prize winners): ```bash python main.py ``` -### Step 4: Ask Custom Questions +### Step 4: Ask Your Own Questions -To ask your own question, use the `--` prefix: +Got a burning question? Ask anything you want by using the `--` prefix: ```bash python main.py --"What is quantum computing?" ``` -## How It Works +## 🧩 How It Works -The agent is structured as a simple directed graph with three main nodes: +The magic happens through a simple but powerful graph structure with three main parts: ```mermaid graph TD @@ -80,6 +83,7 @@ graph TD B -->|"decide"| A ``` -1. **DecideAction**: Determines whether to search for information or provide an answer -2. **SearchWeb**: Searches the web for information -3. **AnswerQuestion**: Creates a final answer once enough information is gathered +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 \ No newline at end of file