Skip to content

Commit a4549cc

Browse files
committed
Update gem name in README
1 parent fb89778 commit a4549cc

2 files changed

Lines changed: 38 additions & 38 deletions

File tree

CITATION.cff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cff-version: 1.2.0
22
message: Please use the following metadata when citing this project in your work.
3-
title: Openai Chat
3+
title: AI Chat
44
abstract:
55
version: 0.0.0
66
license: Hippocratic-2.1
@@ -12,6 +12,6 @@ authors:
1212
orcid: https://orcid.org/
1313
keywords:
1414
- ruby
15-
repository-code: https://github.com/undefined/openai-chat
16-
repository-artifact: https://rubygems.org/gems/openai-chat
17-
url: https://undefined.io/projects/openai-chat
15+
repository-code: https://github.com/undefined/ai-chat
16+
repository-artifact: https://rubygems.org/gems/ai-chat
17+
url: https://undefined.io/projects/ai-chat

README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# OpenAI Chat
1+
# AI Chat
22

3-
This gem provides a class called `OpenAI::Chat` that is intended to make it as easy as possible to use OpenAI's cutting-edge generative AI models.
3+
This gem provides a class called `AI::Chat` that is intended to make it as easy as possible to use OpenAI's cutting-edge generative AI models.
44

55
## Installation
66

@@ -9,7 +9,7 @@ This gem provides a class called `OpenAI::Chat` that is intended to make it as e
99
Add this line to your application's Gemfile:
1010

1111
```ruby
12-
gem "openai-chat", "< 1.0.0"
12+
gem "ai-chat", "< 1.0.0"
1313
```
1414

1515
And then, at a command prompt:
@@ -23,18 +23,18 @@ bundle install
2323
Or, install it directly with:
2424

2525
```
26-
gem install openai-chat
26+
gem install ai-chat
2727
```
2828

2929
## Simplest usage
3030

3131
In your Ruby program:
3232

3333
```ruby
34-
require "openai/chat"
34+
require "ai-chat"
3535

36-
# Create an instance of OpenAI::Chat
37-
a = OpenAI::Chat.new
36+
# Create an instance of AI::Chat
37+
a = AI::Chat.new
3838

3939
# Build up your conversation by adding messages
4040
a.add("If the Ruby community had an official motto, what might it be?")
@@ -50,7 +50,7 @@ a.generate! # => "Matz is nice and so we are nice" (or similar)
5050
pp a.messages
5151
# => [
5252
# {:role=>"user", :content=>"If the Ruby community had an official motto, what might it be?"},
53-
# {:role=>"assistant", :content=>"Matz is nice and so we are nice", :response => #<OpenAI::Chat::Response id=resp_abc... model=gpt-4.1-nano tokens=12>}
53+
# {:role=>"assistant", :content=>"Matz is nice and so we are nice", :response => #<AI::Chat::Response id=resp_abc... model=gpt-4.1-nano tokens=12>}
5454
# ]
5555

5656
# Continue the conversation
@@ -70,7 +70,7 @@ That's it! You're building something like this:
7070
[
7171
{:role => "system", :content => "You are a helpful assistant"},
7272
{:role => "user", :content => "Hello!"},
73-
{:role => "assistant", :content => "Hi there! How can I help you today?", :response => #<OpenAI::Chat::Response id=resp_abc... model=gpt-4.1-nano tokens=12>}
73+
{:role => "assistant", :content => "Hi there! How can I help you today?", :response => #<AI::Chat::Response id=resp_abc... model=gpt-4.1-nano tokens=12>}
7474
]
7575
```
7676

@@ -79,9 +79,9 @@ That last bit, under `:response`, is an object that represents the JSON that the
7979
## Adding Different Types of Messages
8080

8181
```ruby
82-
require "openai/chat"
82+
require "ai-chat"
8383

84-
b = OpenAI::Chat.new
84+
b = AI::Chat.new
8585

8686
# Add system instructions
8787
b.add("You are a helpful assistant that talks like Shakespeare.", role: "system")
@@ -105,7 +105,7 @@ b.generate! # => "Methinks 'tis 'Ruby doth bring joy to all who craft with care'
105105
Instead of always specifying the role, you can use these shortcuts:
106106

107107
```ruby
108-
c = OpenAI::Chat.new
108+
c = AI::Chat.new
109109

110110
# These are equivalent:
111111
c.add("You are helpful", role: "system")
@@ -130,7 +130,7 @@ We use the `add` method (and its shortcuts) to build up an array because:
130130

131131
```ruby
132132
# In a Rails app, you might do:
133-
d = OpenAI::Chat.new
133+
d = AI::Chat.new
134134
d.messages = @conversation.messages # Load existing messages
135135
d.user("What should I do next?") # Add a new question
136136
d.generate! # Generate a response
@@ -143,7 +143,7 @@ d.generate! # Generate a response
143143
By default, the gem uses OpenAI's `gpt-4.1-nano` model. If you want to use a different model, you can set it:
144144

145145
```ruby
146-
e = OpenAI::Chat.new
146+
e = AI::Chat.new
147147
e.model = "o4-mini"
148148
```
149149

@@ -167,21 +167,21 @@ The gem by default looks for an environment variable called `OPENAI_API_KEY` and
167167
You can specify a different environment variable name:
168168

169169
```ruby
170-
f = OpenAI::Chat.new(api_key_env_var: "MY_OPENAI_TOKEN")
170+
f = AI::Chat.new(api_key_env_var: "MY_OPENAI_TOKEN")
171171
```
172172

173173
Or, you can pass an API key in directly:
174174

175175
```ruby
176-
g = OpenAI::Chat.new(api_key: "your-api-key-goes-here")
176+
g = AI::Chat.new(api_key: "your-api-key-goes-here")
177177
```
178178

179179
## Inspecting Your Conversation
180180

181181
You can call `.messages` to get an array containing the conversation so far:
182182

183183
```ruby
184-
h = OpenAI::Chat.new
184+
h = AI::Chat.new
185185
h.system("You are a helpful cooking assistant")
186186
h.user("How do I boil an egg?")
187187
h.generate!
@@ -208,7 +208,7 @@ h.last
208208
Get back Structured Output by setting the `schema` attribute (I suggest using [OpenAI's handy tool for generating the JSON Schema](https://platform.openai.com/docs/guides/structured-outputs)):
209209

210210
```ruby
211-
i = OpenAI::Chat.new
211+
i = AI::Chat.new
212212

213213
i.system("You are an expert nutritionist. The user will describe a meal. Estimate the calories, carbs, fat, and protein.")
214214

@@ -253,7 +253,7 @@ The keys can be `String`s or `Symbol`s.
253253
You can include images in your chat messages using the `user` method with the `image` or `images` parameter:
254254

255255
```ruby
256-
j = OpenAI::Chat.new
256+
j = AI::Chat.new
257257

258258
# Send a single image
259259
j.user("What's in this image?", image: "path/to/local/image.jpg")
@@ -282,7 +282,7 @@ The gem supports three types of image inputs:
282282
To give the model access to real-time information from the internet, you can enable the `web_search` feature. This uses OpenAI's built-in `web_search_preview` tool.
283283

284284
```ruby
285-
m = OpenAI::Chat.new
285+
m = AI::Chat.new
286286
m.web_search = true
287287
m.user("What are the latest developments in the Ruby language?")
288288
m.generate! # This may use web search to find current information
@@ -296,7 +296,7 @@ You can manually add assistant messages without making API calls, which is usefu
296296

297297
```ruby
298298
# Create a new chat instance
299-
k = OpenAI::Chat.new
299+
k = AI::Chat.new
300300

301301
# Add previous messages
302302
k.system("You are a helpful assistant who provides information about planets.")
@@ -316,14 +316,14 @@ response = k.generate!
316316
puts response
317317
```
318318

319-
With this, you can loop through any conversation's history (perhaps after retrieving it from your database), recreate an `OpenAI::Chat`, and then continue it.
319+
With this, you can loop through any conversation's history (perhaps after retrieving it from your database), recreate an `AI::Chat`, and then continue it.
320320

321321
## Reasoning Models
322322

323323
When using reasoning models like `o3` or `o4-mini`, you can specify a reasoning effort level to control how much reasoning the model does before producing its final response:
324324

325325
```ruby
326-
l = OpenAI::Chat.new
326+
l = AI::Chat.new
327327
l.model = "o3-mini"
328328
l.reasoning_effort = "medium" # Can be "low", "medium", or "high"
329329

@@ -343,7 +343,7 @@ Setting to `nil` disables the reasoning parameter.
343343
When you call `generate!` or `generate!`, the gem stores additional information about the API response:
344344

345345
```ruby
346-
t = OpenAI::Chat.new
346+
t = AI::Chat.new
347347
t.user("Hello!")
348348
t.generate!
349349

@@ -352,7 +352,7 @@ pp t.messages.last
352352
# => {
353353
# :role => "assistant",
354354
# :content => "Hello! How can I help you today?",
355-
# :response => #<OpenAI::Chat::Response id=resp_abc... model=gpt-4.1-nano tokens=12>
355+
# :response => #<AI::Response id=resp_abc... model=gpt-4.1-nano tokens=12>
356356
# }
357357

358358
# Access detailed information
@@ -376,17 +376,17 @@ This information is useful for:
376376
You can also, if you know a response ID, pick up an old conversation at that point in time:
377377

378378
```ruby
379-
t = OpenAI::Chat.new
379+
t = AI::Chat.new
380380
t.user("Hello!")
381381
t.generate!
382382
old_id = t.last_response_id # => "resp_abc123..."
383383

384384
# Some time in the future...
385385

386-
u = OpenAI::Chat.new
386+
u = AI::Chat.new
387387
u.pick_up_from("resp_abc123...")
388388
u.messages # => [
389-
# {:role=>"assistant", :response => #<OpenAI::Chat::Response id=resp_abc...}
389+
# {:role=>"assistant", :response => #<AI::Chat::Response id=resp_abc...}
390390
# ]
391391
u.user("What should we do next?")
392392
u.generate!
@@ -400,7 +400,7 @@ You can use `.messages=()` to assign an `Array` of `Hashes`. Each `Hash` must ha
400400

401401
```ruby
402402
# Using the planet example with array of hashes
403-
p = OpenAI::Chat.new
403+
p = AI::Chat.new
404404

405405
# Set all messages at once instead of calling methods sequentially
406406
p.messages = [
@@ -423,7 +423,7 @@ You can still include images:
423423

424424
```ruby
425425
# Create a new chat instance
426-
q = OpenAI::Chat.new
426+
q = AI::Chat.new
427427

428428
# With images
429429
q.messages = [
@@ -446,7 +446,7 @@ If your chat history is contained in an `ActiveRecord::Relation`, you can assign
446446
# Load from ActiveRecord
447447
@thread = Thread.find(42)
448448

449-
r = OpenAI::Chat.new
449+
r = AI::Chat.new
450450
r.messages = @thread.posts.order(:created_at)
451451
r.user("What should we discuss next?")
452452
r.generate! # Creates a new post record, too
@@ -466,7 +466,7 @@ In order for the above to "magically" work, there are a few requirements. Your A
466466
If your columns have different names:
467467

468468
```ruby
469-
s = OpenAI::Chat.new
469+
s = AI::Chat.new
470470
s.configure_message_attributes(
471471
role: :message_type, # Your column for role
472472
content: :message_body, # Your column for content
@@ -485,13 +485,13 @@ add_column :messages, :openai_response, :text
485485

486486
# In your model
487487
class Message < ApplicationRecord
488-
serialize :openai_response, OpenAI::Chat::Response
488+
serialize :openai_response, AI::Chat::Response
489489
end
490490

491491
# Usage
492492
@thread = Thread.find(42)
493493

494-
t = OpenAI::Chat.new
494+
t = AI::Chat.new
495495
t.posts = @thread.messages
496496
t.user("Hello!")
497497
t.generate!

0 commit comments

Comments
 (0)