ai-chat 0.7.0 → 0.8.1
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 +7 -7
- data/ai-chat.gemspec +1 -1
- data/lib/ai/chat.rb +5 -5
- data/lib/ai/items.rb +2 -0
- data/lib/ai/message.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc97776343765eccd577dce51e9988f4166971b745e5d9c37dd91d4a0bd8d67c
|
|
4
|
+
data.tar.gz: a33c87723c355331c0b416872e7c788b68b53c8240ed1ebe9b9ab5d73e98ee08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 639236eb1189cf3fdb254044f5e372ccd2067f931f9dab953dc26eafe324e751b957c476703a1e67cfdc9f2327e822ffe1701b1cfad35d122b2b5527ea4f718f
|
|
7
|
+
data.tar.gz: 2f6d191c96cc6011a077252042ebbed48032f4652d4605ae199de2c63cf4b4742f0b0155e1a0c56959020834af4386f8d36fed19f6d3d9bdf3e090d39797a50a
|
data/README.md
CHANGED
|
@@ -56,7 +56,7 @@ ap response
|
|
|
56
56
|
# => {
|
|
57
57
|
# :role => "assistant",
|
|
58
58
|
# :content => "Matz is nice and so we are nice.",
|
|
59
|
-
# :response => { id: "resp_abc...", model: "gpt-
|
|
59
|
+
# :response => { id: "resp_abc...", model: "gpt-6-luna", ... }
|
|
60
60
|
# }
|
|
61
61
|
|
|
62
62
|
ap chat.messages
|
|
@@ -68,7 +68,7 @@ ap chat.messages
|
|
|
68
68
|
# {
|
|
69
69
|
# :role => "assistant",
|
|
70
70
|
# :content => "Matz is nice and so we are nice.",
|
|
71
|
-
# :response => { id: "resp_abc...", model: "gpt-
|
|
71
|
+
# :response => { id: "resp_abc...", model: "gpt-6-luna", ... }
|
|
72
72
|
# }
|
|
73
73
|
# ]
|
|
74
74
|
```
|
|
@@ -131,11 +131,11 @@ chat.add("Here's what I think...", role: "assistant")
|
|
|
131
131
|
|
|
132
132
|
### Model
|
|
133
133
|
|
|
134
|
-
The gem defaults to `gpt-
|
|
134
|
+
The gem defaults to `gpt-6-luna`. You can change it:
|
|
135
135
|
|
|
136
136
|
```ruby
|
|
137
137
|
chat = AI::Chat.new
|
|
138
|
-
chat.model = "gpt-
|
|
138
|
+
chat.model = "gpt-6.1-sol"
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
### API Key
|
|
@@ -409,9 +409,9 @@ chat.user("Explain the tradeoffs between microservices and monoliths.")
|
|
|
409
409
|
chat.generate!
|
|
410
410
|
```
|
|
411
411
|
|
|
412
|
-
By default, `reasoning_effort` is `"
|
|
412
|
+
By default, `reasoning_effort` is `"low"`, so the model does a little reasoning before it answers. `"low"` is accepted by all of OpenAI's current flagship models (`gpt-6-luna`, `gpt-6.1-sol`, and `gpt-6-astra`), while some of them reject `"none"`, so you can switch models without also changing the effort. The gem always sends an effort because GPT-5.5 and newer models fall back to `"medium"` when the parameter is omitted, which is slower and more expensive.
|
|
413
413
|
|
|
414
|
-
Set `reasoning_effort = nil` to omit the reasoning parameter entirely — you will need this if you switch to a model that does not support reasoning (e.g., `gpt-4o`)
|
|
414
|
+
Set `reasoning_effort = "none"` for the fastest replies on models that support it (such as `gpt-6-luna`). Set `reasoning_effort = nil` to omit the reasoning parameter entirely — you will need this if you switch to a model that does not support reasoning (e.g., `gpt-4o`).
|
|
415
415
|
|
|
416
416
|
### Verbosity
|
|
417
417
|
|
|
@@ -476,7 +476,7 @@ chat.generate!
|
|
|
476
476
|
|
|
477
477
|
response = chat.last[:response]
|
|
478
478
|
response[:id] # => "resp_abc123..."
|
|
479
|
-
response[:model] # => "gpt-
|
|
479
|
+
response[:model] # => "gpt-6-luna"
|
|
480
480
|
response[:usage] # => { input_tokens: 5, output_tokens: 7, total_tokens: 12 }
|
|
481
481
|
```
|
|
482
482
|
|
data/ai-chat.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "ai-chat"
|
|
5
|
-
spec.version = "0.
|
|
5
|
+
spec.version = "0.8.1"
|
|
6
6
|
spec.authors = ["Raghu Betina", "Jelani Woods"]
|
|
7
7
|
spec.email = ["raghu@firstdraft.com", "jelani@firstdraft.com"]
|
|
8
8
|
spec.homepage = "https://github.com/firstdraft/ai-chat"
|
data/lib/ai/chat.rb
CHANGED
|
@@ -32,8 +32,8 @@ module AI
|
|
|
32
32
|
@proxy = proxy.nil? ? ENV[PROXY_ENV]&.downcase == "true" : !!proxy
|
|
33
33
|
@api_key = resolve_api_key
|
|
34
34
|
@messages = []
|
|
35
|
-
@reasoning_effort = "
|
|
36
|
-
@model = "gpt-
|
|
35
|
+
@reasoning_effort = "low"
|
|
36
|
+
@model = "gpt-6-luna"
|
|
37
37
|
client_options = {api_key: @api_key}
|
|
38
38
|
client_options[:base_url] = BASE_PROXY_URL if @proxy
|
|
39
39
|
@client = OpenAI::Client.new(**client_options)
|
|
@@ -46,7 +46,7 @@ module AI
|
|
|
46
46
|
|
|
47
47
|
def self.generate_schema!(description, location: "schema.json", api_key: nil, api_key_env_var: nil, proxy: nil)
|
|
48
48
|
proxy = proxy.nil? ? ENV[PROXY_ENV]&.downcase == "true" : !!proxy
|
|
49
|
-
api_key
|
|
49
|
+
api_key ||= ENV.fetch(api_key_env_var || (proxy ? PROXY_KEY_ENV : OPENAI_KEY_ENV))
|
|
50
50
|
prompt_path = File.expand_path("../prompts/schema_generator.md", __dir__)
|
|
51
51
|
system_prompt = File.read(prompt_path)
|
|
52
52
|
|
|
@@ -57,7 +57,7 @@ module AI
|
|
|
57
57
|
|
|
58
58
|
client = OpenAI::Client.new(**options)
|
|
59
59
|
response = client.responses.create(
|
|
60
|
-
model: "gpt-
|
|
60
|
+
model: "gpt-6-luna",
|
|
61
61
|
input: [
|
|
62
62
|
{role: :system, content: system_prompt},
|
|
63
63
|
{role: :user, content: description}
|
|
@@ -175,7 +175,7 @@ module AI
|
|
|
175
175
|
@api_key = new_key
|
|
176
176
|
@api_key_validated = false
|
|
177
177
|
@client = new_client
|
|
178
|
-
rescue
|
|
178
|
+
rescue
|
|
179
179
|
@proxy = previous_proxy
|
|
180
180
|
raise
|
|
181
181
|
end
|
data/lib/ai/items.rb
CHANGED
data/lib/ai/message.rb
CHANGED
|
@@ -11,8 +11,11 @@ module AI
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# IRB's ColorPrinter calls pretty_print and re-colorizes text,
|
|
14
|
-
# which escapes our ANSI codes. Write directly to output to bypass
|
|
14
|
+
# which escapes our ANSI codes. Write directly to output to bypass,
|
|
15
|
+
# but flush first: inside an Array, PP is still buffering the "[" and
|
|
16
|
+
# earlier separators, so an unflushed write lands ahead of them.
|
|
15
17
|
def pretty_print(q)
|
|
18
|
+
q.flush
|
|
16
19
|
q.output << inspect
|
|
17
20
|
end
|
|
18
21
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ai-chat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Raghu Betina
|
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
156
156
|
- !ruby/object:Gem::Version
|
|
157
157
|
version: '0'
|
|
158
158
|
requirements: []
|
|
159
|
-
rubygems_version:
|
|
159
|
+
rubygems_version: 4.0.3
|
|
160
160
|
specification_version: 4
|
|
161
161
|
summary: A beginner-friendly Ruby interface for OpenAI's API
|
|
162
162
|
test_files: []
|