omniai 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bab309e1be1b9acc7671c341b8e50cd0ec257ac22b254899b3661e428432f290
4
- data.tar.gz: 7968c811a16cf77172b087a03693641dbca83f2ba683e5eff30eda05ad4817e4
3
+ metadata.gz: 7f87f1b50c279a434ef7c23fb84f66321450897a62c9db0eda70659e3ac024a6
4
+ data.tar.gz: 334d3055c491bb582107b62ff555bba9bd175d9a23d7492cbfb07bdae4a1b876
5
5
  SHA512:
6
- metadata.gz: b22be38a54e83cb76c45e94d739290ee2530e51d81fd892e8a749deba3a54f88d9f7ec99a159df2688dadd7f5be9ce0a6ad03acfc7d0344e7ae4910e910f3bce
7
- data.tar.gz: a5a11dd87da47b2f5ee4a49d9a37bbfe55ccb1ff3b0a6da48544d076eb850e925343775ea90cbdf6a30f309bcb2d3e783be21798d7deecfc2762dca80a886393
6
+ metadata.gz: c6ed29f063e505bf58ad6ca19f8d4dace1627f73fb3bee8b52fb5f9756d550f3ff322e7ef00d286044eaa9a0b48a16811e62efb70c130948302834e9206a362d
7
+ data.tar.gz: 512fa19f0b5cb1c67a081d413bdf8e9b964716f08151fc20b048f5c2b46edc4eb8ec891563eb510c98e7ae5749c63afbbb661546718ec219f1287592c1f351da
data/README.md CHANGED
@@ -22,9 +22,11 @@ gem install omniai-openai
22
22
 
23
23
  ## Usage
24
24
 
25
+ OmniAI implements APIs for a number of popular clients by default. A client can be initialized using the specific gem (e.g. `omniai-openai` for `OmniAI::OpenAI`). Vendor specific docs can be found within each repo.
26
+
25
27
  ### Client
26
28
 
27
- #### Anthropic (Claude)
29
+ #### [OmniAI::Anthropic](https://github.com/ksylvest/omniai-anthropic)
28
30
 
29
31
  ```ruby
30
32
  require 'omniai-anthropic'
@@ -32,7 +34,7 @@ require 'omniai-anthropic'
32
34
  client = OmniAI::Anthropic::Client.new
33
35
  ```
34
36
 
35
- #### Google (Gemini)
37
+ #### [OmniAI::Google](https://github.com/ksylvest/omniai-google)
36
38
 
37
39
  ```ruby
38
40
  require 'omniai-google'
@@ -40,7 +42,7 @@ require 'omniai-google'
40
42
  client = OmniAI::Google::Client.new
41
43
  ```
42
44
 
43
- #### Mistral (LeChat)
45
+ #### [OmniAI::Mistral](https://github.com/ksylvest/omniai-mistral)
44
46
 
45
47
  ```ruby
46
48
  require 'omniai-mistral'
@@ -48,18 +50,18 @@ require 'omniai-mistral'
48
50
  client = OmniAI::Mistral::Client.new
49
51
  ```
50
52
 
51
- #### OpenAI (ChatGPT)
53
+ #### [OmniAI::OpenAI](https://github.com/ksylvest/omniai-openai)
52
54
 
53
55
  ```ruby
54
56
  require 'omniai-openai'
55
57
 
56
58
  client = OmniAI::OpenAI::Client.new
57
- completion = client.chat.completion('Tell me a joke.')
58
- completion.choice.message.content # '...'
59
59
  ```
60
60
 
61
61
  ### Chat
62
62
 
63
+ Clients that support chat (e.g. Anthropic w/ "Claude", Google w/ "Gemini", Mistral w/ "LeChat", OpenAI w/ "ChatGPT", etc) can generate completions using either a basic or streaming API:
64
+
63
65
  #### Basic
64
66
 
65
67
  ```ruby
@@ -70,7 +72,7 @@ puts(completion.choice.message.content) # '...'
70
72
  #### Streaming
71
73
 
72
74
  ```ruby
73
- stream = proc do |chunk|
75
+ client.chat.completion 'Tell me a joke.', stream: proc do |chunk|
74
76
  print(chunk.choice.delta.content) # '...'
75
77
  end
76
78
  ```
@@ -2,8 +2,8 @@
2
2
 
3
3
  module OmniAI
4
4
  class Chat
5
- # A delta returned by the API.
6
- class CompletionChunk
5
+ # A chunk returned by the API.
6
+ class Chunk
7
7
  attr_accessor :data
8
8
 
9
9
  # @param data [Hash]
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OmniAI
4
4
  class Chat
5
- # An class wrapping the response completion. A vendor may override if custom behavior is required.
5
+ # A completion returned by the API.
6
6
  class Completion
7
7
  attr_accessor :data
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OmniAI
4
4
  class Chat
5
- # An class wrapping the response usage. A vendor may override if custom behavior is required.
5
+ # A usage returned by the API.
6
6
  class Completion
7
7
  attr_accessor :data
8
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = '0.0.9'
4
+ VERSION = '0.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
@@ -72,7 +72,6 @@ files:
72
72
  - lib/omniai/chat/delta.rb
73
73
  - lib/omniai/chat/message.rb
74
74
  - lib/omniai/chat/request.rb
75
- - lib/omniai/chat/stream.rb
76
75
  - lib/omniai/chat/usage.rb
77
76
  - lib/omniai/client.rb
78
77
  - lib/omniai/version.rb
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module OmniAI
4
- class Chat
5
- # A processor for streaming back events in chunks.
6
- class Stream
7
- LINE_REGEX = /data:\s*(?<data>.*)\n\n/
8
-
9
- def initialize
10
- @buffer = String.new
11
- end
12
-
13
- # @yield [data] a parsed hash
14
- # @param [String] chunk
15
- def process!(chunk)
16
- @buffer << chunk
17
-
18
- while (line = @buffer.slice!(LINE_REGEX))
19
- match = LINE_REGEX.match(line)
20
- data = match[:data]
21
- break if data.eql?('[DONE]')
22
-
23
- yield JSON.parse(data)
24
- end
25
- end
26
- end
27
- end
28
- end