foobara-agent-backed-command 0.0.1 → 0.0.3
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/src/agent_backed_command.rb +49 -7
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1285ca282dd917cdb1193550613fafd8b73a0de6fa28e9b3bb54645b559c0f32
|
4
|
+
data.tar.gz: 5db41d9063471ad5d537aac616ac6c66ab54f6bee854cc32dec4f8ca86b78e0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 031bb05dfe8d289d7ceaa4a8ba6151644305c56dc7a670a4482e71f618226aebdee4dde73f492d057e8c571ba9cf60bdccbd83839d2ce74f811a288a43e9b383
|
7
|
+
data.tar.gz: 7f723d58cf19367d5a0d3ecb31e77aa1b2563fd7be4f187ac8260e5d7c0f7c38ba76f1d40a49e5cd54df04be90875262c12dcaf6e87c2ba465fc5ea12ca2513d
|
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,16 +23,19 @@ 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"
|
29
30
|
agent_name :string, :allow_nil
|
30
31
|
llm_model :string,
|
31
32
|
:allow_nil,
|
32
|
-
one_of:
|
33
|
+
one_of: Ai::AnswerBot::Types::ModelEnum,
|
34
|
+
default: Ai.default_llm_model,
|
33
35
|
description: "The model to use for the LLM"
|
34
36
|
max_llm_calls_per_minute :integer, :allow_nil
|
37
|
+
pass_aggregates_to_llm :boolean, :allow_nil
|
38
|
+
result_entity_depth :symbol, :allow_nil, one_of: Foobara::AssociationDepth
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -97,7 +101,7 @@ module Foobara
|
|
97
101
|
verbose = agent_options&.[](:verbose)
|
98
102
|
verbose = self.class.verbose? if verbose.nil?
|
99
103
|
|
100
|
-
|
104
|
+
opts = {
|
101
105
|
command_classes:,
|
102
106
|
include_message_to_user_in_result:,
|
103
107
|
result_type: agent_result_type,
|
@@ -107,8 +111,35 @@ module Foobara
|
|
107
111
|
agent_name:,
|
108
112
|
context: agent_options&.[](:context) || self.class.context,
|
109
113
|
llm_model: agent_options&.[](:llm_model) || self.class.llm_model,
|
114
|
+
# TODO: eliminate this now that we have backoffs for 529s and 429s
|
110
115
|
max_llm_calls_per_minute: agent_options&.[](:max_llm_calls_per_minute) || self.class.max_llm_calls_per_minute
|
111
|
-
|
116
|
+
}
|
117
|
+
|
118
|
+
if agent_options&.[](:result_entity_depth).nil?
|
119
|
+
unless self.class.result_entity_depth.nil?
|
120
|
+
opts[:result_entity_depth] = self.class.result_entity_depth
|
121
|
+
end
|
122
|
+
else
|
123
|
+
opts[:result_entity_depth] = agent_options[:result_entity_depth]
|
124
|
+
end
|
125
|
+
|
126
|
+
if agent_options&.[](:pass_aggregates_to_llm).nil?
|
127
|
+
unless self.class.pass_aggregates_to_llm.nil?
|
128
|
+
opts[:pass_aggregates_to_llm] = self.class.pass_aggregates_to_llm
|
129
|
+
end
|
130
|
+
else
|
131
|
+
opts[:pass_aggregates_to_llm] = agent_options[:pass_aggregates_to_llm]
|
132
|
+
end
|
133
|
+
|
134
|
+
self.agent = Foobara::Agent.new(**opts)
|
135
|
+
end
|
136
|
+
|
137
|
+
def pass_aggregates_to_llm?
|
138
|
+
if agent_options&.[](:pass_aggregates_to_llm).nil?
|
139
|
+
self.class.pass_aggregates_to_llm
|
140
|
+
else
|
141
|
+
agent_options[:pass_aggregates_to_llm]
|
142
|
+
end
|
112
143
|
end
|
113
144
|
|
114
145
|
def construct_goal_if_needed
|
@@ -132,13 +163,24 @@ module Foobara
|
|
132
163
|
inputs_type = TypeDeclarations::Attributes.reject(inputs_type.declaration_data, :agent_options)
|
133
164
|
inputs_type = domain.foobara_type_from_declaration(inputs_type)
|
134
165
|
|
166
|
+
association_depth = if pass_aggregates_to_llm?
|
167
|
+
AssociationDepth::AGGREGATE
|
168
|
+
else
|
169
|
+
AssociationDepth::ATOM
|
170
|
+
end
|
171
|
+
|
135
172
|
json_inputs_type = JsonSchemaGenerator.to_json_schema(
|
136
173
|
inputs_type,
|
137
|
-
association_depth:
|
174
|
+
association_depth:
|
138
175
|
)
|
139
176
|
goal += " The inputs to this command have the following type:\n\n#{json_inputs_type}\n\n"
|
140
177
|
|
141
|
-
serializer =
|
178
|
+
serializer = if pass_aggregates_to_llm?
|
179
|
+
CommandConnectors::Serializers::AggregateSerializer
|
180
|
+
else
|
181
|
+
CommandConnectors::Serializers::AtomicSerializer
|
182
|
+
end.new
|
183
|
+
|
142
184
|
inputs_json = serializer.serialize(inputs.except(:agent_options))
|
143
185
|
inputs_json = JSON.fast_generate(inputs_json)
|
144
186
|
goal += "You have been ran with the following inputs:\n\n#{inputs_json}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-agent-backed-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -16,6 +16,9 @@ dependencies:
|
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: 0.0.1
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
19
22
|
type: :runtime
|
20
23
|
prerelease: false
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -23,6 +26,9 @@ dependencies:
|
|
23
26
|
- - ">="
|
24
27
|
- !ruby/object:Gem::Version
|
25
28
|
version: 0.0.1
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 2.0.0
|
26
32
|
email:
|
27
33
|
- azimux@gmail.com
|
28
34
|
executables: []
|