ox-ai-workers 0.7.10 → 0.8.0
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 +5 -3
- 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: b177fcb5d7633d2cf26c608db3ec4ee0c69a301bf3913397be7cdd146de52cc5
|
4
|
+
data.tar.gz: 172312df86eba2fd578100467da9b7ac17ebfff577889f3df1b6888643c129e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d812c840212f8651ae58c09378c1eff43f4f8b69c0a6d50e17997863e3b1635d66470b9edec3eff270f8fe910dd309df994f07a4a18654799b82166fb52ee25
|
7
|
+
data.tar.gz: 24615b0e9a421c538d926fe97ad843f78d6795c54334d005fd03d0b6016dd4d24f694e267d0d18cb0ad653a25b8791893658557299fb6aa3558f17980fc2b696
|
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
|
@@ -233,8 +233,10 @@ module OxAiWorkers
|
|
233
233
|
|
234
234
|
out = tool.send(external_call[:name], **external_call[:args])
|
235
235
|
@queue << { role: :assistant,
|
236
|
-
content: "
|
237
|
-
@queue << { role: :system,
|
236
|
+
content: "Call #{external_call[:name]} with args #{external_call[:args]}" }
|
237
|
+
@queue << { role: :system,
|
238
|
+
content: "Tool call #{external_call[:name]} complited" }
|
239
|
+
@queue << { role: :system, content: "Result: #{out}" } if out.present?
|
238
240
|
end
|
239
241
|
@worker.finish
|
240
242
|
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