omniai 2.4.1 → 2.4.2

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: ab754f5c048f4d0e4c76e75f142f4e3d511e81a4f2a0585dd466e4b325ccdeb2
4
- data.tar.gz: 815d97caf42308a0bfaf183383522c5e34ce08ecab30835390d4c22034b32779
3
+ metadata.gz: 4bc8ae7e913581cbec89c7942594654b86902edf17ff08ecd531cb14b9edaeb9
4
+ data.tar.gz: 53dfc81815745d635a000e24c74c88b2fed6bdde42fe6aa80155995506fe055c
5
5
  SHA512:
6
- metadata.gz: 3497bf2f884a273896d42271170a513462f180bf86ca561f9120a3b8d464485b42400828901ada0bfd3c47ff2f374eb57242149a3664b3b6208b42fcf4227425
7
- data.tar.gz: d714671acf5e5c8dcfd3834bfbc529d2fede0967e8e7a3ddda4710588375eb65366c1067e1bcd00220764a6e9d30f583e7478e6e85881762fe005e43f8da3851
6
+ metadata.gz: 5768837dd4a72433a385b7f59b851c7f29d6dc8cc0f09bcdcbbe305e8e35eda3a2c0bca7e2c06ad29133def22e588b8d3a1a7ab0f5fe65dcc38c3707759e0d6f
7
+ data.tar.gz: 69628cb125a5fa86b752277b3403ed54ff4008fb37b0a6ff20ea5818eb51ea5509ada51ab814f4e1c2d8654312053b192a2614a2f9f7db8eacc000410af6fc00
data/README.md CHANGED
@@ -96,7 +96,7 @@ class Weather < OmniAI::Tool
96
96
  required %i[location]
97
97
 
98
98
  # @param location [String] required
99
- # @param unit [String] optional - "Celcius" or "Fahrenheit"
99
+ # @param unit [String] optional - "Celsius" or "Fahrenheit"
100
100
  # @return [String]
101
101
  def execute(location:, unit: "Celsius")
102
102
  puts "[weather] location=#{location} unit=#{unit}"
@@ -121,7 +121,7 @@ The weather is 24° Celsius in London and 42° Fahrenheit in Madrid.
121
121
 
122
122
  ### Example #5: [Chat w/ History](https://github.com/ksylvest/omniai/blob/main/examples/chat_with_history)
123
123
 
124
- Building a conversation history (e.g. multiple user and assistant messages) is especially helpful when building an agent like conversation experience. A prompt can be used to track this back and forth conversation:
124
+ Tracking a prompt history over multiple user and assistant messages is especially helpful when building an agent like conversation experience. A prompt can be used to track this back and forth conversation:
125
125
 
126
126
  ```ruby
127
127
  require "omniai/openai"
@@ -534,7 +534,7 @@ omniai chat --provider="openai" --model="gpt-4" --temperature="0.5"
534
534
 
535
535
  ```
536
536
  Type 'exit' or 'quit' to abort.
537
- # What is the warmet place on earth?
537
+ # What is the warmest place on earth?
538
538
  ```
539
539
 
540
540
  ```
@@ -562,7 +562,8 @@ omniai embed --provider="openai" --model="text-embedding-ada-002"
562
562
 
563
563
  ```
564
564
  Type 'exit' or 'quit' to abort.
565
- # Whe quick brown fox jumps over a lazy dog.
565
+ # What is the capital of Spain?
566
+ The capital of Spain is **Madrid**.
566
567
  ```
567
568
 
568
569
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OmniAI
4
4
  class Chat
5
- # Used to standardizes the process of building complex prompts.
5
+ # Used to standardize the process of building complex prompts.
6
6
  #
7
7
  # Usage:
8
8
  #
data/lib/omniai/chat.rb CHANGED
@@ -86,14 +86,19 @@ module OmniAI
86
86
  end
87
87
 
88
88
  # @raise [HTTPError]
89
+ # @raise [SSLError]
89
90
  #
90
91
  # @return [OmniAI::Chat::Response]
91
92
  def process!
92
- response = request!
93
+ begin
94
+ response = request!
93
95
 
94
- raise HTTPError, response.flush unless response.status.ok?
96
+ raise HTTPError, response.flush unless response.status.ok?
95
97
 
96
- completion = parse!(response:)
98
+ completion = parse!(response:)
99
+ rescue OpenSSL::SSL::SSLError => e
100
+ raise SSLError, e.message, cause: e
101
+ end
97
102
 
98
103
  if @tools && completion.tool_call_list?
