RCrewAI

Build powerful AI agent crews in Ruby that work together to accomplish complex tasks.

RCrewAI is a Ruby implementation of the CrewAI framework, allowing you to create autonomous AI agents that collaborate to solve problems and complete tasks.

Features

Quick Start

Basic Agent Collaboration

require 'rcrewai'

# Configure your LLM provider
RCrewAI.configure do |config|
  config.llm_provider = :openai  # or :anthropic, :google, :azure, :ollama
  config.temperature = 0.1
end

# Create intelligent agents with specialized tools
researcher = RCrewAI::Agent.new(
  name: "researcher",
  role: "Senior Research Analyst",
  goal: "Uncover cutting-edge developments in AI",
  backstory: "Expert at finding and analyzing the latest tech trends",
  tools: [RCrewAI::Tools::WebSearch.new],
  verbose: true
)

writer = RCrewAI::Agent.new(
  name: "writer", 
  role: "Tech Content Strategist",
  goal: "Create compelling technical content",
  backstory: "Skilled at transforming research into engaging articles",
  tools: [RCrewAI::Tools::FileWriter.new]
)

# Create crew with sequential process
crew = RCrewAI::Crew.new("ai_research_crew")
crew.add_agent(researcher)
crew.add_agent(writer)

# Define tasks with dependencies
research_task = RCrewAI::Task.new(
  name: "research_ai_trends",
  description: "Research the latest developments in AI for 2024",
  agent: researcher,
  expected_output: "Comprehensive report on AI trends with key insights"
)

writing_task = RCrewAI::Task.new(
  name: "write_article",
  description: "Write an engaging 1000-word article about AI trends",
  agent: writer,
  context: [research_task],  # Uses research results as context
  expected_output: "Publication-ready article saved as ai_trends.md"
)

crew.add_task(research_task)
crew.add_task(writing_task)

# Execute - agents will reason, search, and produce real results!
results = crew.execute
puts "βœ… Crew completed #{results[:completed_tasks]}/#{results[:total_tasks]} tasks"

Advanced: Hierarchical Team with Human Oversight

# Create a hierarchical crew with manager coordination
crew = RCrewAI::Crew.new("enterprise_team", process: :hierarchical)

# Manager agent coordinates the team
manager = RCrewAI::Agent.new(
  name: "project_manager",
  role: "Senior Project Manager", 
  goal: "Coordinate team execution efficiently",
  backstory: "Experienced manager with expertise in AI project coordination",
  manager: true,
  allow_delegation: true,
  verbose: true
)

# Specialist agents with human-in-the-loop capabilities
data_analyst = RCrewAI::Agent.new(
  name: "data_analyst",
  role: "Senior Data Analyst",
  goal: "Analyze data with human validation", 
  backstory: "Expert at extracting insights from complex datasets",
  tools: [RCrewAI::Tools::SqlDatabase.new, RCrewAI::Tools::FileWriter.new],
  human_input: true,                      # Enable human interaction
  require_approval_for_tools: true,       # Human approves SQL queries
  require_approval_for_final_answer: true # Human validates analysis
)

# Add agents to hierarchical crew
crew.add_agent(manager)
crew.add_agent(data_analyst)
crew.add_agent(researcher)

# Tasks with different execution modes
analysis_task = RCrewAI::Task.new(
  name: "customer_analysis",
  description: "Analyze customer behavior patterns from database",
  expected_output: "Customer segmentation analysis with actionable insights",
  human_input: true,
  require_confirmation: true,  # Human confirms before starting
  async: true                  # Can run concurrently
)

research_task = RCrewAI::Task.new(
  name: "market_research", 
  description: "Research competitive landscape",
  expected_output: "Competitive analysis report",
  async: true
)

crew.add_task(analysis_task)
crew.add_task(research_task)

# Execute with async/hierarchical coordination
results = crew.execute(async: true, max_concurrency: 2)
puts "πŸš€ Hierarchical execution completed with #{results[:success_rate]}% success rate"

Installation

Add this line to your application’s Gemfile:

gem 'rcrewai'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install rcrewai

CLI Usage

RCrewAI includes a powerful CLI for managing your AI crews:

# Create a new crew with different process types
$ rcrewai new my_research_crew --process sequential
$ rcrewai new enterprise_team --process hierarchical

# List available crews and agents
$ rcrewai list
$ rcrewai agents list

# Create agents with advanced capabilities
$ rcrewai agent new researcher \
  --role "Senior Research Analyst" \
  --goal "Find cutting-edge AI information" \
  --backstory "Expert researcher with 10 years experience" \
  --tools web_search,file_writer \
  --verbose \
  --human-input

# Create manager agents for hierarchical crews
$ rcrewai agent new project_manager \
  --role "Project Coordinator" \
  --goal "Coordinate team execution" \
  --manager \
  --allow-delegation

# Create tasks with dependencies and human interaction
$ rcrewai task new research \
  --description "Research latest AI developments" \
  --expected-output "Comprehensive AI research report" \
  --agent researcher \
  --async \
  --human-input \
  --require-confirmation

# Run crews with different execution modes
$ rcrewai run --crew my_research_crew
$ rcrewai run --crew enterprise_team --async --max-concurrency 4

# Check crew status and results
$ rcrewai status --crew my_research_crew
$ rcrewai results --crew my_research_crew --task research

Key Capabilities

🧠 Advanced Agent Intelligence

Agents use sophisticated reasoning with your chosen LLM provider:

πŸ› οΈ Comprehensive Tool Ecosystem

Production-ready tools for real-world tasks:

🀝 Human-in-the-Loop Integration

Seamless human-AI collaboration for critical workflows:

πŸ—οΈ Enterprise-Grade Orchestration

Sophisticated coordination patterns for complex workflows:

⚑ Advanced Task Management

Powerful task system with production features:

πŸ”’ Production-Ready Architecture

Built for enterprise deployment and reliability:

LLM Provider Support

RCrewAI works with all major LLM providers through a unified interface:

# OpenAI (GPT-4, GPT-3.5, etc.)
RCrewAI.configure do |config|
  config.llm_provider = :openai
  config.openai_api_key = ENV['OPENAI_API_KEY']
  config.model = 'gpt-4'
  config.temperature = 0.1
end

# Anthropic Claude
RCrewAI.configure do |config|
  config.llm_provider = :anthropic
  config.anthropic_api_key = ENV['ANTHROPIC_API_KEY'] 
  config.model = 'claude-3-sonnet-20240229'
end

# Google Gemini
RCrewAI.configure do |config|
  config.llm_provider = :google
  config.google_api_key = ENV['GOOGLE_API_KEY']
  config.model = 'gemini-pro'
end

# Azure OpenAI
RCrewAI.configure do |config|
  config.llm_provider = :azure
  config.azure_api_key = ENV['AZURE_OPENAI_API_KEY']
  config.azure_endpoint = ENV['AZURE_OPENAI_ENDPOINT']
  config.model = 'gpt-4'
end

# Local Ollama
RCrewAI.configure do |config|
  config.llm_provider = :ollama
  config.ollama_url = 'http://localhost:11434'
  config.model = 'llama2'
end

Use Cases

RCrewAI excels in scenarios requiring:

Learn More

πŸ“š Tutorials

Step-by-step guides to get you started with RCrewAI

View Tutorials β†’

πŸ“– API Reference

Complete documentation of all classes and methods

API Docs β†’

πŸ’‘ Examples

Real-world examples and use cases

View Examples β†’

Contributing

We welcome contributions! Please see our contributing guidelines for details.

License

RCrewAI is released under the MIT License.