Skip to content

gsavla6-hue/langchain-custom-agent-framework

Repository files navigation

🤖 Langchain Custom Agent Framework

Production LangChain agent framework with custom tool creation, streaming output, async execution, observability tracing and comprehensive error recovery

Python OpenAI License

python langchain openai custom-agents streaming observability

🚀 Quick Start

# 1. Clone
git clone https://github.com/gsavla6-hue/langchain-custom-agent-framework.git
cd langchain-custom-agent-framework

# 2. Install
pip install -r requirements.txt

# 3. Configure
cp .env.example .env
# Edit .env — add your OPENAI_API_KEY

# 4. Run
python main.py                    # Interactive CLI
python main.py --task "your task" # Single task
python main.py --api              # REST API

✨ Features

  • Autonomous Execution — Breaks complex tasks into steps and executes them
  • Tool Use — Web search, code execution, file operations
  • Multi-turn Memory — Remembers context across conversation
  • REST API — FastAPI server with /run, /chat, /stats endpoints
  • Streaming — Real-time output streaming support
  • Production Ready — Error handling, retries, logging

🔌 API Usage

# Start API server
python main.py --api

# Run a task
curl -X POST http://localhost:8000/run \
  -H "Content-Type: application/json" \
  -d '{"task": "Research the latest developments in quantum computing"}'

# Chat
curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{"task": "Explain RAG systems"}'

🐍 Python SDK

from main import LangchainCustomAgentFramework

agent = LangchainCustomAgentFramework()

# Single task
result = agent.run("Write a Python function to parse JSON files recursively")
print(result["output"])

# Interactive chat
while True:
    user_input = input("You: ")
    print(f"Agent: {agent.chat(user_input)}")

🏗️ Architecture

langchain-custom-agent-framework/
├── main.py              # Main agent (entry point)
├── utils/
│   └── helpers.py       # Utility functions
├── tests/
│   └── test_agent.py    # Test suite
├── agent_outputs/       # Files created by the agent
├── .env.example         # Environment template
└── requirements.txt

🧪 Running Tests

pytest tests/ -v

📄 License

MIT — see LICENSE


Built by Gaurav Savla

About

Production LangChain agent framework with custom tool creation, streaming output, async execution, observability tracing and comprehensive error recovery

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors