openai-chat 0.0.3 → 0.0.5
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/Gemfile.lock +4 -3
- data/README.md +4 -4
- data/lib/openai/chat/version.rb +1 -1
- data/lib/openai/chat.rb +7 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b415dc91e4bf63afb35d142c96a5a00839cd7462d6f55743bb2a2f33aed4cb6
|
4
|
+
data.tar.gz: e26cb433930f594a648c06f386539e687a41db1827aae1efda091fc596993b13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f2c6cf5cba6ad745b588b1d0895240b4edbea916d9a9656f156041b711ecd71dfc143ca6cd97d7b5bd486aa40f1c5115dde3cb222a6b0fac47cd299d6a36499
|
7
|
+
data.tar.gz: a3b85ff44ce74cb5ff9cceb5b45bd0bd268f1aff935f34ab7d68f6ec38e8373834592b44eaf4d779e8475b45fac42ce4755dc0e2b777f7af721aab317c517d69
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openai-chat (0.0.
|
4
|
+
openai-chat (0.0.5)
|
5
5
|
mime-types (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -42,10 +42,10 @@ GEM
|
|
42
42
|
language_server-protocol (3.17.0.4)
|
43
43
|
lint_roller (1.1.0)
|
44
44
|
logger (1.6.6)
|
45
|
-
mime-types (3.6.
|
45
|
+
mime-types (3.6.2)
|
46
46
|
logger
|
47
47
|
mime-types-data (~> 3.2015)
|
48
|
-
mime-types-data (3.2025.
|
48
|
+
mime-types-data (3.2025.0422)
|
49
49
|
minitest (5.25.4)
|
50
50
|
parallel (1.26.3)
|
51
51
|
parser (3.3.7.1)
|
@@ -114,6 +114,7 @@ GEM
|
|
114
114
|
|
115
115
|
PLATFORMS
|
116
116
|
arm64-darwin-23
|
117
|
+
arm64-darwin-24
|
117
118
|
x86_64-linux
|
118
119
|
|
119
120
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ This gem provides a class called `OpenAI::Chat` that is intended to make it as e
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem "openai-chat"
|
10
|
+
gem "openai-chat"
|
11
11
|
```
|
12
12
|
|
13
13
|
And then, at a command prompt:
|
@@ -29,10 +29,10 @@ gem install openai-chat
|
|
29
29
|
```ruby
|
30
30
|
x = OpenAI::Chat.new(api_token: "your-token-goes-here")
|
31
31
|
```
|
32
|
-
- By default, the gem uses the `gpt-
|
32
|
+
- By default, the gem uses the `gpt-4.1-nano` model. If you want something else, you can set it:
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
x.model = "o3
|
35
|
+
x.model = "o3"
|
36
36
|
```
|
37
37
|
|
38
38
|
## Simplest usage
|
@@ -118,7 +118,7 @@ You can manually add assistant messages:
|
|
118
118
|
x.assistant("Greetings, good sir or madam! How dost thou fare on this fine day? Pray, tell me how I may be of service to thee.")
|
119
119
|
```
|
120
120
|
|
121
|
-
Useful if you are reconstructing
|
121
|
+
Useful if you are reconstructing a chat that has already happened.
|
122
122
|
|
123
123
|
## Getting and setting messages directly
|
124
124
|
|
data/lib/openai/chat/version.rb
CHANGED
data/lib/openai/chat.rb
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
|
5
5
|
module OpenAI
|
6
6
|
class Chat
|
7
|
-
attr_accessor :messages, :schema, :model
|
7
|
+
attr_accessor :messages, :schema, :model, :temperature
|
8
8
|
|
9
9
|
def initialize(api_token: nil)
|
10
10
|
@api_token = api_token || ENV.fetch("OPENAI_TOKEN")
|
11
11
|
@messages = []
|
12
|
-
@model = "gpt-
|
12
|
+
@model = "gpt-4.1-nano"
|
13
|
+
@temperature = 0
|
13
14
|
end
|
14
15
|
|
15
16
|
def system(content)
|
@@ -114,7 +115,8 @@ module OpenAI
|
|
114
115
|
request_body_hash = {
|
115
116
|
"model" => model,
|
116
117
|
"response_format" => response_format,
|
117
|
-
"messages" => messages
|
118
|
+
"messages" => messages,
|
119
|
+
"temperature" => temperature
|
118
120
|
}
|
119
121
|
|
120
122
|
request_body_json = JSON.generate(request_body_hash)
|
@@ -136,7 +138,7 @@ module OpenAI
|
|
136
138
|
end
|
137
139
|
|
138
140
|
def inspect
|
139
|
-
"#<#{self.class.name} @messages=#{messages.inspect} @model=#{@model.inspect} @schema=#{@schema.inspect}>"
|
141
|
+
"#<#{self.class.name} @messages=#{messages.inspect} @model=#{@model.inspect} @schema=#{@schema.inspect} @temperature=#{@temperature.inspect}>"
|
140
142
|
end
|
141
143
|
|
142
144
|
private
|
@@ -149,9 +151,7 @@ module OpenAI
|
|
149
151
|
# Attempt to parse as a URL.
|
150
152
|
begin
|
151
153
|
uri = URI.parse(obj)
|
152
|
-
if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
|
153
|
-
return :url
|
154
|
-
end
|
154
|
+
return :url if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
|
155
155
|
rescue URI::InvalidURIError
|
156
156
|
# Not a valid URL; continue to check if it's a file path.
|
157
157
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openai-chat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raghu Betina
|
8
8
|
- Jelani Woods
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
rubygems_version: 3.6.
|
154
|
+
rubygems_version: 3.6.2
|
155
155
|
specification_version: 4
|
156
156
|
summary: This gem provides a class called `OpenAI::Chat` that is intended to make
|
157
157
|
it as easy as possible to use OpenAI's Chat Completions endpoint.
|