99
104
  spawn!(
@@ -154,6 +159,8 @@ module OmniAI
154
159
 
155
160
  # @param response [HTTP::Response]
156
161
  #
162
+ # @raise [OmniAI::Chat::Error]
163
+ #
157
164
  # @return [OmniAI::Chat::Response]
158
165
  def parse!(response:)
159
166
  if stream?
data/lib/omniai/client.rb CHANGED
@@ -173,7 +173,7 @@ module OmniAI
173
173
  #
174
174
  # @return [OmniAI::Transcribe::Transcription]
175
175
  def transcribe(io, model:, language: nil, prompt: nil, temperature: nil, format: nil)
176
- raise NotImplementedError, "#{self.class.name}#speak undefined"
176
+ raise NotImplementedError, "#{self.class.name}#transcribe undefined"
177
177
  end
178
178
 
179
179
  # @raise [OmniAI::Error]
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAI
4
+ # An error that wraps an HTTP::Response for non-OK requests.
5
+ class HTTPError < Error
6
+ # @!attribute [rw] response
7
+ # @return [HTTP::Response]
8
+ attr_accessor :response
9
+
10
+ # @param response [HTTP::Response]
11
+ def initialize(response)
12
+ super("status=#{response.status} body=#{response.body}")
13
+
14
+ @response = response
15
+ end
16
+
17
+ # @return [String]
18
+ def inspect
19
+ "#<#{self.class} status=#{@response.status} body=#{@response.body}>"
20
+ end
21
+ end
22
+ end
@@ -10,7 +10,7 @@ module OmniAI
10
10
  class Base
11
11
  # @param text [String]
12
12
  def puts(text)
13
- raise NotImplementedError, "#{self.class}#gets undefined"
13
+ raise NotImplementedError, "#{self.class}#puts undefined"
14
14
  end
15
15
 
16
16
  # @return [String]
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAI
4
+ # An error that wraps an OpenSSL::SSL::SSLError.
5
+ class SSLError < Error; end
6
+ end
@@ -11,7 +11,7 @@ module OmniAI
11
11
  # properties: {
12
12
  # name: OmniAI::Tool::Parameters.string(description: 'The name of the person.'),
13
13
  # age: OmniAI::Tool::Parameters.integer(description: 'The age of the person.'),
14
- # employeed: OmniAI::Tool::Parameters.boolean(description: 'Is the person employeed?'),
14
+ # employed: OmniAI::Tool::Parameters.boolean(description: 'Is the person employed?'),
15
15
  # }
16
16
  # n: OmniAI::Tool::Parameters.integer(description: 'The nth number to calculate.')
17
17
  # required: %i[n]
@@ -64,7 +64,7 @@ module OmniAI
64
64
  # properties: {
65
65
  # name: OmniAI::Tool::Property.string(description: 'The name of the person.'),
66
66
  # age: OmniAI::Tool::Property.integer(description: 'The age of the person.'),
67
- # employeed: OmniAI::Tool::Property.boolean(description: 'Is the person employeed?'),
67
+ # employed: OmniAI::Tool::Property.boolean(description: 'Is the person employed?'),
68
68
  # },
69
69
  # description: 'A person.'
70
70
  # required: %i[name]
data/lib/omniai/tool.rb CHANGED
@@ -7,7 +7,7 @@ module OmniAI
7
7
  # description 'Find the weather for a location'
8
8
  #
9
9
  # parameter :location, :string, description: 'The location to find the weather for (e.g. "Toronto, Canada").'
10
- # parameter :unit, :string, description: 'The unit of measurement (e.g. "Celcius" or "Fahrenheit").'
10
+ # parameter :unit, :string, description: 'The unit of measurement (e.g. "Celsius" or "Fahrenheit").'
11
11
  # required %i[location]
12
12
  #
13
13
  # def execute!(location:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = "2.4.1"
4
+ VERSION = "2.4.2"
5
5
  end
data/lib/omniai.rb CHANGED
@@ -12,27 +12,10 @@ loader.inflector.inflect "cli" => "CLI"
12
12
  loader.inflector.inflect "jrpc" => "JRPC"
13
13
  loader.inflector.inflect "mcp" => "MCP"
14
14
  loader.inflector.inflect "url" => "URL"
15
+ loader.inflector.inflect "http_error" => "HTTPError"
16
+ loader.inflector.inflect "ssl_error" => "SSLError"
15
17
  loader.setup
16
18
 
17
19
  module OmniAI
18
20
  class Error < StandardError; end
19
-
20
- # An error that wraps an HTTP::Response for non-OK requests.
21
- class HTTPError < Error
22
- # @!attribute [rw] response
23
- # @return [HTTP::Response]
24
- attr_accessor :response
25
-
26
- # @param response [HTTP::Response]
27
- def initialize(response)
28
- super("status=#{response.status} body=#{response.body}")
29
-
30
- @response = response
31
- end
32
-
33
- # @return [String]
34
- def inspect
35
- "#<#{self.class} status=#{@response.status} body=#{@response.body}>"
36
- end
37
- end
38
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-23 00:00:00.000000000 Z
10
+ date: 2025-04-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: event_stream_parser
@@ -110,6 +110,7 @@ files:
110
110
  - lib/omniai/embed/response.rb
111
111
  - lib/omniai/embed/usage.rb
112
112
  - lib/omniai/files.rb
113
+ - lib/omniai/http_error.rb
113
114
  - lib/omniai/instrumentation.rb
114
115
  - lib/omniai/mcp/jrpc.rb
115
116
  - lib/omniai/mcp/jrpc/error.rb
@@ -119,6 +120,7 @@ files:
119
120
  - lib/omniai/mcp/transport/base.rb
120
121
  - lib/omniai/mcp/transport/stdio.rb
121
122
  - lib/omniai/speak.rb
123
+ - lib/omniai/ssl_error.rb
122
124
  - lib/omniai/tool.rb
123
125
  - lib/omniai/tool/array.rb
124
126
  - lib/omniai/tool/object.rb