rcrewai 0.10.0 → 0.11.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 +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +133 -23
- data/ROADMAP.md +1 -1
- data/docs/api/agent.md +5 -2
- data/docs/api/configuration.md +36 -41
- data/docs/api/crew.md +34 -48
- data/docs/api/index.md +7 -0
- data/docs/api/task.md +10 -91
- data/docs/api/tools.md +19 -0
- data/docs/examples/api-integration.md +4 -4
- data/docs/examples/async-execution.md +4 -4
- data/docs/examples/code-review-crew.md +1 -1
- data/docs/examples/content-marketing-pipeline.md +3 -3
- data/docs/examples/custom-tools.md +8 -8
- data/docs/examples/customer-support.md +5 -5
- data/docs/examples/data-analysis-team.md +4 -4
- data/docs/examples/database-operations.md +4 -4
- data/docs/examples/ecommerce-operations.md +4 -4
- data/docs/examples/financial-analysis.md +3 -3
- data/docs/examples/hierarchical-crew.md +3 -2
- data/docs/examples/production-ready-crew.md +16 -10
- data/docs/examples/research-development.md +5 -5
- data/docs/examples/simple-research-crew.md +2 -2
- data/docs/examples/social-media.md +4 -4
- data/docs/examples/task-automation.md +2 -2
- data/docs/examples/tool-composition.md +42 -27
- data/docs/examples/web-scraping.md +6 -6
- data/docs/index.md +61 -44
- data/docs/tutorials/advanced-agents.md +194 -917
- data/docs/tutorials/agent-options.md +1 -1
- data/docs/tutorials/checkpointing.md +65 -0
- data/docs/tutorials/concurrency.md +57 -0
- data/docs/tutorials/custom-tools.md +198 -1143
- data/docs/tutorials/deployment.md +156 -155
- data/docs/tutorials/getting-started.md +69 -81
- data/docs/tutorials/index.md +19 -0
- data/docs/tutorials/interceptors-and-events.md +84 -0
- data/docs/tutorials/live-streaming.md +52 -0
- data/docs/tutorials/multiple-crews.md +70 -51
- data/docs/tutorials/providers.md +115 -0
- data/docs/upgrading-to-0.11.md +55 -0
- data/lib/rcrewai/agent.rb +0 -2
- data/lib/rcrewai/configuration.rb +64 -29
- data/lib/rcrewai/context_window.rb +12 -2
- data/lib/rcrewai/llm_clients/anthropic.rb +60 -9
- data/lib/rcrewai/llm_clients/base.rb +7 -0
- data/lib/rcrewai/llm_clients/bedrock.rb +29 -2
- data/lib/rcrewai/llm_clients/google.rb +36 -4
- data/lib/rcrewai/llm_clients/ollama.rb +17 -3
- data/lib/rcrewai/llm_clients/openai.rb +14 -1
- data/lib/rcrewai/llm_clients/openai_responses.rb +21 -2
- data/lib/rcrewai/pricing.rb +13 -3
- data/lib/rcrewai/tool_runner.rb +5 -1
- data/lib/rcrewai/version.rb +1 -1
- metadata +7 -1
|
@@ -34,9 +34,9 @@ module RCrewAI
|
|
|
34
34
|
|
|
35
35
|
payload = {
|
|
36
36
|
model: options[:model] || config.model,
|
|
37
|
-
messages: format_messages(non_system),
|
|
37
|
+
messages: format_messages(non_system).map { |m| m.except(:tool_results) },
|
|
38
38
|
max_tokens: options[:max_tokens] || config.max_tokens || 1000,
|
|
39
|
-
temperature: options[:temperature] || config.
|
|
39
|
+
temperature: options[:temperature] || config.explicit_temperature
|
|
40
40
|
}.compact
|
|
41
41
|
|
|
42
42
|
if system_message
|
|
@@ -71,8 +71,9 @@ module RCrewAI
|
|
|
71
71
|
|
|
72
72
|
def models
|
|
73
73
|
%w[
|
|
74
|
-
claude-opus-
|
|
75
|
-
claude-
|
|
74
|
+
claude-fable-5-1 claude-opus-5-5 claude-sonnet-5-5 claude-haiku-5-5
|
|
75
|
+
claude-opus-5 claude-sonnet-5 claude-opus-4-8 claude-opus-4-7
|
|
76
|
+
claude-sonnet-4-6 claude-haiku-4-5
|
|
76
77
|
]
|
|
77
78
|
end
|
|
78
79
|
|
|
@@ -102,6 +103,8 @@ module RCrewAI
|
|
|
102
103
|
assembled_text = +''
|
|
103
104
|
# tool_use blocks keyed by content-block index
|
|
104
105
|
blocks = {}
|
|
106
|
+
# Every content block as the API sent it, for replay in a tool loop
|
|
107
|
+
raw_blocks = {}
|
|
105
108
|
finish_reason = nil
|
|
106
109
|
prompt_tokens = nil
|
|
107
110
|
cached_tokens = nil
|
|
@@ -115,9 +118,11 @@ module RCrewAI
|
|
|
115
118
|
cached_tokens = data.dig('message', 'usage', 'cache_read_input_tokens')
|
|
116
119
|
when 'content_block_start'
|
|
117
120
|
cb = data['content_block'] || {}
|
|
121
|
+
raw_blocks[data['index']] = cb.dup
|
|
118
122
|
blocks[data['index']] = { id: cb['id'], name: cb['name'], arguments: +'' } if cb['type'] == 'tool_use'
|
|
119
123
|
when 'content_block_delta'
|
|
120
124
|
delta = data['delta'] || {}
|
|
125
|
+
merge_raw_delta(raw_blocks[data['index']], delta)
|
|
121
126
|
case delta['type']
|
|
122
127
|
when 'text_delta'
|
|
123
128
|
text = delta['text'].to_s
|
|
@@ -166,6 +171,7 @@ module RCrewAI
|
|
|
166
171
|
result = {
|
|
167
172
|
content: assembled_text.empty? ? nil : assembled_text,
|
|
168
173
|
tool_calls: tool_calls,
|
|
174
|
+
raw_content: assemble_raw_blocks(raw_blocks, tool_calls),
|
|
169
175
|
usage: usage,
|
|
170
176
|
finish_reason: finish_reason || :stop,
|
|
171
177
|
model: payload[:model],
|
|
@@ -175,6 +181,26 @@ module RCrewAI
|
|
|
175
181
|
end
|
|
176
182
|
|
|
177
183
|
# Streams over one kept-alive connection per client (see PersistentHTTP).
|
|
184
|
+
def merge_raw_delta(block, delta)
|
|
185
|
+
return unless block
|
|
186
|
+
|
|
187
|
+
case delta['type']
|
|
188
|
+
when 'text_delta' then block['text'] = "#{block['text']}#{delta['text']}"
|
|
189
|
+
when 'thinking_delta' then block['thinking'] = "#{block['thinking']}#{delta['thinking']}"
|
|
190
|
+
when 'signature_delta' then block['signature'] = "#{block['signature']}#{delta['signature']}"
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Tool arguments arrive as JSON fragments, already parsed into tool_calls.
|
|
195
|
+
def assemble_raw_blocks(raw_blocks, tool_calls)
|
|
196
|
+
raw_blocks.sort.map do |_index, block|
|
|
197
|
+
next block unless block['type'] == 'tool_use'
|
|
198
|
+
|
|
199
|
+
call = tool_calls.find { |c| c[:id] == block['id'] }
|
|
200
|
+
block.merge('input' => call ? call[:arguments] : {})
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
178
204
|
def streaming_post(payload, cancel: nil, &on_chunk)
|
|
179
205
|
uri = URI("#{@base_url}/messages")
|
|
180
206
|
response = streaming_connection.post_stream(
|
|
@@ -201,6 +227,7 @@ module RCrewAI
|
|
|
201
227
|
{
|
|
202
228
|
content: text.empty? ? nil : text,
|
|
203
229
|
tool_calls: tool_calls,
|
|
230
|
+
raw_content: content_blocks,
|
|
204
231
|
usage: {
|
|
205
232
|
prompt_tokens: prompt_tokens,
|
|
206
233
|
completion_tokens: completion_tokens,
|
|
@@ -227,15 +254,39 @@ module RCrewAI
|
|
|
227
254
|
end
|
|
228
255
|
|
|
229
256
|
def format_messages(messages)
|
|
230
|
-
messages.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
257
|
+
messages.each_with_object([]) do |msg, out|
|
|
258
|
+
next out << { role: 'user', content: msg.to_s } unless msg.is_a?(Hash)
|
|
259
|
+
|
|
260
|
+
case msg[:role].to_s
|
|
261
|
+
when 'assistant' then out << { role: 'assistant', content: assistant_content(msg) }
|
|
262
|
+
when 'tool' then append_tool_result(out, msg)
|
|
263
|
+
else out << { role: 'user', content: msg[:content] }
|
|
235
264
|
end
|
|
236
265
|
end
|
|
237
266
|
end
|
|
238
267
|
|
|
268
|
+
# A tool loop must replay the model's blocks unchanged, including thinking.
|
|
269
|
+
def assistant_content(msg)
|
|
270
|
+
return msg[:raw_content] if msg[:raw_content]
|
|
271
|
+
return msg[:content] if msg[:tool_calls].nil? || msg[:tool_calls].empty?
|
|
272
|
+
|
|
273
|
+
text = msg[:content].to_s.empty? ? [] : [{ type: 'text', text: msg[:content] }]
|
|
274
|
+
text + msg[:tool_calls].map do |call|
|
|
275
|
+
{ type: 'tool_use', id: call[:id], name: call[:name], input: call[:arguments] || {} }
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Results from one turn belong together in a single user message.
|
|
280
|
+
def append_tool_result(out, msg)
|
|
281
|
+
block = { type: 'tool_result', tool_use_id: msg[:tool_call_id], content: msg[:content] }
|
|
282
|
+
last = out.last
|
|
283
|
+
if last && last[:tool_results]
|
|
284
|
+
last[:content] << block
|
|
285
|
+
else
|
|
286
|
+
out << { role: 'user', content: [block], tool_results: true }
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
239
290
|
def validate_config!
|
|
240
291
|
raise ConfigurationError, 'Anthropic API key is required' unless config.anthropic_api_key || config.api_key
|
|
241
292
|
raise ConfigurationError, 'Model is required' unless config.model
|
|
@@ -75,6 +75,13 @@ module RCrewAI
|
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
# Takes the call a tool result answers out of +pending+: by id when there
|
|
79
|
+
# is one, otherwise the oldest, since results come back in call order.
|
|
80
|
+
def take_tool_call(pending, tool_call_id)
|
|
81
|
+
index = pending.index { |call| call[:id] && call[:id] == tool_call_id } || 0
|
|
82
|
+
pending.delete_at(index)
|
|
83
|
+
end
|
|
84
|
+
|
|
78
85
|
def hook_context
|
|
79
86
|
{ provider: provider_name, model: config.model }
|
|
80
87
|
end
|
|
@@ -84,8 +84,34 @@ module RCrewAI
|
|
|
84
84
|
|
|
85
85
|
# Every message content is a list of typed blocks.
|
|
86
86
|
def format_messages(messages)
|
|
87
|
-
messages.reject { |m| m.is_a?(Hash) && m[:role].to_s == 'system' }.
|
|
88
|
-
|
|
87
|
+
messages.reject { |m| m.is_a?(Hash) && m[:role].to_s == 'system' }.each_with_object([]) do |m, out|
|
|
88
|
+
case m[:role].to_s
|
|
89
|
+
when 'assistant' then out << { role: 'assistant', content: assistant_blocks(m) }
|
|
90
|
+
when 'tool' then append_tool_result(out, m)
|
|
91
|
+
else out << { role: m[:role].to_s, content: [{ text: m[:content].to_s }] }
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Blocks are replayed as received, so reasoning reaches the model unchanged.
|
|
97
|
+
def assistant_blocks(msg)
|
|
98
|
+
return msg[:raw_content] if msg[:raw_content]
|
|
99
|
+
return [{ text: msg[:content].to_s }] if msg[:tool_calls].nil? || msg[:tool_calls].empty?
|
|
100
|
+
|
|
101
|
+
text = msg[:content].to_s.empty? ? [] : [{ text: msg[:content] }]
|
|
102
|
+
text + msg[:tool_calls].map do |call|
|
|
103
|
+
{ toolUse: { toolUseId: call[:id], name: call[:name], input: call[:arguments] || {} } }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Converse alternates roles, so one turn's results share a user message.
|
|
108
|
+
def append_tool_result(out, msg)
|
|
109
|
+
block = { toolResult: { toolUseId: msg[:tool_call_id], content: [{ text: msg[:content].to_s }] } }
|
|
110
|
+
last = out.last
|
|
111
|
+
if last && last[:content].first.key?(:toolResult)
|
|
112
|
+
last[:content] << block
|
|
113
|
+
else
|
|
114
|
+
out << { role: 'user', content: [block] }
|
|
89
115
|
end
|
|
90
116
|
end
|
|
91
117
|
|
|
@@ -109,6 +135,7 @@ module RCrewAI
|
|
|
109
135
|
{
|
|
110
136
|
content: text.empty? ? nil : text,
|
|
111
137
|
tool_calls: tool_calls,
|
|
138
|
+
raw_content: blocks,
|
|
112
139
|
usage: {
|
|
113
140
|
prompt_tokens: body.dig('usage', 'inputTokens'),
|
|
114
141
|
completion_tokens: body.dig('usage', 'outputTokens'),
|
|
@@ -85,6 +85,7 @@ module RCrewAI
|
|
|
85
85
|
|
|
86
86
|
assembled_text = +''
|
|
87
87
|
tool_calls = []
|
|
88
|
+
raw_parts = []
|
|
88
89
|
finish_reason = nil
|
|
89
90
|
usage = nil
|
|
90
91
|
|
|
@@ -94,6 +95,7 @@ module RCrewAI
|
|
|
94
95
|
parts = candidate.dig('content', 'parts') || []
|
|
95
96
|
|
|
96
97
|
parts.each do |part|
|
|
98
|
+
raw_parts << part
|
|
97
99
|
if part['text']
|
|
98
100
|
text = part['text']
|
|
99
101
|
assembled_text << text
|
|
@@ -101,7 +103,7 @@ module RCrewAI
|
|
|
101
103
|
agent: nil, iteration: nil, text: text))
|
|
102
104
|
elsif part['functionCall']
|
|
103
105
|
fc = part['functionCall']
|
|
104
|
-
tool_calls << { id:
|
|
106
|
+
tool_calls << { id: fc['id'], name: fc['name'], arguments: fc['args'] || {} }
|
|
105
107
|
end
|
|
106
108
|
end
|
|
107
109
|
|
|
@@ -134,6 +136,7 @@ module RCrewAI
|
|
|
134
136
|
result = {
|
|
135
137
|
content: assembled_text.empty? ? nil : assembled_text,
|
|
136
138
|
tool_calls: tool_calls,
|
|
139
|
+
raw_content: raw_parts,
|
|
137
140
|
usage: usage || {},
|
|
138
141
|
finish_reason: finish_reason || :stop,
|
|
139
142
|
model: config.model,
|
|
@@ -160,7 +163,8 @@ module RCrewAI
|
|
|
160
163
|
parts = candidate.dig('content', 'parts') || []
|
|
161
164
|
text = parts.select { |p| p['text'] }.map { |p| p['text'] }.join
|
|
162
165
|
tool_calls = parts.select { |p| p['functionCall'] }.map do |p|
|
|
163
|
-
{ id:
|
|
166
|
+
{ id: p.dig('functionCall', 'id'), name: p.dig('functionCall', 'name'),
|
|
167
|
+
arguments: p.dig('functionCall', 'args') || {} }
|
|
164
168
|
end
|
|
165
169
|
usage_md = body['usageMetadata'] || {}
|
|
166
170
|
finish_reason = tool_calls.any? ? :tool_calls : (FINISH_REASON_MAP[candidate['finishReason']] || :stop)
|
|
@@ -168,6 +172,7 @@ module RCrewAI
|
|
|
168
172
|
{
|
|
169
173
|
content: text.empty? ? nil : text,
|
|
170
174
|
tool_calls: tool_calls,
|
|
175
|
+
raw_content: parts,
|
|
171
176
|
usage: {
|
|
172
177
|
prompt_tokens: usage_md['promptTokenCount'],
|
|
173
178
|
completion_tokens: usage_md['candidatesTokenCount'],
|
|
@@ -182,14 +187,17 @@ module RCrewAI
|
|
|
182
187
|
def format_messages(messages)
|
|
183
188
|
contents = []
|
|
184
189
|
system_msg = nil
|
|
190
|
+
pending = []
|
|
185
191
|
|
|
186
192
|
messages.each do |msg|
|
|
187
193
|
case msg[:role]
|
|
188
194
|
when 'system'
|
|
189
195
|
system_msg = msg[:content]
|
|
190
|
-
next
|
|
191
196
|
when 'assistant'
|
|
192
|
-
|
|
197
|
+
pending = Array(msg[:tool_calls]).dup
|
|
198
|
+
contents << { role: 'model', parts: model_parts(msg) }
|
|
199
|
+
when 'tool'
|
|
200
|
+
append_function_response(contents, msg, take_tool_call(pending, msg[:tool_call_id]))
|
|
193
201
|
else
|
|
194
202
|
contents << { role: 'user', parts: [{ text: msg[:content].to_s }] }
|
|
195
203
|
end
|
|
@@ -202,6 +210,30 @@ module RCrewAI
|
|
|
202
210
|
contents
|
|
203
211
|
end
|
|
204
212
|
|
|
213
|
+
# Parts are replayed as received because Gemini can attach thought
|
|
214
|
+
# signatures to them.
|
|
215
|
+
def model_parts(msg)
|
|
216
|
+
return msg[:raw_content] if msg[:raw_content]
|
|
217
|
+
return [{ text: msg[:content].to_s }] if msg[:tool_calls].nil? || msg[:tool_calls].empty?
|
|
218
|
+
|
|
219
|
+
text = msg[:content].to_s.empty? ? [] : [{ text: msg[:content] }]
|
|
220
|
+
text + msg[:tool_calls].map do |call|
|
|
221
|
+
{ functionCall: { id: call[:id], name: call[:name], args: call[:arguments] || {} }.compact }
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Results from one turn belong together in a single user content.
|
|
226
|
+
def append_function_response(contents, msg, call)
|
|
227
|
+
response = { id: call&.dig(:id), name: call&.dig(:name), response: { result: msg[:content] } }.compact
|
|
228
|
+
part = { functionResponse: response }
|
|
229
|
+
last = contents.last
|
|
230
|
+
if last && last[:parts].first.key?(:functionResponse)
|
|
231
|
+
last[:parts] << part
|
|
232
|
+
else
|
|
233
|
+
contents << { role: 'user', parts: [part] }
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
205
237
|
def validate_config!
|
|
206
238
|
raise ConfigurationError, 'Google API key is required' unless config.google_api_key || config.api_key
|
|
207
239
|
raise ConfigurationError, 'Model is required' unless config.model
|
|
@@ -213,15 +213,29 @@ module RCrewAI
|
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
def format_messages(messages)
|
|
216
|
+
pending = []
|
|
216
217
|
messages.map do |msg|
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
next { role: 'user', content: msg.to_s } unless msg.is_a?(Hash)
|
|
219
|
+
|
|
220
|
+
if msg[:tool_calls]&.any?
|
|
221
|
+
pending = msg[:tool_calls].dup
|
|
222
|
+
assistant_tool_message(msg)
|
|
223
|
+
elsif msg[:role].to_s == 'tool'
|
|
224
|
+
call = take_tool_call(pending, msg[:tool_call_id])
|
|
225
|
+
{ role: 'tool', content: msg[:content], tool_name: call&.dig(:name) }.compact
|
|
219
226
|
else
|
|
220
|
-
{ role:
|
|
227
|
+
{ role: msg[:role], content: msg[:content] }
|
|
221
228
|
end
|
|
222
229
|
end
|
|
223
230
|
end
|
|
224
231
|
|
|
232
|
+
def assistant_tool_message(msg)
|
|
233
|
+
{ role: 'assistant', content: msg[:content].to_s,
|
|
234
|
+
tool_calls: msg[:tool_calls].map do |call|
|
|
235
|
+
{ function: { name: call[:name], arguments: call[:arguments] || {} } }
|
|
236
|
+
end }
|
|
237
|
+
end
|
|
238
|
+
|
|
225
239
|
def ollama_url
|
|
226
240
|
ENV['OLLAMA_HOST'] || ENV['OLLAMA_URL']
|
|
227
241
|
end
|
|
@@ -21,7 +21,7 @@ module RCrewAI
|
|
|
21
21
|
def chat(messages:, tools: nil, tool_choice: :auto, stream: nil, **options)
|
|
22
22
|
payload = {
|
|
23
23
|
model: config.model,
|
|
24
|
-
messages: messages,
|
|
24
|
+
messages: format_chat_messages(messages),
|
|
25
25
|
temperature: options[:temperature] || config.temperature,
|
|
26
26
|
max_tokens: options[:max_tokens] || config.max_tokens
|
|
27
27
|
}.compact
|
|
@@ -192,6 +192,19 @@ module RCrewAI
|
|
|
192
192
|
}
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
+
# ToolRunner keeps calls as { id:, name:, arguments: }. Chat Completions
|
|
196
|
+
# wants them wrapped, with the arguments as a JSON string.
|
|
197
|
+
def format_chat_messages(messages)
|
|
198
|
+
messages.map do |msg|
|
|
199
|
+
next msg unless msg.is_a?(Hash) && msg[:tool_calls]&.any?
|
|
200
|
+
|
|
201
|
+
msg.merge(tool_calls: msg[:tool_calls].map do |call|
|
|
202
|
+
{ id: call[:id], type: 'function',
|
|
203
|
+
function: { name: call[:name], arguments: JSON.generate(call[:arguments] || {}) } }
|
|
204
|
+
end)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
195
208
|
def auth_header
|
|
196
209
|
{ 'Authorization' => "Bearer #{config.openai_api_key || config.api_key}" }
|
|
197
210
|
end
|
|
@@ -54,8 +54,26 @@ module RCrewAI
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def format_input(messages)
|
|
57
|
-
messages.reject { |m| m.is_a?(Hash) && m[:role].to_s == 'system' }
|
|
58
|
-
|
|
57
|
+
messages.reject { |m| m.is_a?(Hash) && m[:role].to_s == 'system' }.flat_map do |m|
|
|
58
|
+
case m[:role].to_s
|
|
59
|
+
when 'assistant' then assistant_items(m)
|
|
60
|
+
when 'tool' then [{ type: 'function_call_output', call_id: m[:tool_call_id], output: m[:content] }]
|
|
61
|
+
else [{ role: m[:role].to_s, content: m[:content] }]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Output items are replayed as received, because reasoning models need
|
|
67
|
+
# their reasoning items alongside the function calls.
|
|
68
|
+
def assistant_items(msg)
|
|
69
|
+
return msg[:raw_content] if msg[:raw_content]
|
|
70
|
+
return [{ role: 'assistant', content: msg[:content] }] if msg[:tool_calls].nil? || msg[:tool_calls].empty?
|
|
71
|
+
|
|
72
|
+
text = msg[:content].to_s.empty? ? [] : [{ role: 'assistant', content: msg[:content] }]
|
|
73
|
+
text + msg[:tool_calls].map do |call|
|
|
74
|
+
{ type: 'function_call', call_id: call[:id], name: call[:name],
|
|
75
|
+
arguments: JSON.generate(call[:arguments] || {}) }
|
|
76
|
+
end
|
|
59
77
|
end
|
|
60
78
|
|
|
61
79
|
# Responses flattens the function definition instead of nesting it under
|
|
@@ -75,6 +93,7 @@ module RCrewAI
|
|
|
75
93
|
{
|
|
76
94
|
content: text.empty? ? nil : text,
|
|
77
95
|
tool_calls: tool_calls,
|
|
96
|
+
raw_content: output,
|
|
78
97
|
usage: {
|
|
79
98
|
prompt_tokens: body.dig('usage', 'input_tokens'),
|
|
80
99
|
completion_tokens: body.dig('usage', 'output_tokens'),
|
data/lib/rcrewai/pricing.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module RCrewAI
|
|
4
4
|
module Pricing
|
|
5
|
-
# Prices in USD per 1M tokens. List prices as of 2026-
|
|
5
|
+
# Prices in USD per 1M tokens. List prices as of 2026-11; users can override.
|
|
6
6
|
DEFAULT_PRICES = {
|
|
7
7
|
# OpenAI
|
|
8
8
|
'gpt-4o' => { input: 2.50, output: 10.00 },
|
|
@@ -11,12 +11,22 @@ module RCrewAI
|
|
|
11
11
|
'gpt-4' => { input: 30.00, output: 60.00 },
|
|
12
12
|
'gpt-3.5-turbo' => { input: 0.50, output: 1.50 },
|
|
13
13
|
# Anthropic
|
|
14
|
-
'claude-
|
|
14
|
+
'claude-fable-5-1' => { input: 10.00, output: 50.00 },
|
|
15
|
+
'claude-opus-5-5' => { input: 4.00, output: 20.00 },
|
|
16
|
+
'claude-opus-5' => { input: 5.00, output: 25.00 },
|
|
17
|
+
'claude-opus-4-8' => { input: 5.00, output: 25.00 },
|
|
18
|
+
'claude-opus-4-7' => { input: 5.00, output: 25.00 },
|
|
19
|
+
'claude-opus-4-6' => { input: 5.00, output: 25.00 },
|
|
20
|
+
'claude-sonnet-5-5' => { input: 2.00, output: 10.00 },
|
|
21
|
+
'claude-sonnet-5' => { input: 2.00, output: 10.00 },
|
|
15
22
|
'claude-sonnet-4-6' => { input: 3.00, output: 15.00 },
|
|
16
|
-
'claude-haiku-
|
|
23
|
+
'claude-haiku-5-5' => { input: 0.10, output: 0.50 }, # prompts up to 100K tokens
|
|
24
|
+
'claude-haiku-4-5' => { input: 1.00, output: 5.00 },
|
|
17
25
|
'claude-3-5-sonnet-20241022' => { input: 3.00, output: 15.00 },
|
|
18
26
|
'claude-3-haiku-20240307' => { input: 0.25, output: 1.25 },
|
|
19
27
|
# Google
|
|
28
|
+
'gemini-3.8-flash' => { input: 0.75, output: 3.75 }, # $1.50/$7.50 from 2027-01-01
|
|
29
|
+
'gemini-3.5-flash-lite' => { input: 0.30, output: 2.50 },
|
|
20
30
|
'gemini-1.5-pro' => { input: 1.25, output: 5.00 },
|
|
21
31
|
'gemini-1.5-flash' => { input: 0.075, output: 0.30 }
|
|
22
32
|
}.freeze
|
data/lib/rcrewai/tool_runner.rb
CHANGED
|
@@ -50,7 +50,11 @@ module RCrewAI
|
|
|
50
50
|
finish_reason: response[:finish_reason], usage: total_usage)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
assistant = { role: 'assistant', content: response[:content], tool_calls: response[:tool_calls] }
|
|
54
|
+
# Providers that must see their own response replayed verbatim (Anthropic
|
|
55
|
+
# thinking blocks) return it here.
|
|
56
|
+
assistant[:raw_content] = response[:raw_content] if response[:raw_content]
|
|
57
|
+
msgs << assistant
|
|
54
58
|
|
|
55
59
|
run_tool_calls(response[:tool_calls], iter).each do |outcome|
|
|
56
60
|
history << outcome[:history] if outcome[:history]
|
data/lib/rcrewai/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rcrewai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gkosmo
|
|
@@ -332,15 +332,21 @@ files:
|
|
|
332
332
|
- docs/superpowers/specs/2026-07-07-consensual-process-design.md
|
|
333
333
|
- docs/tutorials/advanced-agents.md
|
|
334
334
|
- docs/tutorials/agent-options.md
|
|
335
|
+
- docs/tutorials/checkpointing.md
|
|
336
|
+
- docs/tutorials/concurrency.md
|
|
335
337
|
- docs/tutorials/consensual-process.md
|
|
336
338
|
- docs/tutorials/custom-tools.md
|
|
337
339
|
- docs/tutorials/deployment.md
|
|
338
340
|
- docs/tutorials/flows.md
|
|
339
341
|
- docs/tutorials/getting-started.md
|
|
340
342
|
- docs/tutorials/index.md
|
|
343
|
+
- docs/tutorials/interceptors-and-events.md
|
|
341
344
|
- docs/tutorials/knowledge.md
|
|
345
|
+
- docs/tutorials/live-streaming.md
|
|
342
346
|
- docs/tutorials/memory.md
|
|
343
347
|
- docs/tutorials/multiple-crews.md
|
|
348
|
+
- docs/tutorials/providers.md
|
|
349
|
+
- docs/upgrading-to-0.11.md
|
|
344
350
|
- docs/upgrading-to-0.3.md
|
|
345
351
|
- docs/upgrading-to-0.4.md
|
|
346
352
|
- docs/upgrading-to-0.6.md
|