Skip to main content

A lightweight, observable ReAct Agent framework

Project description

ReActFlow

A lightweight, observable ReAct Agent framework

中文文档 | English

FeaturesInstallationQuick StartDocumentationContributing


Features

  • 🚀 5-minute setup - Get started with minimal code
  • 🔍 Fully observable - Track every thought, action, and observation
  • 💰 Cost transparent - Real-time token usage and cost tracking
  • 🛠 Easy customization - Define tools with simple decorators
  • 🔄 Loop detection - Automatic detection of stuck agents
  • 📦 Zero dependencies core - Minimal dependencies for maximum flexibility

Installation

pip install reactflow

Quick Start

Basic Usage

from reactflow import Agent, Tool

# Define a custom tool
@Tool.define
def search(query: str) -> str:
    """Search for information"""
    return f"Results for: {query}"

# Create an agent
agent = Agent(tools=[search])

# Run a task
result = agent.run("What is the capital of France?")
print(result.answer)

CLI Usage

# Run a single task
reactflow run "Calculate 25 * 17"

# Start interactive mode
reactflow interactive

# Export trajectory
reactflow run "What is Python?" --export trajectory.json

Built-in Tools

ReActFlow comes with several built-in tools:

Tool Description
search Search for information
calculator Evaluate mathematical expressions
datetime Get current date and time
text_analyzer Analyze text in various ways

Custom Tools

Create custom tools easily:

from reactflow import Tool

@Tool.define
def my_tool(query: str, count: int = 5) -> str:
    """
    My custom tool description.

    Args:
        query: The search query
        count: Number of results

    Returns:
        The result string
    """
    return f"Found {count} results for '{query}'"

# Use it
agent = Agent(tools=[my_tool])

Tracking Execution

Every execution generates a complete trajectory:

result = agent.run("What is 2+2?")

# Get the trajectory
trajectory = agent.get_trajectory()

# Export as Markdown
trajectory.export("my_trajectory.md", format="markdown")

# Or as JSON
trajectory.export("my_trajectory.json", format="json")

Configuration

agent = Agent(
    tools=[search, calculator],
    model="gpt-4",           # LLM model
    max_steps=10,            # Maximum reasoning steps
    debug=True,              # Enable debug output
    temperature=0.7,         # LLM temperature
)

Architecture

ReActFlow Architecture
│
├── Agent              # Main interface
│   ├── Engine         # ReAct execution loop
│   ├── Tools          # Tool registry and execution
│   ├── State          # Execution state tracking
│   └── Memory         # Conversation memory
│
└── CLI                # Command-line interface

Why ReActFlow?

ReActFlow Other Frameworks
5 lines to start 20+ lines of setup
Full observability Black box execution
Debug-friendly Hard to trace issues
Cost transparent Unknown token usage
Minimal dependencies Heavy dependency chains

Academic Reference

This framework implements the ReAct (Reasoning + Acting) paradigm from the following paper:

ReAct: Synergizing Reasoning and Acting in Language Models

Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R. Narasimhan, Yuan Cao

ICLR 2023

Paper: https://arxiv.org/abs/2210.03629

@inproceedings{yao2023react,
  title={ReAct: Synergizing Reasoning and Acting in Language Models},
  author={Yao, Shunyu and Zhao, Jeffrey and Yu, Dian and Du, Nan and Shafran, Izhak and Narasimhan, Karthik R and Cao, Yuan},
  booktitle={International Conference on Learning Representations (ICLR)},
  year={2023}
}

License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2024 AI Agent Research Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

Contributing

We welcome contributions! Please see our Contributing Guide for details.


Made with ❤️ by AI Agent Research Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reactflow-0.1.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reactflow-0.1.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file reactflow-0.1.0.tar.gz.

File metadata

  • Download URL: reactflow-0.1.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for reactflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e914bc3dfa935811c4f9df0ef09e4636182443cb3bd546cd1a68be45486c7cd6
MD5 e33a8fd85fd36c665146f4b5770dfb23
BLAKE2b-256 5690b5c333170a470b148387a9390072c2d8c35107a60b59e274ee51ab2d0932

See more details on using hashes here.

File details

Details for the file reactflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: reactflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for reactflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90624805fe29075cadd5a0ec5a359a1818f5429946d09d6a36f318a14479feb9
MD5 69067b6bbb09b614334eac754c705bba
BLAKE2b-256 3c8457b420d377a0b9d647d0963e6d50bac159ab338e05186eb5e30b8a7a7583

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page