rcrewai 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +108 -0
  3. data/LICENSE +21 -0
  4. data/README.md +328 -0
  5. data/Rakefile +130 -0
  6. data/bin/rcrewai +7 -0
  7. data/docs/_config.yml +59 -0
  8. data/docs/_layouts/api.html +16 -0
  9. data/docs/_layouts/default.html +78 -0
  10. data/docs/_layouts/example.html +24 -0
  11. data/docs/_layouts/tutorial.html +33 -0
  12. data/docs/api/configuration.md +327 -0
  13. data/docs/api/crew.md +345 -0
  14. data/docs/api/index.md +41 -0
  15. data/docs/api/tools.md +412 -0
  16. data/docs/assets/css/style.css +416 -0
  17. data/docs/examples/human-in-the-loop.md +382 -0
  18. data/docs/examples/index.md +78 -0
  19. data/docs/examples/production-ready-crew.md +485 -0
  20. data/docs/examples/simple-research-crew.md +297 -0
  21. data/docs/index.md +353 -0
  22. data/docs/tutorials/getting-started.md +341 -0
  23. data/examples/async_execution_example.rb +294 -0
  24. data/examples/hierarchical_crew_example.rb +193 -0
  25. data/examples/human_in_the_loop_example.rb +233 -0
  26. data/lib/rcrewai/agent.rb +636 -0
  27. data/lib/rcrewai/async_executor.rb +248 -0
  28. data/lib/rcrewai/cli.rb +39 -0
  29. data/lib/rcrewai/configuration.rb +100 -0
  30. data/lib/rcrewai/crew.rb +292 -0
  31. data/lib/rcrewai/human_input.rb +520 -0
  32. data/lib/rcrewai/llm_client.rb +41 -0
  33. data/lib/rcrewai/llm_clients/anthropic.rb +127 -0
  34. data/lib/rcrewai/llm_clients/azure.rb +158 -0
  35. data/lib/rcrewai/llm_clients/base.rb +82 -0
  36. data/lib/rcrewai/llm_clients/google.rb +158 -0
  37. data/lib/rcrewai/llm_clients/ollama.rb +199 -0
  38. data/lib/rcrewai/llm_clients/openai.rb +124 -0
  39. data/lib/rcrewai/memory.rb +194 -0
  40. data/lib/rcrewai/process.rb +421 -0
  41. data/lib/rcrewai/task.rb +376 -0
  42. data/lib/rcrewai/tools/base.rb +82 -0
  43. data/lib/rcrewai/tools/code_executor.rb +333 -0
  44. data/lib/rcrewai/tools/email_sender.rb +210 -0
  45. data/lib/rcrewai/tools/file_reader.rb +111 -0
  46. data/lib/rcrewai/tools/file_writer.rb +115 -0
  47. data/lib/rcrewai/tools/pdf_processor.rb +342 -0
  48. data/lib/rcrewai/tools/sql_database.rb +226 -0
  49. data/lib/rcrewai/tools/web_search.rb +131 -0
  50. data/lib/rcrewai/version.rb +5 -0
  51. data/lib/rcrewai.rb +36 -0
  52. data/rcrewai.gemspec +54 -0
  53. metadata +365 -0
