ox-ai-workers 0.9.7 → 0.9.8
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/README.md +2 -0
- data/lib/oxaiworkers/tool/pipeline.rb +4 -2
- data/lib/oxaiworkers/tool_definition.rb +12 -8
- data/lib/oxaiworkers/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: cea51225b7b09bfd512c62960fc5e01f3bb6ed848e8efc6d72115ac6765ac254
|
4
|
+
data.tar.gz: 3f355bf99d4a5d3101c3d8b2f8e7f4859509489bb857c50b49d3efba15dc086f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b665b7c498647dc8c53fe9bd538f3db34c424fc2277b4226e08e66faa0fbc3f3df5cc8d9d8a65301cca94c0b30b0241140565675486a0f2e70be55cbaf43ceef
|
7
|
+
data.tar.gz: dcf0ef347b4e2017f69e09bc85bc99ffa785a4bf0d6ff565c292a0d8ee50fde675d49851766a25d9c473f67126d41185955365da303e4fe0272ad70e0b9a4b3c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -397,6 +397,8 @@ class MyTool
|
|
397
397
|
end
|
398
398
|
```
|
399
399
|
|
400
|
+
The `define_function` method accepts an optional `strict` parameter (defaults to `true`) that controls whether additional properties are allowed in the input. When `strict: true` (default), the schema will include `additionalProperties: false`, enforcing that only defined properties can be used.
|
401
|
+
|
400
402
|
### Working with Files and Images
|
401
403
|
|
402
404
|
You can easily add files and images to your assistants:
|
@@ -33,8 +33,10 @@ module OxAiWorkers
|
|
33
33
|
context = context_for(to_id)
|
34
34
|
@assistants[to_id].replace_context(context)
|
35
35
|
@assistants[to_id].add_task message
|
36
|
-
|
37
|
-
|
36
|
+
with_locale do
|
37
|
+
@assistants[to_id].add_task "#{I18n.t('oxaiworkers.tool.pipeline.send_message.result')}: #{result}"
|
38
|
+
@assistants[to_id].add_task "#{I18n.t('oxaiworkers.tool.pipeline.send_message.example')}: #{example}"
|
39
|
+
end
|
38
40
|
@assistants[to_id].execute
|
39
41
|
nil
|
40
42
|
end
|
@@ -53,10 +53,10 @@ module OxAiWorkers
|
|
53
53
|
# @param method_name [Symbol] Name of the method to define
|
54
54
|
# @param description [String] Description of the function
|
55
55
|
# @yield Block that defines the parameters for the function
|
56
|
-
def define_function(method_name, description:, &)
|
56
|
+
def define_function(method_name, description:, strict: true, &)
|
57
57
|
return unless @white_list.nil? || @white_list == method_name || @white_list.include?(method_name)
|
58
58
|
|
59
|
-
function_schemas.add_function(method_name:, description:, &)
|
59
|
+
function_schemas.add_function(method_name:, description:, strict:, &)
|
60
60
|
end
|
61
61
|
|
62
62
|
# Returns the FunctionSchemas instance for this tool
|
@@ -105,11 +105,11 @@ module OxAiWorkers
|
|
105
105
|
# @param description [String] Description of the function
|
106
106
|
# @yield Block that defines the parameters for the function
|
107
107
|
# @raise [ArgumentError] If a block is defined and no parameters are specified for the function
|
108
|
-
def add_function(method_name:, description:, &)
|
108
|
+
def add_function(method_name:, description:, strict:, &)
|
109
109
|
name = function_name(method_name)
|
110
110
|
|
111
111
|
if block_given?
|
112
|
-
parameters = ParameterBuilder.new(parent_type: 'object').build(&)
|
112
|
+
parameters = ParameterBuilder.new(parent_type: 'object', strict:).build(&)
|
113
113
|
|
114
114
|
if parameters[:properties].empty?
|
115
115
|
raise ArgumentError,
|
@@ -117,9 +117,12 @@ module OxAiWorkers
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
+
function_params = { name:, description:, parameters: }
|
121
|
+
function_params[:strict] = true if strict
|
122
|
+
|
120
123
|
@schemas[method_name] = {
|
121
124
|
type: 'function',
|
122
|
-
function:
|
125
|
+
function: function_params.compact
|
123
126
|
}
|
124
127
|
end
|
125
128
|
|
@@ -163,9 +166,10 @@ module OxAiWorkers
|
|
163
166
|
class ParameterBuilder
|
164
167
|
VALID_TYPES = %w[object array string number integer boolean].freeze
|
165
168
|
|
166
|
-
def initialize(parent_type:)
|
169
|
+
def initialize(parent_type:, strict: true)
|
167
170
|
@schema = parent_type == 'object' ? { type: 'object', properties: {}, required: [] } : {}
|
168
171
|
@parent_type = parent_type
|
172
|
+
@strict = strict
|
169
173
|
end
|
170
174
|
|
171
175
|
# Builds the parameter schema
|
@@ -192,7 +196,7 @@ module OxAiWorkers
|
|
192
196
|
prop = { type:, description:, enum: }.compact
|
193
197
|
|
194
198
|
if block_given?
|
195
|
-
nested_schema = ParameterBuilder.new(parent_type: type).build(&)
|
199
|
+
nested_schema = ParameterBuilder.new(parent_type: type, strict: @strict).build(&)
|
196
200
|
|
197
201
|
case type
|
198
202
|
when 'object'
|
@@ -214,7 +218,7 @@ module OxAiWorkers
|
|
214
218
|
if @parent_type == 'object'
|
215
219
|
@schema[:properties][name] = prop
|
216
220
|
@schema[:required] << name.to_s if required
|
217
|
-
@schema[:additionalProperties] = false
|
221
|
+
@schema[:additionalProperties] = false if @strict
|
218
222
|
else
|
219
223
|
@schema = prop
|
220
224
|
end
|
data/lib/oxaiworkers/version.rb
CHANGED