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
data/docs/api/crew.md ADDED
@@ -0,0 +1,345 @@
1
+ ---
2
+ layout: api
3
+ title: RCrewAI::Crew
4
+ description: API documentation for the Crew class
5
+ ---
6
+
7
+ # RCrewAI::Crew
8
+
9
+ The Crew class is the main orchestrator in RCrewAI. It manages a collection of agents and tasks, coordinating their execution to achieve complex goals.
10
+
11
+ ## Class Methods
12
+
13
+ ### `.new(name)`
14
+
15
+ Creates a new crew instance.
16
+
17
+ **Parameters:**
18
+ - `name` (String) - The name of the crew
19
+
20
+ **Returns:** `RCrewAI::Crew` instance
21
+
22
+ **Example:**
23
+ ```ruby
24
+ crew = RCrewAI::Crew.new("research_team")
25
+ ```
26
+
27
+ ### `.create(name)`
28
+
29
+ Creates and saves a new crew.
30
+
31
+ **Parameters:**
32
+ - `name` (String) - The name of the crew
33
+
34
+ **Returns:** `RCrewAI::Crew` instance
35
+
36
+ **Example:**
37
+ ```ruby
38
+ crew = RCrewAI::Crew.create("marketing_crew")
39
+ ```
40
+
41
+ ### `.load(name)`
42
+
43
+ Loads an existing crew from storage.
44
+
45
+ **Parameters:**
46
+ - `name` (String) - The name of the crew to load
47
+
48
+ **Returns:** `RCrewAI::Crew` instance
49
+
50
+ **Example:**
51
+ ```ruby
52
+ crew = RCrewAI::Crew.load("existing_crew")
53
+ ```
54
+
55
+ ### `.list`
56
+
57
+ Lists all available crews.
58
+
59
+ **Returns:** Array of crew names
60
+
61
+ **Example:**
62
+ ```ruby
63
+ crews = RCrewAI::Crew.list
64
+ # => ["research_crew", "marketing_crew", "development_crew"]
65
+ ```
66
+
67
+ ## Instance Methods
68
+
69
+ ### `#add_agent(agent)`
70
+
71
+ Adds an agent to the crew.
72
+
73
+ **Parameters:**
74
+ - `agent` (RCrewAI::Agent) - The agent to add
75
+
76
+ **Returns:** `self`
77
+
78
+ **Example:**
79
+ ```ruby
80
+ researcher = RCrewAI::Agent.new(name: "researcher", role: "Research Analyst", goal: "Find information")
81
+ crew.add_agent(researcher)
82
+ ```
83
+
84
+ ### `#add_task(task)`
85
+
86
+ Adds a task to the crew's workflow.
87
+
88
+ **Parameters:**
89
+ - `task` (RCrewAI::Task) - The task to add
90
+
91
+ **Returns:** `self`
92
+
93
+ **Example:**
94
+ ```ruby
95
+ task = RCrewAI::Task.new(name: "research", description: "Research AI trends", agent: researcher)
96
+ crew.add_task(task)
97
+ ```
98
+
99
+ ### `#execute`
100
+
101
+ Executes all tasks in the crew's workflow.
102
+
103
+ **Returns:** Hash with execution results
104
+
105
+ **Example:**
106
+ ```ruby
107
+ results = crew.execute
108
+ puts results[:status] # => "completed"
109
+ puts results[:tasks] # => Array of task results
110
+ ```
111
+
112
+ ### `#execute_async`
113
+
114
+ Executes tasks asynchronously.
115
+
116
+ **Returns:** Future object with execution results
117
+
118
+ **Example:**
119
+ ```ruby
120
+ future = crew.execute_async
121
+ # Do other work...
122
+ results = future.value # Block until complete
123
+ ```
124
+
125
+ ### `#save`
126
+
127
+ Saves the crew configuration to storage.
128
+
129
+ **Returns:** Boolean indicating success
130
+
131
+ **Example:**
132
+ ```ruby
133
+ if crew.save
134
+ puts "Crew saved successfully"
135
+ end
136
+ ```
137
+
138
+ ### `#agents`
139
+
140
+ Returns all agents in the crew.
141
+
142
+ **Returns:** Array of `RCrewAI::Agent` instances
143
+
144
+ **Example:**
145
+ ```ruby
146
+ crew.agents.each do |agent|
147
+ puts "Agent: #{agent.name} - Role: #{agent.role}"
148
+ end
149
+ ```
150
+
151
+ ### `#tasks`
152
+
153
+ Returns all tasks in the crew's workflow.
154
+
155
+ **Returns:** Array of `RCrewAI::Task` instances
156
+
157
+ **Example:**
158
+ ```ruby
159
+ crew.tasks.each do |task|
160
+ puts "Task: #{task.name} - Assigned to: #{task.agent.name}"
161
+ end
162
+ ```
163
+
164
+ ### `#clear_agents`
165
+
166
+ Removes all agents from the crew.
167
+
168
+ **Returns:** `self`
169
+
170
+ **Example:**
171
+ ```ruby
172
+ crew.clear_agents
173
+ ```
174
+
175
+ ### `#clear_tasks`
176
+
177
+ Removes all tasks from the crew's workflow.
178
+
179
+ **Returns:** `self`
180
+
181
+ **Example:**
182
+ ```ruby
183
+ crew.clear_tasks
184
+ ```
185
+
186
+ ## Attributes
187
+
188
+ ### `name` (readonly)
189
+
190
+ The name of the crew.
191
+
192
+ **Type:** String
193
+
194
+ **Example:**
195
+ ```ruby
196
+ puts crew.name # => "research_team"
197
+ ```
198
+
199
+ ### `process`
200
+
201
+ The execution process type for the crew.
202
+
203
+ **Type:** Symbol (`:sequential`, `:hierarchical`, `:consensual`)
204
+
205
+ **Default:** `:sequential`
206
+
207
+ **Example:**
208
+ ```ruby
209
+ crew.process = :hierarchical
210
+ ```
211
+
212
+ ### `verbose`
213
+
214
+ Whether to output detailed execution logs.
215
+
216
+ **Type:** Boolean
217
+
218
+ **Default:** `false`
219
+
220
+ **Example:**
221
+ ```ruby
222
+ crew.verbose = true
223
+ ```
224
+
225
+ ### `max_iterations`
226
+
227
+ Maximum number of iterations for task execution.
228
+
229
+ **Type:** Integer
230
+
231
+ **Default:** `10`
232
+
233
+ **Example:**
234
+ ```ruby
235
+ crew.max_iterations = 20
236
+ ```
237
+
238
+ ## Configuration Options
239
+
240
+ Crews can be configured with various options:
241
+
242
+ ```ruby
243
+ crew = RCrewAI::Crew.new("advanced_crew") do |c|
244
+ c.process = :hierarchical
245
+ c.verbose = true
246
+ c.max_iterations = 15
247
+ c.memory = true # Enable memory between tasks
248
+ c.cache = true # Enable result caching
249
+ end
250
+ ```
251
+
252
+ ## Events
253
+
254
+ Crews emit events during execution that can be hooked into:
255
+
256
+ ```ruby
257
+ crew.on(:task_started) do |task|
258
+ puts "Starting task: #{task.name}"
259
+ end
260
+
261
+ crew.on(:task_completed) do |task, result|
262
+ puts "Completed task: #{task.name}"
263
+ puts "Result: #{result}"
264
+ end
265
+
266
+ crew.on(:execution_complete) do |results|
267
+ puts "All tasks completed!"
268
+ end
269
+ ```
270
+
271
+ ## Error Handling
272
+
273
+ ```ruby
274
+ begin
275
+ results = crew.execute
276
+ rescue RCrewAI::ExecutionError => e
277
+ puts "Execution failed: #{e.message}"
278
+ puts "Failed task: #{e.task.name}"
279
+ rescue RCrewAI::ConfigurationError => e
280
+ puts "Configuration error: #{e.message}"
281
+ end
282
+ ```
283
+
284
+ ## Examples
285
+
286
+ ### Basic Crew Setup
287
+
288
+ ```ruby
289
+ # Create a crew
290
+ crew = RCrewAI::Crew.new("content_team")
291
+
292
+ # Add agents
293
+ writer = RCrewAI::Agent.new(
294
+ name: "writer",
295
+ role: "Content Writer",
296
+ goal: "Write engaging content"
297
+ )
298
+ editor = RCrewAI::Agent.new(
299
+ name: "editor",
300
+ role: "Content Editor",
301
+ goal: "Ensure content quality"
302
+ )
303
+
304
+ crew.add_agent(writer)
305
+ crew.add_agent(editor)
306
+
307
+ # Add tasks
308
+ writing_task = RCrewAI::Task.new(
309
+ name: "write_article",
310
+ description: "Write an article about Ruby",
311
+ agent: writer
312
+ )
313
+ editing_task = RCrewAI::Task.new(
314
+ name: "edit_article",
315
+ description: "Edit and polish the article",
316
+ agent: editor,
317
+ context: [writing_task]
318
+ )
319
+
320
+ crew.add_task(writing_task)
321
+ crew.add_task(editing_task)
322
+
323
+ # Execute
324
+ results = crew.execute
325
+ ```
326
+
327
+ ### Hierarchical Process
328
+
329
+ ```ruby
330
+ crew = RCrewAI::Crew.new("management_team")
331
+ crew.process = :hierarchical
332
+
333
+ # Add a manager agent
334
+ manager = RCrewAI::Agent.new(
335
+ name: "manager",
336
+ role: "Project Manager",
337
+ goal: "Coordinate team efforts",
338
+ allow_delegation: true
339
+ )
340
+
341
+ crew.add_agent(manager)
342
+ # Add other agents...
343
+
344
+ crew.execute
345
+ ```
data/docs/api/index.md ADDED
@@ -0,0 +1,41 @@
1
+ ---
2
+ layout: api
3
+ title: API Reference
4
+ description: Complete API documentation for RCrewAI
5
+ ---
6
+
7
+ # API Reference
8
+
9
+ Complete documentation for all RCrewAI classes and methods.
10
+
11
+ ## Core Classes
12
+
13
+ ### [RCrewAI::Crew]({{ site.baseurl }}/api/crew)
14
+ The main orchestrator that manages agents and tasks.
15
+
16
+ ### [RCrewAI::Agent]({{ site.baseurl }}/api/agent)
17
+ Individual AI agents with specific roles and capabilities.
18
+
19
+ ### [RCrewAI::Task]({{ site.baseurl }}/api/task)
20
+ Tasks that agents execute to achieve goals.
21
+
22
+ ## Tools
23
+
24
+ ### [RCrewAI::Tools::WebSearch]({{ site.baseurl }}/api/tools/web-search)
25
+ Enable agents to search the web for information.
26
+
27
+ ### [RCrewAI::Tools::FileSystem]({{ site.baseurl }}/api/tools/file-system)
28
+ Allow agents to read and write files.
29
+
30
+ ### [RCrewAI::Tools::Database]({{ site.baseurl }}/api/tools/database)
31
+ Connect agents to databases for data operations.
32
+
33
+ ## Configuration
34
+
35
+ ### [RCrewAI::Configuration]({{ site.baseurl }}/api/configuration)
36
+ Configure LLM providers and other settings.
37
+
38
+ ## CLI
39
+
40
+ ### [RCrewAI::CLI]({{ site.baseurl }}/api/cli)
41
+ Command-line interface for managing crews.