nitro_intelligence 2.7.0 → 2.8.0

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: d87085d656ea4f0e2ee7ee00f1d1e360de33aa91257847a7c127ba65082b5e7c
4
- data.tar.gz: f7587153b62be7ab17a60302ce8438ab483d35e9b499aee634c69cd1388cf2a9
3
+ metadata.gz: 5f65b41b164172defbd342f01a3be82035ce33ce1f057a64700391fddacc8d51
4
+ data.tar.gz: 8c1086916735274f86154cebf70bc7cc91e30b2459da5e9adc3bb773e18f661d
5
5
  SHA512:
6
- metadata.gz: ea8307af597a82b4e7511589eb5258ab1006805a63e3cc358dc7db6b2ca55882b0e522701667d7b98f5d851e89b214b9290d3c9330ff27a8957290c3c00584c8
7
- data.tar.gz: 9a891b5281ec8f6f34b4611ab8a0204027b5c14a9b63ea02999f273386a06ab9b4d2a5410b18be0041b6acb4ad7ace1f8146c2115148dc81d70c12b2372a37a6
6
+ metadata.gz: 9e8ed2298e83a75a257a91df4fd8ad1a64a86e53ef312f6c4b466bd5b9e88753c45af292fa1af3896f9fd8b7804222dbba54f23ed22962e28e4b7d20b398154e
7
+ data.tar.gz: 77f1fe28780cc5ea002754a102ae5b28046104597d8c18a76f2c5e4b50523df475f5e2ec2afd7d8159236621a435e1b2109e656bbd9e2c04cf8094feac8c7654
@@ -207,9 +207,19 @@ module NitroIntelligence
207
207
  raise RunError, run_response.body if run_response.code.to_i != 200
208
208
 
209
209
  run = JSON.parse(run_response.body)
210
+ raise_run_error!(run, RunError)
211
+
210
212
  Array(run["messages"]).last&.dig("content")
211
213
  end
212
214
 
215
+ def raise_run_error!(run, error)
216
+ failure = run["__error__"]
217
+ return if failure.blank?
218
+
219
+ detail = failure.is_a?(Hash) ? [failure["error"], failure["message"]].compact.join(": ") : failure.to_s
220
+ raise error, detail
221
+ end
222
+
213
223
  def resume_run(thread_id:, assistant_id:, resume:, context:)
214
224
  run_response = post(
215
225
  path: "/threads/#{thread_id}/runs/wait",
@@ -224,7 +234,10 @@ module NitroIntelligence
224
234
 
225
235
  raise ThreadResumptionError, run_response.body if run_response.code.to_i != 200
226
236
 
227
- JSON.parse(run_response.body)
237
+ run = JSON.parse(run_response.body)
238
+ raise_run_error!(run, ThreadResumptionError)
239
+
240
+ run
228
241
  end
229
242
 
230
243
  def interrupted?(thread)
@@ -61,10 +61,9 @@ module NitroIntelligence
61
61
 
62
62
  private
63
63
 
64
- # `last_response` carries the HTTP metadata of the response a typed model was
65
- # built from. The client leaves it unset on nested and locally constructed
66
- # models, and on endpoints returning raw or binary payloads, so both the
67
- # method and its value are optional.
64
+ # `last_response` carries the HTTP metadata of the response a model was built
65
+ # from. The client leaves it unset on nested and locally constructed models,
66
+ # so both the method and its value are optional.
68
67
  def response_headers(response)
69
68
  return nil unless response.respond_to?(:last_response)
70
69
 
@@ -79,11 +79,13 @@ module NitroIntelligence
79
79
  output = handle_text_to_speech_upload(tempfile, trace_id)
80
80
  end
81
81
 
82
- # We only get StringIO object as a response, so there are no usage details
83
- # and no resolved model to record. The requested model and the input are
84
- # already on the observation from before the request ran.
82
+ # Usage details and the resolved model are read off a response body, and
83
+ # this endpoint's body is audio, so neither is available here. The
84
+ # requested model and the input are already on the observation from
85
+ # before the request ran.
85
86
  trace_attributes = {
86
87
  output:,
88
+ cost_details: @base_handler.cost_details(tts),
87
89
  }
88
90
 
89
91
  [tts, trace_attributes]
@@ -1,3 +1,3 @@
1
1
  module NitroIntelligence
2
- VERSION = "2.7.0".freeze
2
+ VERSION = "2.8.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitro_intelligence
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Artemenko
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.79'
60
+ version: '0.86'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.79'
67
+ version: '0.86'
68
68
  description: The Ruby client for Nitro Intelligence
69
69
  email:
70
70
  - igor.artemenko@powerhrg.com