foobara-agent-backed-command 0.0.1 → 0.0.2
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 +4 -0
- data/src/agent_backed_command.rb +47 -6
- 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: 3f5c7e403d3856677c7e1a8b7d047eaa2632e7d25d77e805ed28e6d59ecfee0f
|
4
|
+
data.tar.gz: 465f51347fa4ea0c28ae0c692716dbe0bfc6fcf993e9b619b414dd8d8d546f79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e83aadf2ce5940b7b51c601b273319cd53d112a44ba673842b40a76cf566aabf29963b4218c56d5287f94896d764711d2af231c41423b9f68fd65a7b2f60c0bd
|
7
|
+
data.tar.gz: d9804222c4a0832d5e747ec0e663bb0caf21668adbf032310fc498db7ec65f1f14b8c9f18082d0cdaf1382249ef4cd304fea3a8a4db73b8bdd80a64aaa8e35d0
|
data/CHANGELOG.md
CHANGED
data/src/agent_backed_command.rb
CHANGED
@@ -9,7 +9,8 @@ module Foobara
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
# TODO: does this need to be a Concern for proper inheritance?
|
12
|
-
attr_accessor :is_verbose, :io_out, :io_err, :context, :agent_name, :llm_model, :max_llm_calls_per_minute
|
12
|
+
attr_accessor :is_verbose, :io_out, :io_err, :context, :agent_name, :llm_model, :max_llm_calls_per_minute,
|
13
|
+
:pass_aggregates_to_llm, :result_entity_depth
|
13
14
|
|
14
15
|
def verbose(value = true)
|
15
16
|
self.is_verbose = value
|
@@ -22,7 +23,7 @@ module Foobara
|
|
22
23
|
|
23
24
|
inputs do
|
24
25
|
agent_options do
|
25
|
-
verbose :boolean
|
26
|
+
verbose :boolean, :allow_nil
|
26
27
|
io_out :duck
|
27
28
|
io_err :duck
|
28
29
|
context Foobara::Agent::Context, :allow_nil, "The current context of the agent"
|
@@ -32,6 +33,8 @@ module Foobara
|
|
32
33
|
one_of: Foobara::Ai::AnswerBot::Types::ModelEnum,
|
33
34
|
description: "The model to use for the LLM"
|
34
35
|
max_llm_calls_per_minute :integer, :allow_nil
|
36
|
+
pass_aggregates_to_llm :boolean, :allow_nil
|
37
|
+
result_entity_depth :symbol, :allow_nil, one_of: Foobara::AssociationDepth
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
@@ -97,7 +100,7 @@ module Foobara
|
|
97
100
|
verbose = agent_options&.[](:verbose)
|
98
101
|
verbose = self.class.verbose? if verbose.nil?
|
99
102
|
|
100
|
-
|
103
|
+
opts = {
|
101
104
|
command_classes:,
|
102
105
|
include_message_to_user_in_result:,
|
103
106
|
result_type: agent_result_type,
|
@@ -107,8 +110,35 @@ module Foobara
|
|
107
110
|
agent_name:,
|
108
111
|
context: agent_options&.[](:context) || self.class.context,
|
109
112
|
llm_model: agent_options&.[](:llm_model) || self.class.llm_model,
|
113
|
+
# TODO: eliminate this now that we have backoffs for 529s and 429s
|
110
114
|
max_llm_calls_per_minute: agent_options&.[](:max_llm_calls_per_minute) || self.class.max_llm_calls_per_minute
|
111
|
-
|
115
|
+
}
|
116
|
+
|
117
|
+
if agent_options&.[](:result_entity_depth).nil?
|
118
|
+
unless self.class.result_entity_depth.nil?
|
119
|
+
opts[:result_entity_depth] = self.class.result_entity_depth
|
120
|
+
end
|
121
|
+
else
|
122
|
+
opts[:result_entity_depth] = agent_options[:result_entity_depth]
|
123
|
+
end
|
124
|
+
|
125
|
+
if agent_options&.[](:pass_aggregates_to_llm).nil?
|
126
|
+
unless self.class.pass_aggregates_to_llm.nil?
|
127
|
+
opts[:pass_aggregates_to_llm] = self.class.pass_aggregates_to_llm
|
128
|
+
end
|
129
|
+
else
|
130
|
+
opts[:pass_aggregates_to_llm] = agent_options[:pass_aggregates_to_llm]
|
131
|
+
end
|
132
|
+
|
133
|
+
self.agent = Foobara::Agent.new(**opts)
|
134
|
+
end
|
135
|
+
|
136
|
+
def pass_aggregates_to_llm?
|
137
|
+
if agent_options&.[](:pass_aggregates_to_llm).nil?
|
138
|
+
self.class.pass_aggregates_to_llm
|
139
|
+
else
|
140
|
+
agent_options[:pass_aggregates_to_llm]
|
141
|
+
end
|
112
142
|
end
|
113
143
|
|
114
144
|
def construct_goal_if_needed
|
@@ -132,13 +162,24 @@ module Foobara
|
|
132
162
|
inputs_type = TypeDeclarations::Attributes.reject(inputs_type.declaration_data, :agent_options)
|
133
163
|
inputs_type = domain.foobara_type_from_declaration(inputs_type)
|
134
164
|
|
165
|
+
association_depth = if pass_aggregates_to_llm?
|
166
|
+
AssociationDepth::AGGREGATE
|
167
|
+
else
|
168
|
+
AssociationDepth::ATOM
|
169
|
+
end
|
170
|
+
|
135
171
|
json_inputs_type = JsonSchemaGenerator.to_json_schema(
|
136
172
|
inputs_type,
|
137
|
-
association_depth:
|
173
|
+
association_depth:
|
138
174
|
)
|
139
175
|
goal += " The inputs to this command have the following type:\n\n#{json_inputs_type}\n\n"
|
140
176
|
|
141
|
-
serializer =
|
177
|
+
serializer = if pass_aggregates_to_llm?
|
178
|
+
CommandConnectors::Serializers::AggregateSerializer
|
179
|
+
else
|
180
|
+
CommandConnectors::Serializers::AtomicSerializer
|
181
|
+
end.new
|
182
|
+
|
142
183
|
inputs_json = serializer.serialize(inputs.except(:agent_options))
|
143
184
|
inputs_json = JSON.fast_generate(inputs_json)
|
144
185
|
goal += "You have been ran with the following inputs:\n\n#{inputs_json}"
|