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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc2941185cac34d62d83233dd4e680fe84e5260cd4444ab168207c1b14064d9b
4
- data.tar.gz: 7aa8e27049a66787cd49319d45421b8a82bb5a44fe622a1878c0e045ff341373
3
+ metadata.gz: bc97776343765eccd577dce51e9988f4166971b745e5d9c37dd91d4a0bd8d67c
4
+ data.tar.gz: a33c87723c355331c0b416872e7c788b68b53c8240ed1ebe9b9ab5d73e98ee08
5
5
  SHA512:
6
- metadata.gz: 5fa4dc0c4a18a484e676c7b14f1de69fd6d4c814f6bc4be5f1c91fcb56294b90f324a890e8c2f954bf2fe4528f75328c5a0c4b5e8dec8fb8ed94a5f20446a276
7
- data.tar.gz: ade82f46956897d29530401ddc604977bab731e6c0714e4904d1cae4d7e853b6ad23a0a5eef4dbeca2b2ea4fd3e690aacb1bde0812e27a67cfb08504dc3f5000
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-5.6-terra", ... }
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-5.6-terra", ... }
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-5.6-terra`. You can change it:
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-5.6-luna"
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 `"none"`, so the model answers directly without spending reasoning tokens. This matters because GPT-5.5 and newer models (including the default `gpt-5.6-terra`) fall back to `"medium"` reasoning when the parameter is omitted, which is slower and more expensive.
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`) or one that predates the `"none"` option.
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-5.6-terra"
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.7.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 = "none"
36
- @model = "gpt-5.6-terra"
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 = api_key || ENV.fetch(api_key_env_var || (proxy ? PROXY_KEY_ENV : OPENAI_KEY_ENV))
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-5.6-terra",
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 => error
178
+ rescue
179
179
  @proxy = previous_proxy
180
180
  raise
181
181
  end
data/lib/ai/items.rb CHANGED
@@ -35,7 +35,9 @@ module AI
35
35
  "#{inspect}\n"
36
36
  end
37
37
 
38
+ # Same direct write as AI::Message#pretty_print, for the same reasons.
38
39
  def pretty_print(q)
40
+ q.flush
39
41
  q.output << inspect
40
42
  end
41
43
 
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.7.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: 3.6.9
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: []