ox-ai-workers 0.7.10 → 0.8.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 +4 -0
- data/lib/oxaiworkers/assistant/module_base.rb +2 -2
- data/lib/oxaiworkers/iterator.rb +4 -4
- data/lib/oxaiworkers/module_request.rb +8 -3
- 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: f78fe8562d281490ff77a739af65aac6c23961e19bed5b2d14cf7598711affc6
|
4
|
+
data.tar.gz: 8f3fea145d2c7d9ae60fd6b79705cc03b4dfa88e81c1954051015e0ae5542dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96beaf2ea54324504aef5267915672987ff70b2fb9ce862306515759a0a90dc0ea18b8c8889694fb5ee6739cd1223a880da86468b1eeca597a9e003c387c9723
|
7
|
+
data.tar.gz: 93d1baa2365ee956027a882662aa549afd7bd8cd2e34f3573fb3f412f1c694840243aa7a396422ac1806767aa48ca63963707bf7e33296c5e212b5aae924f568
|
data/CHANGELOG.md
CHANGED
@@ -20,8 +20,8 @@ module OxAiWorkers
|
|
20
20
|
@iterator.execute
|
21
21
|
end
|
22
22
|
|
23
|
-
def init_worker(delayed: false, model: nil)
|
24
|
-
worker = delayed ? DelayedRequest.new : Request.new
|
23
|
+
def init_worker(delayed: false, model: nil, on_stream: nil)
|
24
|
+
worker = delayed ? DelayedRequest.new : Request.new(on_stream:)
|
25
25
|
worker.model = model || OxAiWorkers.configuration.model
|
26
26
|
worker
|
27
27
|
end
|
data/lib/oxaiworkers/iterator.rb
CHANGED
@@ -80,7 +80,7 @@ module OxAiWorkers
|
|
80
80
|
# @return [nil] This method does not return a value.
|
81
81
|
def inner_monologue(speach:)
|
82
82
|
# @queue.pop
|
83
|
-
@queue << { role: :assistant, content: speach.to_s }
|
83
|
+
# @queue << { role: :assistant, content: speach.to_s }
|
84
84
|
@on_inner_monologue&.call(text: speach)
|
85
85
|
nil
|
86
86
|
end
|
@@ -232,9 +232,9 @@ module OxAiWorkers
|
|
232
232
|
next if tool.nil?
|
233
233
|
|
234
234
|
out = tool.send(external_call[:name], **external_call[:args])
|
235
|
-
@queue << { role: :
|
236
|
-
content: "Tool
|
237
|
-
@queue << { role: :system, content: out
|
235
|
+
@queue << { role: :system,
|
236
|
+
content: "Tool called #{external_call[:name]} completed. Args: #{external_call[:args]}" }
|
237
|
+
@queue << { role: :system, content: "Result: #{out}" } if out.present?
|
238
238
|
end
|
239
239
|
@worker.finish
|
240
240
|
iterate! if can_iterate?
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module OxAiWorkers
|
4
4
|
class ModuleRequest
|
5
5
|
attr_accessor :result, :client, :messages, :model, :max_tokens, :custom_id, :temperature, :tools, :errors,
|
6
|
-
:tool_calls_raw, :tool_calls, :is_truncated, :finish_reason, :uri_base
|
6
|
+
:tool_calls_raw, :tool_calls, :is_truncated, :finish_reason, :uri_base, :on_stream_proc
|
7
7
|
|
8
|
-
def initialize_requests(model: nil, max_tokens: nil, temperature: nil, uri_base: nil)
|
8
|
+
def initialize_requests(model: nil, max_tokens: nil, temperature: nil, uri_base: nil, on_stream: nil)
|
9
9
|
@max_tokens = max_tokens || OxAiWorkers.configuration.max_tokens
|
10
10
|
@custom_id = SecureRandom.uuid
|
11
11
|
@model = model || OxAiWorkers.configuration.model
|
@@ -14,6 +14,7 @@ module OxAiWorkers
|
|
14
14
|
@client = nil
|
15
15
|
@is_truncated = false
|
16
16
|
@finish_reason = nil
|
17
|
+
@on_stream_proc = on_stream
|
17
18
|
|
18
19
|
OxAiWorkers.configuration.access_token ||= ENV['OPENAI']
|
19
20
|
if OxAiWorkers.configuration.access_token.nil?
|
@@ -40,7 +41,7 @@ module OxAiWorkers
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def append(role: nil, content: nil, messages: nil)
|
43
|
-
@messages << { role:, content: } if role.present?
|
44
|
+
@messages << { role:, content: } if role.present? && content.present?
|
44
45
|
@messages += messages if messages.present?
|
45
46
|
end
|
46
47
|
|
@@ -55,6 +56,10 @@ module OxAiWorkers
|
|
55
56
|
parameters[:tools] = @tools
|
56
57
|
parameters[:tool_choice] = 'required'
|
57
58
|
end
|
59
|
+
if @on_stream_proc.present?
|
60
|
+
parameters[:stream] = @on_stream_proc
|
61
|
+
parameters[:stream_options] = { include_usage: true }
|
62
|
+
end
|
58
63
|
parameters
|
59
64
|
end
|
60
65
|
|
data/lib/oxaiworkers/version.rb
CHANGED