ox-ai-workers 1.0.1.4 → 1.0.2.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/CHANGELOG.md +6 -0
- data/README.md +18 -1
- data/lib/ox-ai-workers.rb +1 -0
- data/lib/oxaiworkers/iterator.rb +10 -2
- data/lib/oxaiworkers/models/openai_whisper.rb +25 -0
- data/lib/oxaiworkers/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33177f5c822272383d00d96fadd552db0b966af7ddb2ec494538ca8cace7fadf
|
4
|
+
data.tar.gz: e3f756943f16fb8be2823f493156e261eb2d4d02a99d9c0373e8a3ed606c8726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a64203d85443d9b812c2d36aa0718283fb21fd784043a4d1346ec96a3386bec3766f4ed127d41c1c6f149af7abb4af6241fad089caf72b058037b7bc323b08cb
|
7
|
+
data.tar.gz: f0e1ec3b3be53fbe00f31dddc6e16e6a3befb7457d307cbc9906160b02e94bc66d8d18ec1c0095c2e6a53c9d48d4f256515da6ac0ea1ae4bb327ab07fb0772a0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -385,21 +385,34 @@ You can create custom tools by extending the `ToolDefinition` module:
|
|
385
385
|
class MyTool
|
386
386
|
include OxAiWorkers::ToolDefinition
|
387
387
|
|
388
|
+
attr_accessor :messages
|
389
|
+
|
388
390
|
def initialize
|
391
|
+
@messages = []
|
392
|
+
|
389
393
|
define_function :hello_world, description: "Says hello to someone" do
|
390
394
|
property :name, type: "string", description: "Name to greet" # Default required: true
|
391
|
-
property :age, type: ["integer", "null"], description: "Age of the person" # Default required: true
|
395
|
+
property :age, type: ["integer", "null"], description: "Age of the person" # Default required: true, can be null so it's optional
|
392
396
|
end
|
393
397
|
end
|
394
398
|
|
395
399
|
def hello_world(name:)
|
400
|
+
@messages << "Greeted #{name}"
|
396
401
|
"Hello, #{name}!"
|
397
402
|
end
|
403
|
+
|
404
|
+
# The context method provides information to assistants using this tool before each request
|
405
|
+
def context
|
406
|
+
return nil if @messages.empty?
|
407
|
+
"Tool activity log:\n#{@messages.join("\n")}"
|
408
|
+
end
|
398
409
|
end
|
399
410
|
```
|
400
411
|
|
401
412
|
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.
|
402
413
|
|
414
|
+
Tools can also implement a `context` method that returns information to be included in assistant conversations before each request, which is particularly useful when multiple assistants share a common tool to maintain shared state or history.
|
415
|
+
|
403
416
|
### Working with Files and Images
|
404
417
|
|
405
418
|
You can easily add files and images to your assistants:
|
@@ -628,6 +641,10 @@ OxAiWorkers provides several specialized tools to extend functionality:
|
|
628
641
|
|
629
642
|
- **FileSystem**: File operations tool
|
630
643
|
|
644
|
+
```ruby
|
645
|
+
gem "ptools"
|
646
|
+
```
|
647
|
+
|
631
648
|
```ruby
|
632
649
|
# Initialize with optional parameters
|
633
650
|
file_system = OxAiWorkers::Tool::FileSystem.new(
|
data/lib/ox-ai-workers.rb
CHANGED
@@ -43,6 +43,7 @@ require_relative 'oxaiworkers/models/openai_max'
|
|
43
43
|
require_relative 'oxaiworkers/models/openai_mini'
|
44
44
|
require_relative 'oxaiworkers/models/openai_nano'
|
45
45
|
require_relative 'oxaiworkers/models/deepseek_max'
|
46
|
+
require_relative 'oxaiworkers/models/openai_whisper'
|
46
47
|
|
47
48
|
require_relative 'oxaiworkers/models/images_base'
|
48
49
|
require_relative 'oxaiworkers/models/stability_images'
|
data/lib/oxaiworkers/iterator.rb
CHANGED
@@ -9,13 +9,14 @@ module OxAiWorkers
|
|
9
9
|
|
10
10
|
attr_accessor :worker, :role, :messages, :context, :tools, :queue, :monologue, :tasks,
|
11
11
|
:on_inner_monologue, :on_outer_voice, :on_finish, :def_except, :def_only,
|
12
|
-
:call_stack, :stop_double_calls
|
12
|
+
:call_stack, :stop_double_calls, :call_id
|
13
13
|
|
14
14
|
def initialize(worker:, role: nil, tools: [], on_inner_monologue: nil, on_outer_voice: nil,
|
15
15
|
on_finish: nil, steps: nil, def_except: [], def_only: nil, locale: nil,
|
16
16
|
call_stack: nil, stop_double_calls: [])
|
17
17
|
|
18
18
|
@locale = locale || I18n.locale
|
19
|
+
@call_id = 0
|
19
20
|
|
20
21
|
with_locale do
|
21
22
|
define_function :inner_monologue, description: I18n.t('oxaiworkers.iterator.inner_monologue.description') do
|
@@ -71,6 +72,7 @@ module OxAiWorkers
|
|
71
72
|
@queue = []
|
72
73
|
@tasks = []
|
73
74
|
@messages = []
|
75
|
+
@call_id = 0
|
74
76
|
complete_iteration
|
75
77
|
end
|
76
78
|
|
@@ -223,10 +225,16 @@ module OxAiWorkers
|
|
223
225
|
end.first
|
224
226
|
next if tool.nil?
|
225
227
|
|
228
|
+
@call_id += 1
|
226
229
|
out = tool.send(external_call[:name], **external_call[:args])
|
227
230
|
@queue << { role: :assistant,
|
228
231
|
content: "Tool call #{external_call[:name]} completed." }
|
229
|
-
@queue <<
|
232
|
+
@queue << if out.present?
|
233
|
+
{ role: :tool, content: out, tool_call_id: "call_#{@call_id}" }
|
234
|
+
else
|
235
|
+
{ role: :tool, content: "Tool call #{external_call[:name]} successful.",
|
236
|
+
tool_call_id: "call_#{@call_id}" }
|
237
|
+
end
|
230
238
|
end
|
231
239
|
@worker.finish
|
232
240
|
iterate! if can_iterate?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OxAiWorkers
|
4
|
+
module Models
|
5
|
+
class OpenaiWhisper
|
6
|
+
def initialize(uri_base: nil, api_key: nil, model: 'whisper-1')
|
7
|
+
@api_key = api_key || OxAiWorkers.configuration.access_token_openai
|
8
|
+
@uri_base = uri_base
|
9
|
+
@client = OpenAI::Client.new(access_token: @api_key, uri_base:)
|
10
|
+
@model = model
|
11
|
+
end
|
12
|
+
|
13
|
+
def transcribe(binary:, language: nil)
|
14
|
+
response = @client.audio.transcribe(
|
15
|
+
parameters: {
|
16
|
+
model: @model,
|
17
|
+
file: binary,
|
18
|
+
language:
|
19
|
+
}
|
20
|
+
)
|
21
|
+
response['text']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/oxaiworkers/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ox-ai-workers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1
|
4
|
+
version: 1.0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Smolev
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/oxaiworkers/models/openai_max.rb
|
166
166
|
- lib/oxaiworkers/models/openai_mini.rb
|
167
167
|
- lib/oxaiworkers/models/openai_nano.rb
|
168
|
+
- lib/oxaiworkers/models/openai_whisper.rb
|
168
169
|
- lib/oxaiworkers/models/stability_images.rb
|
169
170
|
- lib/oxaiworkers/module_request.rb
|
170
171
|
- lib/oxaiworkers/present_compat.rb
|
@@ -206,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
207
|
- !ruby/object:Gem::Version
|
207
208
|
version: '0'
|
208
209
|
requirements: []
|
209
|
-
rubygems_version: 3.6.
|
210
|
+
rubygems_version: 3.6.9
|
210
211
|
specification_version: 4
|
211
212
|
summary: A powerful state machine with OpenAI generative intelligence integration
|
212
213
|
test_files: []
|