activeagent 0.5.0rc3 → 0.5.1
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/lib/active_agent/action_prompt/base.rb +3 -5
- data/lib/active_agent/generation_provider/anthropic_provider.rb +10 -7
- data/lib/active_agent/generation_provider/open_ai_provider.rb +1 -1
- data/lib/active_agent/parameterized.rb +5 -5
- data/lib/active_agent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae6f20cf300442f42f9bc00eefea0b8b987dd7e3852e410c685b1f51ba5dcdc2
|
4
|
+
data.tar.gz: aaabea49a2e71c68c4b8a9b8769fd541b2fad12e1fc16d90aad2219cd0775522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 454f25de89fd2ba05d31e8a39304d0d6a25e6cf7ad3694464ee9013e0f946ca3794500a889d75e77da3d0c1433a084557caf70765b471eb3a6e9324ef78d8853
|
7
|
+
data.tar.gz: 72075033b38ac50b840e6d6a944922ae2402ab1fdb608f458b9e274883b1ff65286a7eec0530d0a4327c77bf2f1d01f3d471bc18ac986eaee7f9c1ad463816f7
|
@@ -304,9 +304,9 @@ module ActiveAgent
|
|
304
304
|
|
305
305
|
def prompt(headers = {}, &block)
|
306
306
|
return context if @_prompt_was_called && headers.blank? && !block
|
307
|
+
# Apply option hierarchy: prompt options > agent options > config options
|
308
|
+
merged_options = merge_options(headers[:options] || {})
|
307
309
|
|
308
|
-
# Apply option hierarchy: prompt options > agent > config options
|
309
|
-
merged_options = merge_options(headers)
|
310
310
|
raw_instructions = headers.has_key?(:instructions) ? headers[:instructions] : context.options[:instructions]
|
311
311
|
|
312
312
|
context.instructions = prepare_instructions(raw_instructions)
|
@@ -403,9 +403,8 @@ module ActiveAgent
|
|
403
403
|
# Extract runtime options from prompt_options (exclude instructions as it has special template logic)
|
404
404
|
runtime_options = prompt_options.slice(
|
405
405
|
:model, :temperature, :max_tokens, :stream, :top_p, :frequency_penalty,
|
406
|
-
:presence_penalty, :response_format, :seed, :stop, :tools_choice
|
406
|
+
:presence_penalty, :response_format, :seed, :stop, :tools_choice
|
407
407
|
)
|
408
|
-
|
409
408
|
# Handle explicit options parameter
|
410
409
|
explicit_options = prompt_options[:options] || {}
|
411
410
|
|
@@ -535,7 +534,6 @@ module ActiveAgent
|
|
535
534
|
end
|
536
535
|
|
537
536
|
def prepare_instructions(instructions)
|
538
|
-
binding.irb
|
539
537
|
case instructions
|
540
538
|
when Hash
|
541
539
|
raise ArgumentError, "Expected `:template` key in instructions hash" unless instructions[:template]
|
@@ -32,7 +32,7 @@ module ActiveAgent
|
|
32
32
|
def chat_prompt(parameters: prompt_parameters)
|
33
33
|
parameters[:stream] = provider_stream if prompt.options[:stream] || config["stream"]
|
34
34
|
|
35
|
-
chat_response(@client.messages(parameters))
|
35
|
+
chat_response(@client.messages(parameters: parameters))
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
@@ -51,8 +51,11 @@ module ActiveAgent
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def prompt_parameters(model: @prompt.options[:model] || @model_name, messages: @prompt.messages, temperature: @prompt.options[:temperature] || @config["temperature"] || 0.7, tools: @prompt.actions)
|
54
|
+
# fix for new Anthropic API that requires messages to be in a specific format without system role
|
55
|
+
messages = messages.reject { |m| m.role == :system }
|
54
56
|
params = {
|
55
57
|
model: model,
|
58
|
+
system: @prompt.options[:instructions],
|
56
59
|
messages: provider_messages(messages),
|
57
60
|
temperature: temperature,
|
58
61
|
max_tokens: @prompt.options[:max_tokens] || @config["max_tokens"] || 4096
|
@@ -68,9 +71,9 @@ module ActiveAgent
|
|
68
71
|
def format_tools(tools)
|
69
72
|
tools.map do |tool|
|
70
73
|
{
|
71
|
-
name: tool[
|
72
|
-
description: tool[
|
73
|
-
input_schema: tool[
|
74
|
+
name: tool["name"] || tool["function"]["name"],
|
75
|
+
description: tool["description"] || tool["function"]["description"],
|
76
|
+
input_schema: tool["parameters"] || tool["function"]["parameters"]
|
74
77
|
}
|
75
78
|
end
|
76
79
|
end
|
@@ -114,13 +117,13 @@ module ActiveAgent
|
|
114
117
|
def chat_response(response)
|
115
118
|
return @response if prompt.options[:stream]
|
116
119
|
|
117
|
-
content = response
|
120
|
+
content = response["content"].first["text"]
|
118
121
|
|
119
122
|
message = ActiveAgent::ActionPrompt::Message.new(
|
120
123
|
content: content,
|
121
124
|
role: "assistant",
|
122
|
-
action_requested: response
|
123
|
-
requested_actions: handle_actions(response
|
125
|
+
action_requested: response["stop_reason"] == "tool_use",
|
126
|
+
requested_actions: handle_actions(response["tool_use"])
|
124
127
|
)
|
125
128
|
|
126
129
|
update_context(prompt: prompt, message: message, response: response)
|
@@ -15,12 +15,12 @@ module ActiveAgent
|
|
15
15
|
module ClassMethods
|
16
16
|
def with(params = {})
|
17
17
|
# Separate runtime options from regular params
|
18
|
-
runtime_options = params.extract!(:model, :temperature, :max_tokens, :stream, :top_p,
|
19
|
-
|
20
|
-
|
18
|
+
# runtime_options = params.extract!(:model, :temperature, :max_tokens, :stream, :top_p,
|
19
|
+
# :frequency_penalty, :presence_penalty, :response_format,
|
20
|
+
# :seed, :stop, :tools_choice, :user)
|
21
21
|
|
22
|
-
# Pass runtime options as :options parameter
|
23
|
-
params[:options] = runtime_options if runtime_options.any?
|
22
|
+
# # Pass runtime options as :options parameter
|
23
|
+
# params[:options] = runtime_options if runtime_options.any?
|
24
24
|
|
25
25
|
ActiveAgent::Parameterized::Agent.new(self, params)
|
26
26
|
end
|
data/lib/active_agent/version.rb
CHANGED