Skip to content

A demonstration of the ReAct (Reasoning + Acting) agent pattern using LangChain, implementing a simple string length calculator.

Notifications You must be signed in to change notification settings

redrussianarmy/react-agent-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReAct Agent Calculator

A sophisticated implementation of the ReAct (Reasoning + Acting) agent pattern using LangChain, designed for string length calculations with high accuracy and reliability.

📚 Table of Contents

✨ Features

  • Advanced ReAct agent implementation with LangChain
  • High-precision string length calculation
  • Robust error handling and validation
  • Environment-based configuration management
  • Comprehensive logging system
  • Extensive test coverage

🛠️ Technologies

  • Python 3.8+
  • LangChain Framework
  • OpenAI GPT Models
  • pytest for Testing
  • python-dotenv for Configuration

🚀 Getting Started

Prerequisites

  • Python 3.8 or higher
  • OpenAI API key
  • Git

Installation

  1. Clone the repository:
git clone https://github.com/redrussianarmy/react-agent-calculator.git
cd react-agent-calculator
  1. Create and activate virtual environment:
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Configure environment:
cp .env.example .env
# Edit .env with your OpenAI API key

📁 Project Structure

react-agent-calculator/
├── src/
│   ├── agents/          # Agent implementation
│   ├── tools/           # Utility tools
│   └── utils/           # Helper functions
├── tests/               # Test suite
├── .env                 # Environment configuration
├── main.py             # Entry point
└── requirements.txt     # Dependencies

💻 Usage

from src.agents.react_agent import ReActAgent
from src.agents.config import AgentConfig

# Configure agent
config = AgentConfig(
    model_name="gpt-3.5-turbo",
    temperature=0.7
)

# Initialize and run
agent = ReActAgent(config)
result = agent.run("Calculate length: 'Hello, World!'")
print(result)

🧪 Testing

Run tests:

# All tests
pytest

# With coverage
pytest --cov=src tests/

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push branch (git push origin feature/amazing-feature)
  5. Open Pull Request

👥 Authors

  • Hakan BOGAN - Initial work and maintenance

🙏 Acknowledgments

  • LangChain team for the excellent framework
  • OpenAI for providing powerful language models
  • Open source community for inspiration and support

📄 License

This project is currently unlicensed.

About

A demonstration of the ReAct (Reasoning + Acting) agent pattern using LangChain, implementing a simple string length calculator.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages