ai-lite 0.6.0 → 0.6.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: 2866b9f2b18c63bf07b51f6193b421bbb5fa8afc435ee8a50ce16d4debef9d04
4
- data.tar.gz: d6bf73b903f387f2221b5d1c39e06de05901a7b3074161e59c773e649ccf4d6f
3
+ metadata.gz: 6f7c5581a41c1371b086b33502200da2ad06cab07cc202efd0f943616effb738
4
+ data.tar.gz: 3a1c897735f7aa945e4cca0fb3bea1a86c3beefc7e823e8a149b78e93ac3b7c8
5
5
  SHA512:
6
- metadata.gz: d26f6651189db9ad98ec5e5229808a8ede9cc1cb363ec66b5ade079fc1d23c14686ebed11047422b2c2882b9c1916352726385a4cac6f7ae539d510a3abd8923
7
- data.tar.gz: f5a3aef1e3312999d53ac57e0941b8fa34225b7b84e504fb7564293d7c60542bd06703bb029a032ecc9bdbcd5e7c3251287f470e146c589f0fec26dc15a199f9
6
+ metadata.gz: 6c5f349cdf43703435f4ab0c08216ce59c73737042ad179ed675339a37238b175dffdc96d5a0014ac0a89dca554e4ed4d4279c417bd13a25fd9dc80d4d9dadc7
7
+ data.tar.gz: 0475ffdba930c5a5dc6c463f78c6abfc7c14306b233b1d05c17e6e6aa5f20bb706271c994e4aec0f2f350f656bcda3c681716751e280968ec8962222cfdea432
data/README.md CHANGED
@@ -109,6 +109,7 @@ result = ai.chat(
109
109
  - `input`
110
110
  - `max_output_tokens`
111
111
  - optional `instructions`
112
+ - optional `previous_response_id`
112
113
  - optional `debug`
113
114
  - optional extra `options`
114
115
 
@@ -116,23 +117,36 @@ The default model is `gpt-5.5`.
116
117
 
117
118
  The OpenAI API URL is fixed to `https://api.openai.com/v1/responses`.
118
119
 
120
+ ### Message-Array Input
121
+
122
+ For a conversation with multiple input messages, pass an array using the OpenAI Responses API message shape:
123
+
124
+ ```ruby
125
+ result = ai.chat([
126
+ { role: "developer", content: "Be concise." },
127
+ { role: "user", content: "Explain dependency injection." }
128
+ ])
129
+ ```
130
+
131
+ AI Lite sends the array unchanged as `input`, so you can also use richer Responses API content items when needed.
132
+
119
133
  ### Multi-Turn Chat
120
134
 
121
- Responses include a `response_id` that can be passed back through `options` as `previous_response_id`:
135
+ Responses include a `response_id`. Pass it to the next call as `previous_response_id` to continue the conversation:
122
136
 
123
137
  ```ruby
124
138
  first = ai.chat("Tell me a short joke.")
125
139
 
126
140
  follow_up = ai.chat(
127
141
  "Explain why that is funny.",
128
- options: {
129
- previous_response_id: first["response_id"]
130
- }
142
+ previous_response_id: first["response_id"]
131
143
  )
132
144
 
133
145
  puts follow_up["content"]
134
146
  ```
135
147
 
148
+ Passing `previous_response_id` through `options` remains supported for backward compatibility.
149
+
136
150
  ## Moderation
137
151
 
138
152
  Use `moderate` to classify user-submitted text or images for potentially harmful content before saving, publishing, or sending it into another AI call.
@@ -1,3 +1,3 @@
1
1
  class AiLite
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.6.1".freeze
3
3
  end
data/lib/ai_lite.rb CHANGED
@@ -124,13 +124,14 @@ class AiLite
124
124
  }
125
125
  end
126
126
 
127
- def chat(message, model: nil, instructions: nil, max_output_tokens: nil, debug: false, options: {})
127
+ def chat(message, model: nil, instructions: nil, previous_response_id: nil, max_output_tokens: nil, debug: false, options: {})
128
128
  payload = options.merge(
129
129
  model: model || self.model,
130
130
  input: message,
131
131
  max_output_tokens: max_output_tokens || self.max_output_tokens
132
132
  )
133
133
  payload[:instructions] = instructions if instructions
134
+ payload[:previous_response_id] = previous_response_id if previous_response_id
134
135
 
135
136
  extract_content(post(payload), debug: debug)
136
137
  rescue => e
data/test/ai_lite_test.rb CHANGED
@@ -238,15 +238,13 @@ class AiLiteTest < Minitest::Test
238
238
  end
239
239
  end
240
240
 
241
- def test_chat_supports_previous_response_id_through_options
241
+ def test_chat_supports_previous_response_id
242
242
  client = AiLite.new(api_key: "token-abc")
243
243
 
244
244
  with_stubbed_http(success_response("Follow-up")) do |captured, _response|
245
245
  result = client.chat(
246
246
  "Explain why that is funny",
247
- options: {
248
- previous_response_id: "resp_previous_123"
249
- }
247
+ previous_response_id: "resp_previous_123"
250
248
  )
251
249
  payload = JSON.parse(captured[:http].last_request.body)
252
250
 
@@ -256,6 +254,53 @@ class AiLiteTest < Minitest::Test
256
254
  end
257
255
  end
258
256
 
257
+ def test_chat_supports_message_array_input
258
+ client = AiLite.new(api_key: "token-abc")
259
+ messages = [
260
+ { role: "developer", content: "Be concise." },
261
+ { role: "user", content: "Say hello." }
262
+ ]
263
+
264
+ with_stubbed_http(success_response("Hello!")) do |captured, _response|
265
+ client.chat(messages)
266
+ payload = JSON.parse(captured[:http].last_request.body)
267
+
268
+ assert_equal(
269
+ [
270
+ { "role" => "developer", "content" => "Be concise." },
271
+ { "role" => "user", "content" => "Say hello." }
272
+ ],
273
+ payload["input"]
274
+ )
275
+ end
276
+ end
277
+
278
+ def test_chat_first_class_previous_response_id_overrides_options
279
+ client = AiLite.new(api_key: "token-abc")
280
+
281
+ with_stubbed_http(success_response("Follow-up")) do |captured, _response|
282
+ client.chat(
283
+ "Continue",
284
+ previous_response_id: "resp_keyword",
285
+ options: { previous_response_id: "resp_options" }
286
+ )
287
+ payload = JSON.parse(captured[:http].last_request.body)
288
+
289
+ assert_equal "resp_keyword", payload["previous_response_id"]
290
+ end
291
+ end
292
+
293
+ def test_chat_keeps_supporting_previous_response_id_through_options
294
+ client = AiLite.new(api_key: "token-abc")
295
+
296
+ with_stubbed_http(success_response("Follow-up")) do |captured, _response|
297
+ client.chat("Continue", options: { previous_response_id: "resp_options" })
298
+ payload = JSON.parse(captured[:http].last_request.body)
299
+
300
+ assert_equal "resp_options", payload["previous_response_id"]
301
+ end
302
+ end
303
+
259
304
  def test_extracts_text_from_nested_output_text_items
260
305
  client = AiLite.new(api_key: "token-abc")
261
306
  body = JSON.generate(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Basmayor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-16 00:00:00.000000000 Z
11
+ date: 2026-10-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: AI Lite is a dependency-light Ruby client for Rails apps and plain Ruby
14
14
  projects that need simple OpenAI chat, moderation, embedding, image, speech, and