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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +108 -0
- data/LICENSE +21 -0
- data/README.md +328 -0
- data/Rakefile +130 -0
- data/bin/rcrewai +7 -0
- data/docs/_config.yml +59 -0
- data/docs/_layouts/api.html +16 -0
- data/docs/_layouts/default.html +78 -0
- data/docs/_layouts/example.html +24 -0
- data/docs/_layouts/tutorial.html +33 -0
- data/docs/api/configuration.md +327 -0
- data/docs/api/crew.md +345 -0
- data/docs/api/index.md +41 -0
- data/docs/api/tools.md +412 -0
- data/docs/assets/css/style.css +416 -0
- data/docs/examples/human-in-the-loop.md +382 -0
- data/docs/examples/index.md +78 -0
- data/docs/examples/production-ready-crew.md +485 -0
- data/docs/examples/simple-research-crew.md +297 -0
- data/docs/index.md +353 -0
- data/docs/tutorials/getting-started.md +341 -0
- data/examples/async_execution_example.rb +294 -0
- data/examples/hierarchical_crew_example.rb +193 -0
- data/examples/human_in_the_loop_example.rb +233 -0
- data/lib/rcrewai/agent.rb +636 -0
- data/lib/rcrewai/async_executor.rb +248 -0
- data/lib/rcrewai/cli.rb +39 -0
- data/lib/rcrewai/configuration.rb +100 -0
- data/lib/rcrewai/crew.rb +292 -0
- data/lib/rcrewai/human_input.rb +520 -0
- data/lib/rcrewai/llm_client.rb +41 -0
- data/lib/rcrewai/llm_clients/anthropic.rb +127 -0
- data/lib/rcrewai/llm_clients/azure.rb +158 -0
- data/lib/rcrewai/llm_clients/base.rb +82 -0
- data/lib/rcrewai/llm_clients/google.rb +158 -0
- data/lib/rcrewai/llm_clients/ollama.rb +199 -0
- data/lib/rcrewai/llm_clients/openai.rb +124 -0
- data/lib/rcrewai/memory.rb +194 -0
- data/lib/rcrewai/process.rb +421 -0
- data/lib/rcrewai/task.rb +376 -0
- data/lib/rcrewai/tools/base.rb +82 -0
- data/lib/rcrewai/tools/code_executor.rb +333 -0
- data/lib/rcrewai/tools/email_sender.rb +210 -0
- data/lib/rcrewai/tools/file_reader.rb +111 -0
- data/lib/rcrewai/tools/file_writer.rb +115 -0
- data/lib/rcrewai/tools/pdf_processor.rb +342 -0
- data/lib/rcrewai/tools/sql_database.rb +226 -0
- data/lib/rcrewai/tools/web_search.rb +131 -0
- data/lib/rcrewai/version.rb +5 -0
- data/lib/rcrewai.rb +36 -0
- data/rcrewai.gemspec +54 -0
- metadata +365 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ site.title }}</title>
|
7
|
+
<meta name="description" content="{{ page.description | default: site.description }}">
|
8
|
+
|
9
|
+
<!-- CSS -->
|
10
|
+
<link rel="stylesheet" href="{{ '/assets/css/style.css' | relative_url }}">
|
11
|
+
|
12
|
+
<!-- Syntax highlighting -->
|
13
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
|
14
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
15
|
+
<script>hljs.highlightAll();</script>
|
16
|
+
|
17
|
+
<!-- SEO -->
|
18
|
+
{% seo %}
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<nav class="navbar">
|
22
|
+
<div class="nav-container">
|
23
|
+
<a href="{{ site.baseurl }}/" class="nav-brand">{{ site.title }}</a>
|
24
|
+
<div class="nav-menu">
|
25
|
+
{% for item in site.navigation %}
|
26
|
+
<a href="{{ item.url | relative_url }}" class="nav-link">{{ item.title }}</a>
|
27
|
+
{% endfor %}
|
28
|
+
</div>
|
29
|
+
<div class="nav-mobile">
|
30
|
+
<button class="nav-toggle" onclick="toggleNav()">☰</button>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
</nav>
|
34
|
+
|
35
|
+
<main class="main-content">
|
36
|
+
<div class="container">
|
37
|
+
{{ content }}
|
38
|
+
</div>
|
39
|
+
</main>
|
40
|
+
|
41
|
+
<footer class="footer">
|
42
|
+
<div class="container">
|
43
|
+
<div class="footer-content">
|
44
|
+
<div class="footer-section">
|
45
|
+
<h4>RCrewAI</h4>
|
46
|
+
<p>Build AI agent crews in Ruby</p>
|
47
|
+
</div>
|
48
|
+
<div class="footer-section">
|
49
|
+
<h4>Documentation</h4>
|
50
|
+
<ul>
|
51
|
+
<li><a href="{{ site.baseurl }}/tutorials/">Tutorials</a></li>
|
52
|
+
<li><a href="{{ site.baseurl }}/api/">API Reference</a></li>
|
53
|
+
<li><a href="{{ site.baseurl }}/examples/">Examples</a></li>
|
54
|
+
</ul>
|
55
|
+
</div>
|
56
|
+
<div class="footer-section">
|
57
|
+
<h4>Community</h4>
|
58
|
+
<ul>
|
59
|
+
<li><a href="https://github.com/gkosmo/rcrewAI">GitHub</a></li>
|
60
|
+
<li><a href="https://github.com/gkosmo/rcrewAI/issues">Issues</a></li>
|
61
|
+
<li><a href="https://github.com/gkosmo/rcrewAI/discussions">Discussions</a></li>
|
62
|
+
</ul>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
<div class="footer-bottom">
|
66
|
+
<p>© 2024 RCrewAI. Released under the MIT License.</p>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
</footer>
|
70
|
+
|
71
|
+
<script>
|
72
|
+
function toggleNav() {
|
73
|
+
const navMenu = document.querySelector('.nav-menu');
|
74
|
+
navMenu.classList.toggle('active');
|
75
|
+
}
|
76
|
+
</script>
|
77
|
+
</body>
|
78
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
---
|
4
|
+
|
5
|
+
<article class="example">
|
6
|
+
<header class="example-header">
|
7
|
+
<h1>{{ page.title }}</h1>
|
8
|
+
{% if page.description %}
|
9
|
+
<p class="lead">{{ page.description }}</p>
|
10
|
+
{% endif %}
|
11
|
+
</header>
|
12
|
+
|
13
|
+
<div class="example-content">
|
14
|
+
{{ content }}
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<footer class="example-footer">
|
18
|
+
<div class="example-actions">
|
19
|
+
<a href="https://github.com/gkosmo/rcrewAI/tree/main/examples" class="btn btn-secondary">
|
20
|
+
View All Examples on GitHub
|
21
|
+
</a>
|
22
|
+
</div>
|
23
|
+
</footer>
|
24
|
+
</article>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
---
|
4
|
+
|
5
|
+
<article class="tutorial">
|
6
|
+
<header class="tutorial-header">
|
7
|
+
<h1>{{ page.title }}</h1>
|
8
|
+
{% if page.description %}
|
9
|
+
<p class="lead">{{ page.description }}</p>
|
10
|
+
{% endif %}
|
11
|
+
</header>
|
12
|
+
|
13
|
+
<div class="tutorial-content">
|
14
|
+
{{ content }}
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<nav class="tutorial-navigation">
|
18
|
+
<div class="nav-previous">
|
19
|
+
{% if page.previous %}
|
20
|
+
<a href="{{ page.previous.url | relative_url }}">
|
21
|
+
← {{ page.previous.title }}
|
22
|
+
</a>
|
23
|
+
{% endif %}
|
24
|
+
</div>
|
25
|
+
<div class="nav-next">
|
26
|
+
{% if page.next %}
|
27
|
+
<a href="{{ page.next.url | relative_url }}">
|
28
|
+
{{ page.next.title }} →
|
29
|
+
</a>
|
30
|
+
{% endif %}
|
31
|
+
</div>
|
32
|
+
</nav>
|
33
|
+
</article>
|
@@ -0,0 +1,327 @@
|
|
1
|
+
---
|
2
|
+
layout: api
|
3
|
+
title: RCrewAI::Configuration
|
4
|
+
description: Configuration system for LLM providers and settings
|
5
|
+
---
|
6
|
+
|
7
|
+
# RCrewAI::Configuration
|
8
|
+
|
9
|
+
The Configuration class manages settings for various LLM providers and global options for RCrewAI.
|
10
|
+
|
11
|
+
## Supported Providers
|
12
|
+
|
13
|
+
RCrewAI supports the following LLM providers:
|
14
|
+
|
15
|
+
- **OpenAI** (GPT-4, GPT-3.5-turbo, etc.)
|
16
|
+
- **Anthropic** (Claude 3, Claude 2, etc.)
|
17
|
+
- **Google** (Gemini Pro, PaLM, etc.)
|
18
|
+
- **Azure OpenAI** (Azure-hosted OpenAI models)
|
19
|
+
- **Ollama** (Local/self-hosted models)
|
20
|
+
|
21
|
+
## Basic Configuration
|
22
|
+
|
23
|
+
### Using Environment Variables (Recommended)
|
24
|
+
|
25
|
+
Set your API keys as environment variables:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
export OPENAI_API_KEY="your-openai-key"
|
29
|
+
export ANTHROPIC_API_KEY="your-anthropic-key"
|
30
|
+
export GOOGLE_API_KEY="your-google-key"
|
31
|
+
export AZURE_OPENAI_API_KEY="your-azure-key"
|
32
|
+
```
|
33
|
+
|
34
|
+
Then configure RCrewAI:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
RCrewAI.configure do |config|
|
38
|
+
config.llm_provider = :openai # or :anthropic, :google, :azure, :ollama
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
### Direct Configuration
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
RCrewAI.configure do |config|
|
46
|
+
config.llm_provider = :openai
|
47
|
+
config.openai_api_key = "your-openai-key"
|
48
|
+
config.openai_model = "gpt-4"
|
49
|
+
config.temperature = 0.1
|
50
|
+
config.max_tokens = 4000
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
## Provider-Specific Configuration
|
55
|
+
|
56
|
+
### OpenAI
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
RCrewAI.configure do |config|
|
60
|
+
config.llm_provider = :openai
|
61
|
+
config.openai_api_key = ENV['OPENAI_API_KEY']
|
62
|
+
config.openai_model = 'gpt-4' # or 'gpt-3.5-turbo', 'gpt-4-turbo'
|
63
|
+
config.temperature = 0.1
|
64
|
+
config.max_tokens = 4000
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
**Available Models:**
|
69
|
+
- `gpt-4`
|
70
|
+
- `gpt-4-turbo`
|
71
|
+
- `gpt-3.5-turbo`
|
72
|
+
- `gpt-3.5-turbo-16k`
|
73
|
+
|
74
|
+
### Anthropic (Claude)
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
RCrewAI.configure do |config|
|
78
|
+
config.llm_provider = :anthropic
|
79
|
+
config.anthropic_api_key = ENV['ANTHROPIC_API_KEY']
|
80
|
+
config.anthropic_model = 'claude-3-sonnet-20240229'
|
81
|
+
config.temperature = 0.1
|
82
|
+
config.max_tokens = 4000
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
**Available Models:**
|
87
|
+
- `claude-3-opus-20240229`
|
88
|
+
- `claude-3-sonnet-20240229`
|
89
|
+
- `claude-3-haiku-20240307`
|
90
|
+
- `claude-2.1`
|
91
|
+
- `claude-2.0`
|
92
|
+
|
93
|
+
### Google (Gemini)
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
RCrewAI.configure do |config|
|
97
|
+
config.llm_provider = :google
|
98
|
+
config.google_api_key = ENV['GOOGLE_API_KEY']
|
99
|
+
config.google_model = 'gemini-pro'
|
100
|
+
config.temperature = 0.1
|
101
|
+
config.max_tokens = 4000
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
**Available Models:**
|
106
|
+
- `gemini-pro`
|
107
|
+
- `gemini-pro-vision`
|
108
|
+
- `text-bison-001`
|
109
|
+
|
110
|
+
### Azure OpenAI
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
RCrewAI.configure do |config|
|
114
|
+
config.llm_provider = :azure
|
115
|
+
config.azure_api_key = ENV['AZURE_OPENAI_API_KEY']
|
116
|
+
config.base_url = "https://your-resource.openai.azure.com/"
|
117
|
+
config.api_version = "2023-05-15"
|
118
|
+
config.deployment_name = "your-deployment-name"
|
119
|
+
config.azure_model = 'gpt-4'
|
120
|
+
end
|
121
|
+
```
|
122
|
+
|
123
|
+
### Ollama (Local Models)
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
RCrewAI.configure do |config|
|
127
|
+
config.llm_provider = :ollama
|
128
|
+
config.base_url = "http://localhost:11434" # Default Ollama URL
|
129
|
+
config.model = "llama2" # or any installed Ollama model
|
130
|
+
config.temperature = 0.1
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
134
|
+
## Configuration Methods
|
135
|
+
|
136
|
+
### `RCrewAI.configure`
|
137
|
+
|
138
|
+
Configure RCrewAI with a block:
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
RCrewAI.configure do |config|
|
142
|
+
config.llm_provider = :openai
|
143
|
+
config.temperature = 0.2
|
144
|
+
config.max_tokens = 2000
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
148
|
+
### `RCrewAI.configuration`
|
149
|
+
|
150
|
+
Access the current configuration:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
config = RCrewAI.configuration
|
154
|
+
puts config.llm_provider # => :openai
|
155
|
+
puts config.model # => "gpt-4"
|
156
|
+
```
|
157
|
+
|
158
|
+
### `RCrewAI.reset_configuration!`
|
159
|
+
|
160
|
+
Reset configuration to defaults:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
RCrewAI.reset_configuration!
|
164
|
+
```
|
165
|
+
|
166
|
+
## Configuration Options
|
167
|
+
|
168
|
+
### Core Settings
|
169
|
+
|
170
|
+
| Option | Type | Default | Description |
|
171
|
+
|--------|------|---------|-------------|
|
172
|
+
| `llm_provider` | Symbol | `:openai` | LLM provider to use |
|
173
|
+
| `temperature` | Float | `0.1` | Sampling temperature (0.0 - 2.0) |
|
174
|
+
| `max_tokens` | Integer | `4000` | Maximum tokens in response |
|
175
|
+
| `timeout` | Integer | `120` | Request timeout in seconds |
|
176
|
+
|
177
|
+
### Provider-Specific Keys
|
178
|
+
|
179
|
+
| Option | Environment Variable | Description |
|
180
|
+
|--------|---------------------|-------------|
|
181
|
+
| `openai_api_key` | `OPENAI_API_KEY` | OpenAI API key |
|
182
|
+
| `anthropic_api_key` | `ANTHROPIC_API_KEY` | Anthropic API key |
|
183
|
+
| `google_api_key` | `GOOGLE_API_KEY` | Google API key |
|
184
|
+
| `azure_api_key` | `AZURE_OPENAI_API_KEY` | Azure OpenAI API key |
|
185
|
+
|
186
|
+
### Provider-Specific Models
|
187
|
+
|
188
|
+
| Option | Default | Description |
|
189
|
+
|--------|---------|-------------|
|
190
|
+
| `openai_model` | `gpt-4` | OpenAI model name |
|
191
|
+
| `anthropic_model` | `claude-3-sonnet-20240229` | Anthropic model name |
|
192
|
+
| `google_model` | `gemini-pro` | Google model name |
|
193
|
+
| `azure_model` | `gpt-4` | Azure OpenAI model name |
|
194
|
+
|
195
|
+
### Azure-Specific Settings
|
196
|
+
|
197
|
+
| Option | Environment Variable | Description |
|
198
|
+
|--------|---------------------|-------------|
|
199
|
+
| `base_url` | `LLM_BASE_URL` | Azure OpenAI endpoint URL |
|
200
|
+
| `api_version` | `AZURE_API_VERSION` | Azure API version |
|
201
|
+
| `deployment_name` | `AZURE_DEPLOYMENT_NAME` | Azure deployment name |
|
202
|
+
|
203
|
+
## Dynamic Provider Switching
|
204
|
+
|
205
|
+
You can switch providers at runtime:
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
# Start with OpenAI
|
209
|
+
RCrewAI.configure do |config|
|
210
|
+
config.llm_provider = :openai
|
211
|
+
config.openai_api_key = ENV['OPENAI_API_KEY']
|
212
|
+
end
|
213
|
+
|
214
|
+
crew = RCrewAI::Crew.new("test_crew")
|
215
|
+
# ... create agents and tasks
|
216
|
+
|
217
|
+
# Switch to Anthropic for specific tasks
|
218
|
+
RCrewAI.configure do |config|
|
219
|
+
config.llm_provider = :anthropic
|
220
|
+
config.anthropic_api_key = ENV['ANTHROPIC_API_KEY']
|
221
|
+
end
|
222
|
+
|
223
|
+
different_crew = RCrewAI::Crew.new("claude_crew")
|
224
|
+
# This crew will use Claude models
|
225
|
+
```
|
226
|
+
|
227
|
+
## Environment Variables
|
228
|
+
|
229
|
+
RCrewAI automatically loads configuration from environment variables:
|
230
|
+
|
231
|
+
```bash
|
232
|
+
# Provider API Keys
|
233
|
+
export OPENAI_API_KEY="sk-..."
|
234
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
235
|
+
export GOOGLE_API_KEY="AIza..."
|
236
|
+
export AZURE_OPENAI_API_KEY="..."
|
237
|
+
|
238
|
+
# Azure Specific
|
239
|
+
export AZURE_API_VERSION="2023-05-15"
|
240
|
+
export AZURE_DEPLOYMENT_NAME="gpt-4-deployment"
|
241
|
+
export LLM_BASE_URL="https://your-resource.openai.azure.com/"
|
242
|
+
|
243
|
+
# General fallback
|
244
|
+
export LLM_API_KEY="fallback-key"
|
245
|
+
```
|
246
|
+
|
247
|
+
## Configuration Validation
|
248
|
+
|
249
|
+
RCrewAI validates configuration when `configure` is called:
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
begin
|
253
|
+
RCrewAI.configure do |config|
|
254
|
+
config.llm_provider = :invalid_provider
|
255
|
+
end
|
256
|
+
rescue RCrewAI::ConfigurationError => e
|
257
|
+
puts "Configuration error: #{e.message}"
|
258
|
+
end
|
259
|
+
```
|
260
|
+
|
261
|
+
## Multiple Configurations
|
262
|
+
|
263
|
+
For applications that need multiple configurations:
|
264
|
+
|
265
|
+
```ruby
|
266
|
+
# Save current config
|
267
|
+
old_config = RCrewAI.configuration.dup
|
268
|
+
|
269
|
+
# Configure for specific task
|
270
|
+
RCrewAI.configure do |config|
|
271
|
+
config.llm_provider = :anthropic
|
272
|
+
config.temperature = 0.8
|
273
|
+
end
|
274
|
+
|
275
|
+
# Do work with Claude...
|
276
|
+
|
277
|
+
# Restore original config
|
278
|
+
RCrewAI.reset_configuration!
|
279
|
+
# Re-apply old config...
|
280
|
+
```
|
281
|
+
|
282
|
+
## Best Practices
|
283
|
+
|
284
|
+
1. **Use Environment Variables**: Store API keys in environment variables, not in code
|
285
|
+
2. **Provider Selection**: Choose providers based on task requirements:
|
286
|
+
- OpenAI GPT-4: General-purpose, high quality
|
287
|
+
- Claude: Great for analysis and reasoning
|
288
|
+
- Gemini: Good for creative tasks
|
289
|
+
- Azure: Enterprise requirements
|
290
|
+
- Ollama: Privacy-sensitive or offline use
|
291
|
+
3. **Temperature Settings**:
|
292
|
+
- Low (0.1-0.3): Factual, consistent outputs
|
293
|
+
- Medium (0.5-0.7): Balanced creativity and consistency
|
294
|
+
- High (0.8-1.0): Creative, varied outputs
|
295
|
+
4. **Model Selection**: Use the most capable model your budget allows
|
296
|
+
5. **Timeout Settings**: Set appropriate timeouts for your use case
|
297
|
+
|
298
|
+
## Troubleshooting
|
299
|
+
|
300
|
+
### Common Issues
|
301
|
+
|
302
|
+
**"API key must be set" Error**
|
303
|
+
```ruby
|
304
|
+
# Ensure API key is set
|
305
|
+
RCrewAI.configure do |config|
|
306
|
+
config.llm_provider = :openai
|
307
|
+
config.openai_api_key = ENV['OPENAI_API_KEY'] # Make sure this env var exists
|
308
|
+
end
|
309
|
+
```
|
310
|
+
|
311
|
+
**"Unsupported provider" Error**
|
312
|
+
```ruby
|
313
|
+
# Check supported providers
|
314
|
+
puts RCrewAI.configuration.supported_providers
|
315
|
+
# => [:openai, :anthropic, :google, :azure, :ollama]
|
316
|
+
```
|
317
|
+
|
318
|
+
**Azure Configuration Issues**
|
319
|
+
```ruby
|
320
|
+
RCrewAI.configure do |config|
|
321
|
+
config.llm_provider = :azure
|
322
|
+
config.azure_api_key = ENV['AZURE_OPENAI_API_KEY']
|
323
|
+
config.base_url = "https://your-resource.openai.azure.com/" # Include trailing slash
|
324
|
+
config.api_version = "2023-05-15" # Use supported API version
|
325
|
+
config.deployment_name = "your-deployment-name" # Exact deployment name
|
326
|
+
end
|
327
|
+
```
|