ruby_bots 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df9f251c6730b2873d3ceb1584d2a82fa9e6a563d2b760706343a60f69de0017
4
- data.tar.gz: a9f2522f666a0185019fafd8aa757d2c61a2565d8b2f2bd6c0bfc75577dcd36c
3
+ metadata.gz: f6340ca62c9070462527e782f8003e099a278da7e0c70beb4d3bc87da7609a89
4
+ data.tar.gz: 0a9207838ae9ce3ac5b1e00cb8ab1e0a32e591dd5cf03efddf11feb5a4921681
5
5
  SHA512:
6
- metadata.gz: d3bdb00120855fefd228f0fc1c35b9aa4f148fdfa8704f66f3828ef188ef8c67247224be1758aa0241da6c771d755284ad30acba283a4909913c9b075bdd3d46
7
- data.tar.gz: 3e07cdb73ee2fb5ad46af11512ce588c4013f2d4fc7ec55bcbcebcccae1f4bfbd43cf60821a68686a4ef1d796e3cb1921cd60b75fd6b89fb42666fa15ad6f998
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
@@ -1,3 +1,3 @@
1
1
  module RubyBots
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
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.2
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-04-29 00:00:00.000000000 Z
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