foobara-agent-backed-command 0.0.5 → 0.0.7
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 +8 -0
- data/lib/foobara/agent_backed_command.rb +1 -0
- data/src/agent_backed_command.rb +38 -12
- 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: dc71a16e925bc371058a8fa67197ffbb4628fc5b9a7201a41a19e9bb86b661b6
|
4
|
+
data.tar.gz: 1274e53472b00432601ad7ca1c9db89716e82d804816c2b6b35383d9f1dbffb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74a9526f5b9e09496b5a0c0e162181af418d8a2aa9efecdaffe5bb9c6e0e2f04222dbcba84ceded5d7c14d3a0a2b24fefb3b54c8986d23832aa95ed6f3ec5686
|
7
|
+
data.tar.gz: 6c442453cec558c796c836ab9a24b74d0106307dda2cb51689611df1b86e28201adc158e8f3c18cede0b10c3ed662606152074fc2b70c6e2afc491d2460f2d3e
|
data/CHANGELOG.md
CHANGED
data/src/agent_backed_command.rb
CHANGED
@@ -30,8 +30,8 @@ module Foobara
|
|
30
30
|
[
|
31
31
|
:agent_name,
|
32
32
|
:llm_model,
|
33
|
-
:
|
34
|
-
:
|
33
|
+
:result_entity_depth,
|
34
|
+
:maximum_command_calls
|
35
35
|
].each do |method_name|
|
36
36
|
define_method method_name do |*args|
|
37
37
|
case args.size
|
@@ -60,8 +60,11 @@ module Foobara
|
|
60
60
|
one_of: Ai::AnswerBot::Types::ModelEnum,
|
61
61
|
default: Ai.default_llm_model,
|
62
62
|
description: "The model to use for the LLM"
|
63
|
-
max_llm_calls_per_minute :integer, :allow_nil
|
64
63
|
pass_aggregates_to_llm :boolean, :allow_nil
|
64
|
+
maximum_command_calls :integer,
|
65
|
+
:allow_nil,
|
66
|
+
default: 25,
|
67
|
+
description: "Maximum number of commands to run before giving up"
|
65
68
|
result_entity_depth :symbol, :allow_nil, one_of: Foobara::AssociationDepth
|
66
69
|
end
|
67
70
|
end
|
@@ -123,13 +126,12 @@ module Foobara
|
|
123
126
|
end
|
124
127
|
end
|
125
128
|
|
126
|
-
agent_name = agent_options&.[](:agent_name) || self.class.agent_name ||
|
129
|
+
agent_name = agent_options&.[](:agent_name) || self.class.agent_name || self.class.scoped_short_name
|
127
130
|
|
128
131
|
verbose = agent_options&.[](:verbose)
|
129
132
|
verbose = self.class.verbose? if verbose.nil?
|
130
133
|
|
131
134
|
opts = {
|
132
|
-
command_classes:,
|
133
135
|
include_message_to_user_in_result:,
|
134
136
|
result_type: agent_result_type,
|
135
137
|
verbose:,
|
@@ -137,9 +139,7 @@ module Foobara
|
|
137
139
|
io_err: agent_options&.[](:io_err) || self.class.io_err,
|
138
140
|
agent_name:,
|
139
141
|
context: agent_options&.[](:context) || self.class.context,
|
140
|
-
llm_model: agent_options&.[](:llm_model) || self.class.llm_model
|
141
|
-
# TODO: eliminate this now that we have backoffs for 529s and 429s
|
142
|
-
max_llm_calls_per_minute: agent_options&.[](:max_llm_calls_per_minute) || self.class.max_llm_calls_per_minute
|
142
|
+
llm_model: agent_options&.[](:llm_model) || self.class.llm_model
|
143
143
|
}
|
144
144
|
|
145
145
|
if agent_options&.[](:result_entity_depth).nil?
|
@@ -156,7 +156,34 @@ module Foobara
|
|
156
156
|
agent_options[:pass_aggregates_to_llm]
|
157
157
|
end
|
158
158
|
|
159
|
+
maximum_command_calls = agent_options&.[](:maximum_command_calls) || self.class.maximum_command_calls
|
160
|
+
|
161
|
+
if maximum_command_calls
|
162
|
+
opts[:maximum_command_calls] = maximum_command_calls
|
163
|
+
end
|
164
|
+
|
159
165
|
self.agent = Foobara::Agent.new(**opts)
|
166
|
+
|
167
|
+
command_classes.each do |klass|
|
168
|
+
if klass.is_a?(::Symbol)
|
169
|
+
real_class = Namespace.global.foobara_lookup_command(
|
170
|
+
klass,
|
171
|
+
mode: Namespace::LookupMode::ABSOLUTE
|
172
|
+
)
|
173
|
+
|
174
|
+
if real_class
|
175
|
+
klass = real_class
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
opts = if klass.is_a?(Class) && klass < AgentBackedCommand
|
180
|
+
{ inputs: { reject: [:agent_options] } }
|
181
|
+
else
|
182
|
+
{}
|
183
|
+
end
|
184
|
+
|
185
|
+
agent.connect(klass, **opts)
|
186
|
+
end
|
160
187
|
end
|
161
188
|
|
162
189
|
def agent_options
|
@@ -177,10 +204,9 @@ module Foobara
|
|
177
204
|
goal = Util.underscore(goal)
|
178
205
|
goal = Util.humanize(goal)
|
179
206
|
|
180
|
-
goal = "You are an agent backed command named #{self.class.scoped_short_name}. Your goal is: #{goal}."
|
181
|
-
|
182
207
|
if self.class.description
|
183
|
-
goal += "
|
208
|
+
goal += "\n\nYour behavior has been described to the person or agent that chose to run you as: "
|
209
|
+
goal += self.class.description
|
184
210
|
end
|
185
211
|
|
186
212
|
inputs_type = self.class.inputs_type
|
@@ -202,7 +228,7 @@ module Foobara
|
|
202
228
|
inputs_type,
|
203
229
|
association_depth:
|
204
230
|
)
|
205
|
-
goal += "
|
231
|
+
goal += "\n\nYour inputs to this command have the following type:\n\n#{json_inputs_type}\n\n"
|
206
232
|
|
207
233
|
serializer = if pass_aggregates_to_llm?
|
208
234
|
CommandConnectors::Serializers::AggregateSerializer
|