_ ___ _ _ _ _
/ \ |_ _| | | | | __ _ ___| | _____ _ __| | ___ __ _ __ _ _ _ ___
/ _ \ | | | |__| |/ _` |/ __| |/ / _ \ '__| | / _ \/ _` |/ _` || | | |/ _ \
/ ___ \ | | | __ | (_| | (__| < __/ | | |__| __/ (_| | (_| || |_| | __/
/_/ \_\___| |_| |_|\__,_|\___|_|\_\___|_| |_____\___|\__,_|\__, | \__,_|\___|
|___/
Created during AI Hacker League live coding session - Every Thursday at 12pm ET
AI Hacker League is a vibrant community of developers, researchers, and enthusiasts who come together to explore and push the boundaries of AI technology. Our weekly live coding sessions are more than just tutorials - they're collaborative experiments in cutting-edge AI development.
- Live Coding Sessions: Every Thursday at 12pm ET, we dive into hands-on AI development, building real systems in real-time.
- Community Learning: Join fellow AI enthusiasts in exploring new technologies and techniques.
- Practical Experience: Learn by doing, with real-world applications and use cases.
- Expert Guidance: Sessions led by experienced AI developers and researchers.
- 🔧 Hands-On Experience: Get practical experience with cutting-edge AI tools and frameworks.
- 🤝 Networking Opportunities: Connect with other AI developers and enthusiasts.
- 💡 Practical Implementation Techniques: Learn techniques not typically covered in traditional courses.
- 🚀 Stay Ahead in AI Development: Keep up with the latest advancements and trends in AI.
- 🛠️ Build Your Portfolio: Work on real AI projects that showcase your skills.
- 🎓 Learn Best Practices: Gain insights from experienced developers to enhance your development workflow.
This repository showcases a project created during one of our live sessions, demonstrating the power of AI agents using CrewAI, LangChain/LangGraph, and Aider. It's a perfect example of the practical, hands-on learning you'll experience in AI Hacker League.
Learn to build, customize, and deploy intelligent AI agents using CrewAI, LangChain/LangGraph, and Aider
- Introduction
- Project Overview
- Getting Started
- Understanding the Components
- Customization Guide
- Advanced Topics
- Contributing
- Join AI Hacker League
- License
Welcome to the AI Agent Development Tutorial! This guide is designed to help you build and customize AI agents using powerful tools like CrewAI, LangChain/LangGraph, and Aider. Whether you're an entry-level developer or an experienced AI enthusiast, this tutorial will provide you with the knowledge and steps needed to create sophisticated AI-driven systems.
Benefits of Following This Tutorial:
- Step-by-Step Guidance: Clear instructions to guide you through each phase of development.
- Detailed Descriptions: In-depth explanations of each component and their interactions.
- Customizable Codebase: Learn how to modify and extend the code to suit your specific needs.
- Practical Examples: Real-world examples to demonstrate the application of concepts.
- Enhanced Understanding: Gain a comprehensive understanding of AI agent architecture and functionality.
The project implements a modular AI agent system with the following key features:
- ReACT (Reasoning and Acting) Methodology: Structured problem-solving approach integrating reasoning and action-taking.
- Multi-Agent Coordination using CrewAI: Allows multiple agents to work together seamlessly.
- Task Configuration and Agent Role Definition: Defines specific tasks and assigns roles to agents for efficient execution.
- Interactive Command-Line Interface with Cyberpunk Styling: Engaging interface for interacting with the system.
Before you begin, ensure you have the following installed:
- Python 3.8+: Python programming language.
- Poetry: Dependency management and packaging tool.
# Clone the repository
git clone https://github.com/ruvnet/hacker-league-jan23
cd hacker-league-jan23
# Install dependencies
poetry install
- Configure Environment Variables
Copy the sample environment file and set up your environment variables:
cp env.sample .env
Open .env
in your preferred editor and add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
- Setting Up OpenRouter API Key
The project utilizes OpenRouter for certain AI functionalities. You will be prompted to enter your OpenRouter API key during the initial run. You can obtain this key from OpenRouter's website.
The project includes a user-friendly command-line interface (start.sh
) to manage various operations.
./start.sh
Menu Options:
- Install Neural Dependencies: Ensures all required Python packages are installed.
- Activate AI Cores (Default Mode): Runs the AI agent with default settings.
- Activate AI Cores (Custom Mode): Allows you to input custom prompts and select specific tasks.
- Enter Sleep Mode: Safely shuts down the AI cores.
For more control, you can directly run the agent with custom arguments:
poetry run python src/hello_world/main.py --prompt "Your prompt here" --task research
Arguments:
--prompt
: Specify the prompt/question for the AI system. (Default: "Tell me about yourself")--task
: Define the type of task to perform. (Options: research, execute, both; Default: both)
The project includes a powerful configuration management script (coding-admin.sh
) that provides an interactive interface for customizing and managing your AI development environment.
./coding-admin.sh
-
AI Chat Assistant
- Get help with settings configuration
- Development workflow guidance
- Configuration recommendations
- Chat settings management
-
Model Settings
- Configure main model (GPT-4, Claude-3, etc.)
- Set editor model preferences
- Manage model aliases
- Configure SSL and API settings
-
Git Integration
- Toggle auto-commits
- Configure commit messages
- Set repository preferences
- Manage author attribution
-
Output Customization
- Toggle dark/light mode
- Configure color schemes
- Set code themes
- Manage diff display
-
History Management
- Configure input/chat history
- Set history file locations
- Manage chat history restoration
-
Development Tools
- Configure linting settings
- Set up testing preferences
- Manage environment variables
- Configure shell commands
-
Performance Settings
- Configure cache settings
- Manage map settings
- Set up analytics preferences
-
OpenRouter Integration
- Configure API keys
- Set up model preferences
- Manage development workflows
The script manages several configuration files:
.aider.conf.yml
: Main configuration fileopenrouter_config.yml
: OpenRouter-specific settings.env
: Environment variables and API keys
- Setting Up OpenRouter
./coding-admin.sh
# Select option 2 (OpenRouter Settings)
# Follow prompts to enter your API key
- Configuring Model Settings
./coding-admin.sh
# Select option 4 (Model Settings)
# Choose your preferred model and settings
- Customizing Output
./coding-admin.sh
# Select option 6 (Output Settings)
# Configure themes and display preferences
The configuration manager provides an intuitive interface for managing all aspects of your AI development environment. Use the interactive menus to explore and customize settings according to your needs.
Defines agent roles and capabilities:
research_analyst:
name: Research Analyst
model: deepseek
temperature: 0.7
description: |
Expert in analyzing information and providing insights using ReACT methodology.
Defines tasks and their requirements:
research:
description: Conduct research and analysis
tools:
- web_search
- document_analysis
Orchestrates the agent system:
def run():
args = parse_args()
crew = HelloWorldCrew()
result = crew.run(prompt=args.prompt, task_type=args.task)
Handles agent coordination and task execution:
class HelloWorldCrew:
def __init__(self):
self.crew = Crew(
agents=[self.research_analyst],
tasks=[self.research_task]
)
This section will guide you through customizing the AI agent system to better fit your specific needs. We'll cover adding new agents, defining new tasks, and creating custom tools.
To create a new agent type:
- Define Agent Configuration
Add a new agent configuration in agents.yaml
:
code_expert:
name: Code Expert
model: gpt-4
temperature: 0.3
description: |
Specialized in code analysis and generation.
- Implement Agent Logic
Create the agent implementation in crew.py
:
def create_code_expert(self):
return Agent(
role="Code Expert",
goal="Generate and analyze code efficiently",
backstory="Expert software developer with broad language expertise",
tools=[self.code_analysis_tool]
)
To implement new task types:
- Define Task Configuration
Add a new task in tasks.yaml
:
code_review:
description: Perform code analysis and review
tools:
- code_analysis
- best_practices_check
- Implement Task Handler
Create the task handler in crew.py
:
def code_review_task(self):
return Task(
description="Analyze code for quality and improvements",
tools=self.get_code_tools()
)
To create new tools for agents:
- Develop the Tool
Create a new tool in tools/custom_tool.py
:
class CodeAnalysisTool:
def analyze_code(self, code: str) -> dict:
# Implementation
return {
"complexity": calculate_complexity(code),
"suggestions": generate_suggestions(code)
}
- Register the Tool with Agents
Register the new tool in crew.py
:
def get_code_tools(self):
return [
Tool(
name="code_analysis",
func=self.code_analysis_tool.analyze_code,
description="Analyzes code quality and structure"
)
]
Explore more complex functionalities to extend the AI agent system.
Create specialized workflows by combining agents and tasks:
class CustomWorkflow:
def __init__(self):
self.research_agent = ResearchAnalyst()
self.code_agent = CodeExpert()
def execute(self, prompt):
research_results = self.research_agent.analyze(prompt)
code_implementation = self.code_agent.implement(research_results)
return code_implementation
Enhance agent capabilities by integrating external APIs:
class ExternalServiceTool:
def __init__(self, api_key):
self.client = ExternalAPI(api_key)
def fetch_data(self, query):
return self.client.search(query)
Implement custom formatters for agent outputs to improve readability:
class OutputFormatter:
def format_research(self, results):
return f"""
╔══════════════════════════════════════════════════════════════════╗
║ RESEARCH FINDINGS ║
╚══════════════════════════════════════════════════════════════════╝
{results}
"""
We welcome contributions to enhance this project. Follow these steps to contribute:
-
Fork the Repository
Click the "Fork" button at the top-right corner of the repository page to create your own copy.
-
Create a Feature Branch
git checkout -b feature/YourFeatureName
-
Make Your Changes
Implement your feature or bug fix. Ensure your code follows the project's coding standards.
-
Commit Your Changes
git commit -m "Add feature: YourFeatureName"
-
Push to Your Fork
git push origin feature/YourFeatureName
-
Submit a Pull Request
Navigate to the original repository and click "New pull request". Describe your changes and submit.
Be a part of our thriving AI Hacker League community! Join us every Thursday at 12pm ET for live coding sessions where we build and explore AI systems together. Whether you're a beginner or an expert, there's something for everyone.
Why Join?
- Collaborative Learning: Work alongside other AI enthusiasts and learn collaboratively.
- Real-Time Feedback: Get immediate insights and feedback on your work.
- Stay Updated: Keep up with the latest tools and technologies in AI.
Follow @rUv on GitHub for updates and announcements.
This project is open source and available under the MIT License.
Created by rUv, cause he could. 🚀