@@ -0,0 +1,382 @@
1
+ ---
2
+ layout: example
3
+ title: Human-in-the-Loop Integration
4
+ description: Learn how to integrate human oversight and collaboration into your AI agent workflows
5
+ ---
6
+
7
+ # Human-in-the-Loop Integration
8
+
9
+ RCrewAI provides comprehensive human-in-the-loop functionality that allows humans to collaborate with AI agents, providing oversight, guidance, and intervention when needed.
10
+
11
+ ## Overview
12
+
13
+ Human-in-the-loop capabilities include:
14
+
15
+ - **Task Confirmation**: Human approval before starting critical tasks
16
+ - **Tool Approval**: Human confirmation for potentially sensitive tool usage
17
+ - **Real-time Guidance**: Human input during agent reasoning processes
18
+ - **Result Review**: Human review and feedback on task completion
19
+ - **Error Recovery**: Human intervention when agents encounter failures
20
+
21
+ ## Basic Human-in-the-Loop Setup
22
+
23
+ ```ruby
24
+ require 'rcrewai'
25
+
26
+ # Configure RCrewAI
27
+ RCrewAI.configure do |config|
28
+ config.llm_provider = :openai
29
+ end
30
+
31
+ # Create an agent with human interaction enabled
32
+ agent = RCrewAI::Agent.new(
33
+ name: "research_agent",
34
+ role: "Research Specialist",
35
+ goal: "Conduct thorough research with human oversight",
36
+ backstory: "Expert researcher who works closely with humans for quality assurance",
37
+ tools: [RCrewAI::Tools::WebSearch.new, RCrewAI::Tools::FileWriter.new],
38
+ human_input: true, # Enable human interaction
39
+ require_approval_for_tools: true, # Require approval for tool usage
40
+ require_approval_for_final_answer: true # Require approval for final results
41
+ )
42
+
43
+ # Create a task with human interaction points
44
+ task = RCrewAI::Task.new(
45
+ name: "sensitive_research",
46
+ description: "Research confidential market information for our new product",
47
+ agent: agent,
48
+ expected_output: "Market analysis report with strategic insights",
49
+ human_input: true, # Enable human interaction for this task
50
+ require_confirmation: true, # Human must confirm before starting
51
+ allow_guidance: true, # Allow human guidance during execution
52
+ human_review_points: [:completion] # Review when task completes
53
+ )
54
+
55
+ # Execute - human will be prompted for input as needed
56
+ result = task.execute
57
+ ```
58
+
59
+ ## Human Interaction Types
60
+
61
+ ### 1. Task Confirmation
62
+
63
+ Tasks can require human confirmation before starting:
64
+
65
+ ```ruby
66
+ task = RCrewAI::Task.new(
67
+ name: "deploy_changes",
68
+ description: "Deploy the new model to production",
69
+ require_confirmation: true,
70
+ agent: deployment_agent
71
+ )
72
+
73
+ # When executed, human will see:
74
+ # 🤝 HUMAN APPROVAL REQUIRED
75
+ # ========================================
76
+ # Request: Confirm execution of task: deploy_changes
77
+ # Context: Description: Deploy the new model to production
78
+ # Expected Output: Not specified
79
+ # Assigned Agent: deployment_agent
80
+ #
81
+ # Consequences: The task will be executed with the specified agent and may use external tools.
82
+ #
83
+ # Do you approve this action? (yes/no)
84
+ ```
85
+
86
+ ### 2. Tool Approval Workflows
87
+
88
+ Agents can request human approval before using potentially sensitive tools:
89
+
90
+ ```ruby
91
+ agent = RCrewAI::Agent.new(
92
+ name: "data_agent",
93
+ role: "Data Processor",
94
+ goal: "Process data safely",
95
+ tools: [RCrewAI::Tools::SqlDatabase.new, RCrewAI::Tools::EmailSender.new],
96
+ require_approval_for_tools: true
97
+ )
98
+
99
+ # When agent wants to use a tool, human will see:
100
+ # 🤝 HUMAN APPROVAL REQUIRED
101
+ # ========================================
102
+ # Request: Agent data_agent wants to use tool 'SqlDatabase'
103
+ # Context: Parameters: {"query": "SELECT * FROM customers", "database": "production"}
104
+ # Consequences: This will execute the SqlDatabase tool with the specified parameters.
105
+ #
106
+ # Do you approve this action? (yes/no)
107
+ ```
108
+
109
+ ### 3. Real-time Guidance During Reasoning
110
+
111
+ Humans can provide guidance during agent reasoning loops:
112
+
113
+ ```ruby
114
+ agent = RCrewAI::Agent.new(
115
+ name: "strategic_planner",
116
+ role: "Business Strategist",
117
+ goal: "Develop strategic plans with human input",
118
+ human_input: true
119
+ )
120
+
121
+ task = RCrewAI::Task.new(
122
+ name: "market_strategy",
123
+ description: "Develop go-to-market strategy for new product",
124
+ agent: agent,
125
+ allow_guidance: true
126
+ )
127
+
128
+ # During execution, human will periodically see:
129
+ # 👀 HUMAN REVIEW REQUESTED
130
+ # ========================================
131
+ # Content to review:
132
+ # Task: market_strategy
133
+ # Description: Develop go-to-market strategy for new product
134
+ #
135
+ # Current Iteration: 1
136
+ #
137
+ # Agent Analysis:
138
+ # - Role: Business Strategist
139
+ # - Current Progress: Starting task
140
+ # - Previous Reasoning: No previous reasoning
141
+ #
142
+ # The agent is about to continue reasoning for this task.
143
+ # ----------------------------------------
144
+ #
145
+ # Review criteria: Task approach, Progress assessment, Strategic guidance
146
+ #
147
+ # Please review and provide feedback (or type 'approve' to approve as-is):
148
+ ```
149
+
150
+ ### 4. Final Answer Review and Revision
151
+
152
+ Agents can request human review of their final answers:
153
+
154
+ ```ruby
155
+ agent = RCrewAI::Agent.new(
156
+ name: "content_creator",
157
+ role: "Content Writer",
158
+ goal: "Create high-quality content",
159
+ require_approval_for_final_answer: true
160
+ )
161
+
162
+ # When task completes, human will see:
163
+ # 👀 HUMAN REVIEW REQUESTED
164
+ # ========================================
165
+ # Content to review:
166
+ # [Agent's final answer/result here]
167
+ # ----------------------------------------
168
+ #
169
+ # Review criteria: Accuracy, Completeness, Clarity, Relevance
170
+ #
171
+ # Please review and provide feedback (or type 'approve' to approve as-is):
172
+
173
+ # If human provides feedback, agent can:
174
+ # 1. Revise the answer based on feedback
175
+ # 2. Use the answer as-is despite feedback
176
+ # 3. Let human provide the correct answer
177
+ ```
178
+
179
+ ### 5. Error Recovery with Human Intervention
180
+
181
+ When agents encounter failures, humans can guide the recovery process:
182
+
183
+ ```ruby
184
+ # If a task fails, human will see:
185
+ # 🎯 HUMAN CHOICE REQUIRED
186
+ # ========================================
187
+ # Question: Task 'data_analysis' failed with error: Connection timeout. How should I proceed?
188
+ #
189
+ # Available choices:
190
+ # 1. Retry with current settings
191
+ # 2. Modify task parameters and retry
192
+ # 3. Abort task execution
193
+ #
194
+ # Please select a choice (enter number or text):
195
+
196
+ # If human selects "2. Modify task parameters":
197
+ # 💬 HUMAN INPUT REQUESTED
198
+ # ========================================
199
+ # Prompt: Please specify task modifications (JSON format):
200
+ #
201
+ # Help: Provide modifications as JSON, e.g. {"description": "new description", "expected_output": "new output"}
202
+ #
203
+ # Please provide your input:
204
+ ```
205
+
206
+ ## Advanced Human Interaction Patterns
207
+
208
+ ### Multi-Agent Collaboration with Human Oversight
209
+
210
+ ```ruby
211
+ # Create crew with manager coordination
212
+ crew = RCrewAI::Crew.new("human_assisted_team", process: :hierarchical)
213
+
214
+ # Manager agent coordinates human interactions
215
+ manager = RCrewAI::Agent.new(
216
+ name: "project_manager",
217
+ role: "Project Coordinator",
218
+ goal: "Coordinate team with human oversight",
219
+ manager: true,
220
+ human_input: true
221
+ )
222
+
223
+ # Specialist agents with different human interaction needs
224
+ researcher = RCrewAI::Agent.new(
225
+ name: "researcher",
226
+ role: "Research Specialist",
227
+ goal: "Conduct research with human guidance",
228
+ human_input: true,
229
+ require_approval_for_tools: true # Requires approval for web searches
230
+ )
231
+
232
+ analyst = RCrewAI::Agent.new(
233
+ name: "analyst",
234
+ role: "Data Analyst",
235
+ goal: "Analyze data with human validation",
236
+ human_input: true,
237
+ require_approval_for_final_answer: true # Human validates analysis results
238
+ )
239
+
240
+ crew.add_agent(manager)
241
+ crew.add_agent(researcher)
242
+ crew.add_agent(analyst)
243
+
244
+ # Tasks with different human interaction requirements
245
+ research_task = RCrewAI::Task.new(
246
+ name: "market_research",
247
+ description: "Research competitor landscape",
248
+ human_input: true,
249
+ require_confirmation: true, # Confirm before starting research
250
+ human_review_points: [:completion]
251
+ )
252
+
253
+ analysis_task = RCrewAI::Task.new(
254
+ name: "competitive_analysis",
255
+ description: "Analyze research findings for strategic insights",
256
+ context: [research_task],
257
+ human_input: true,
258
+ allow_guidance: true, # Allow human strategic input
259
+ human_review_points: [:completion]
260
+ )
261
+
262
+ crew.add_task(research_task)
263
+ crew.add_task(analysis_task)
264
+
265
+ # Execute with human collaboration
266
+ results = crew.execute
267
+ ```
268
+
269
+ ### Custom Human Input Utilities
270
+
271
+ ```ruby
272
+ # Use HumanInput directly for custom interactions
273
+ human_input = RCrewAI::HumanInput.new(verbose: true)
274
+
275
+ # Request approval with context
276
+ approval = human_input.request_approval(
277
+ "Deploy model to production environment",
278
+ context: "Model version: v2.1.4, Environment: Production",
279
+ consequences: "This will update the live model serving production traffic",
280
+ timeout: 120
281
+ )
282
+
283
+ if approval[:approved]
284
+ puts "Deployment approved: #{approval[:reason]}"
285
+ else
286
+ puts "Deployment rejected: #{approval[:reason]}"
287
+ end
288
+
289
+ # Request multiple choice input
290
+ choice = human_input.request_choice(
291
+ "Which deployment strategy should we use?",
292
+ ["Blue-green deployment", "Rolling deployment", "Canary deployment"],
293
+ timeout: 60
294
+ )
295
+
296
+ puts "Selected strategy: #{choice[:choice]}" if choice[:valid]
297
+
298
+ # Request text input with validation
299
+ input = human_input.request_input(
300
+ "Enter the deployment configuration:",
301
+ type: :json,
302
+ validation: {
303
+ required_keywords: ["environment", "replicas"],
304
+ min_length: 20
305
+ }
306
+ )
307
+
308
+ if input[:valid]
309
+ config = input[:processed_input]
310
+ puts "Configuration: #{config}"
311
+ else
312
+ puts "Invalid input: #{input[:reason]}"
313
+ end
314
+
315
+ # Get session summary
316
+ summary = human_input.session_summary
317
+ puts "Human interactions: #{summary[:total_interactions]}"
318
+ puts "Approval rate: #{summary[:approvals] / summary[:total_interactions].to_f * 100}%"
319
+ ```
320
+
321
+ ## Best Practices
322
+
323
+ ### 1. **Strategic Human Checkpoints**
324
+ - Use human approval for irreversible actions (deployments, data modifications)
325
+ - Request human guidance for strategic decisions
326
+ - Get human validation for critical outputs
327
+
328
+ ### 2. **Balanced Automation**
329
+ - Enable human input for high-risk operations only
330
+ - Use timeouts to prevent workflow blocking
331
+ - Provide meaningful context for human decisions
332
+
333
+ ### 3. **Error Recovery**
334
+ - Always offer human intervention options when tasks fail
335
+ - Allow humans to modify task parameters for retry
336
+ - Provide clear error context and suggested actions
337
+
338
+ ### 4. **User Experience**
339
+ - Keep approval requests concise but informative
340
+ - Provide reasonable timeout values
341
+ - Show consequences of actions clearly
342
+
343
+ ### 5. **Testing and Development**
344
+ - Use auto-approval mode for testing workflows
345
+ - Test human interaction flows in development
346
+ - Monitor interaction patterns and optimize prompts
347
+
348
+ ## Configuration Options
349
+
350
+ ```ruby
351
+ # Agent-level human input configuration
352
+ agent = RCrewAI::Agent.new(
353
+ name: "agent",
354
+ role: "Specialist",
355
+ goal: "Complete tasks with human collaboration",
356
+ human_input: true, # Enable human input
357
+ require_approval_for_tools: true, # Require approval for all tools
358
+ require_approval_for_final_answer: false # Optional final answer approval
359
+ )
360
+
361
+ # Task-level human input configuration
362
+ task = RCrewAI::Task.new(
363
+ name: "task",
364
+ description: "Complete a complex task",
365
+ agent: agent,
366
+ human_input: true, # Enable human input
367
+ require_confirmation: false, # No confirmation needed to start
368
+ allow_guidance: true, # Allow human guidance during execution
369
+ human_review_points: [:completion, :error] # Review at completion and errors
370
+ )
371
+
372
+ # HumanInput utility configuration
373
+ human_input = RCrewAI::HumanInput.new(
374
+ timeout: 300, # Default timeout in seconds
375
+ verbose: true, # Enable verbose logging
376
+ auto_approve: false, # Disable auto-approval (for testing)
377
+ approval_keywords: %w[yes y approve], # Custom approval keywords
378
+ rejection_keywords: %w[no n reject] # Custom rejection keywords
379
+ )
380
+ ```
381
+
382
+ Human-in-the-loop integration makes RCrewAI perfect for scenarios requiring human oversight, strategic input, or collaborative decision-making while maintaining the power and efficiency of AI automation.
@@ -0,0 +1,78 @@
1
+ ---
2
+ layout: example
3
+ title: RCrewAI Examples
4
+ description: Real-world examples of RCrewAI in action
5
+ ---
6
+
7
+ # Examples
8
+
9
+ Explore real-world examples of RCrewAI in action. Each example includes complete code and explanations.
10
+
11
+ ## Basic Examples
12
+
13
+ ### [Simple Research Crew]({{ site.baseurl }}/examples/simple-research-crew)
14
+ A basic crew with a researcher and writer working together to create content.
15
+
16
+ ### [Task Automation]({{ site.baseurl }}/examples/task-automation)
17
+ Automate repetitive tasks using AI agents with specific roles.
18
+
19
+ ## Intermediate Examples
20
+
21
+ ### [Content Marketing Pipeline]({{ site.baseurl }}/examples/content-marketing-pipeline)
22
+ A complete content marketing workflow from research to publication.
23
+
24
+ ### [Code Review Crew]({{ site.baseurl }}/examples/code-review-crew)
25
+ Agents that review code, suggest improvements, and generate documentation.
26
+
27
+ ### [Data Analysis Team]({{ site.baseurl }}/examples/data-analysis-team)
28
+ Collaborative data analysis with specialized agents for different aspects.
29
+
30
+ ## Advanced Examples
31
+
32
+ ### [Human-in-the-Loop Integration]({{ site.baseurl }}/examples/human-in-the-loop)
33
+ Complete guide to integrating human oversight and collaboration into AI workflows.
34
+
35
+ ### [Multi-Stage Product Development]({{ site.baseurl }}/examples/product-development)
36
+ Complex product development workflow with multiple teams and dependencies.
37
+
38
+ ### [Customer Support Automation]({{ site.baseurl }}/examples/customer-support)
39
+ Intelligent customer support with escalation and knowledge management.
40
+
41
+ ### [Financial Analysis Crew]({{ site.baseurl }}/examples/financial-analysis)
42
+ Comprehensive financial analysis with market research and reporting.
43
+
44
+ ### [Hierarchical Team Coordination]({{ site.baseurl }}/examples/hierarchical-crew)
45
+ Manager agents coordinating specialist teams with delegation and async execution.
46
+
47
+ ### [Concurrent Task Processing]({{ site.baseurl }}/examples/async-execution)
48
+ Performance optimization with parallel execution and dependency management.
49
+
50
+ ## Use Case Specific
51
+
52
+ ### [E-commerce Operations]({{ site.baseurl }}/examples/ecommerce-operations)
53
+ Product listing optimization, inventory management, and customer insights.
54
+
55
+ ### [Social Media Management]({{ site.baseurl }}/examples/social-media)
56
+ Content creation, scheduling, and engagement analysis for social platforms.
57
+
58
+ ### [Research & Development]({{ site.baseurl }}/examples/research-development)
59
+ Scientific research workflows with literature review and hypothesis generation.
60
+
61
+ ## Integration Examples
62
+
63
+ ### [Web Scraping Crew]({{ site.baseurl }}/examples/web-scraping)
64
+ Agents equipped with web scraping tools for data collection and analysis.
65
+
66
+ ### [API Integration]({{ site.baseurl }}/examples/api-integration)
67
+ Connecting crews to external APIs and services.
68
+
69
+ ### [Database Operations]({{ site.baseurl }}/examples/database-operations)
70
+ Data processing and analysis with database connectivity.
71
+
72
+ ## Custom Tools
73
+
74
+ ### [Building Custom Tools]({{ site.baseurl }}/examples/custom-tools)
75
+ Create specialized tools for your agents' unique requirements.
76
+
77
+ ### [Tool Composition]({{ site.baseurl }}/examples/tool-composition)
78
+ Combine multiple tools to create powerful agent capabilities.