ruby_bots 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_bots/tools/openai_streaming_tool.rb +27 -0
- data/lib/ruby_bots/version.rb +1 -1
- data/lib/ruby_bots.rb +1 -0
- 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: f6340ca62c9070462527e782f8003e099a278da7e0c70beb4d3bc87da7609a89
|
4
|
+
data.tar.gz: 0a9207838ae9ce3ac5b1e00cb8ab1e0a32e591dd5cf03efddf11feb5a4921681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28cb37f96735cb4341ff5f58260db3e568b15933b39b423d9c5b862ddd73f6d8f42a2e4d73aa17e2e74c6643a1d3e377926bcdf01fa70214212618ad6c63f30a
|
7
|
+
data.tar.gz: efa7b38c6cf1ce93e9dd225eb6d7dae0f58f57b8951b8b2287c188e5aba529ca813ca8af5c8a614a59598a499669e6610b84dacaca55d7bde4918b70122514a1
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RubyBots
|
2
|
+
class OpenAIStreamingTool < OpenAIChatTool
|
3
|
+
def run(input, &block)
|
4
|
+
@messages = [
|
5
|
+
{ role: :system, content: system_instructions },
|
6
|
+
{ role: :user, content: input }
|
7
|
+
]
|
8
|
+
|
9
|
+
client.chat(
|
10
|
+
parameters: {
|
11
|
+
messages: @messages,
|
12
|
+
model: 'gpt-4',
|
13
|
+
temperature: 0.7,
|
14
|
+
stream: stream_proc
|
15
|
+
}
|
16
|
+
).each do |response|
|
17
|
+
puts response
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def stream_proc
|
22
|
+
proc do |chunk, _bytesize|
|
23
|
+
print chunk.dig('choices', 0, 'delta', 'content')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ruby_bots/version.rb
CHANGED
data/lib/ruby_bots.rb
CHANGED
@@ -47,6 +47,7 @@ require_relative 'ruby_bots/version'
|
|
47
47
|
require_relative 'ruby_bots/tool'
|
48
48
|
require_relative 'ruby_bots/tools/openai_tool'
|
49
49
|
require_relative 'ruby_bots/tools/openai_chat_tool'
|
50
|
+
require_relative 'ruby_bots/tools/openai_streaming_tool'
|
50
51
|
|
51
52
|
# bots
|
52
53
|
require_relative 'ruby_bots/bot'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_bots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Paulson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/ruby_bots/streamable.rb
|
100
100
|
- lib/ruby_bots/tool.rb
|
101
101
|
- lib/ruby_bots/tools/openai_chat_tool.rb
|
102
|
+
- lib/ruby_bots/tools/openai_streaming_tool.rb
|
102
103
|
- lib/ruby_bots/tools/openai_tool.rb
|
103
104
|
- lib/ruby_bots/version.rb
|
104
105
|
homepage: https://github.com/aha-app/ruby_bots
|