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 +4 -4
- data/README.md +5 -4
- data/lib/omniai/chat/prompt.rb +1 -1
- data/lib/omniai/chat.rb +10 -3
- data/lib/omniai/client.rb +1 -1
- data/lib/omniai/http_error.rb +22 -0
- data/lib/omniai/mcp/transport/base.rb +1 -1
- data/lib/omniai/ssl_error.rb +6 -0
- data/lib/omniai/tool/parameters.rb +1 -1
- data/lib/omniai/tool/property.rb +1 -1
- data/lib/omniai/tool.rb +1 -1
- data/lib/omniai/version.rb +1 -1
- data/lib/omniai.rb +2 -19
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc8ae7e913581cbec89c7942594654b86902edf17ff08ecd531cb14b9edaeb9
|
4
|
+
data.tar.gz: 53dfc81815745d635a000e24c74c88b2fed6bdde42fe6aa80155995506fe055c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 - "
|
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
|
-
|
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
|
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
|
-
#
|
565
|
+
# What is the capital of Spain?
|
566
|
+
The capital of Spain is **Madrid**.
|
566
567
|
```
|
567
568
|
|
568
569
|
```
|
data/lib/omniai/chat/prompt.rb
CHANGED
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
|
-
|
93
|
+
begin
|
94
|
+
response = request!
|
93
95
|
|
94
|
-
|
96
|
+
raise HTTPError, response.flush unless response.status.ok?
|
95
97
|
|
96
|
-
|
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}#
|
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
|
@@ -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
|
-
#
|
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]
|
data/lib/omniai/tool/property.rb
CHANGED
@@ -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
|
-
#
|
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. "
|
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:)
|
data/lib/omniai/version.rb
CHANGED
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.
|
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-
|
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
|