foobara-open-ai-api 0.0.13 → 1.0.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: 1175861cd5bffc59f8a8983870d47446203f26dca35f0b2d97460a9790a9b8f4
4
- data.tar.gz: bfcd6da5578334bd366dca4f0685c32f64188235fba1b2e44816bcf7f5a5db60
3
+ metadata.gz: 580b42b00a345b7c65f43977cc32b59b80f8b5ff73994cdcd9ac5a91dbfa8dae
4
+ data.tar.gz: 5007d18f07b4b5277f03c5300f364f746ab2f345bf7b42548e243d4526744b4d
5
5
  SHA512:
6
- metadata.gz: 92c60ee4452241731ff44bd19b04c080a5ccaffd193820ae7fcd175f00679dc5071b10a9285241cd4bcbba1f89b820d4ca46df2f5684c553a9224710c46d513f
7
- data.tar.gz: 67db120db8e7ac0d2bc6071bbcffc3109d542142c3956895d9df1ceca541833553dec075a4408307960428fd990ff8b67ecd50e009559c394a874e2afbc941e0
6
+ metadata.gz: 594659af8ea5b44b664e41a8ef994c54ccda0c491802c35fc7d13bb66053db9b5332f4fed28459901d0883d639829e42b7af78e0faeb97d02193c98f89f1147a
7
+ data.tar.gz: de6260ca616e0d89198631585283ab4df2f8674e0b59d4f264d89372aabf5326a771bcec75640f17347bb14d9c33c2b237df181c31a4732e47665e12f7a90d37
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## [0.0.13] - 2025-03-01
1
+ ## [1.0.0] - 2025-07-08
2
+
3
+ - Retry with incremental/exponential backoff for 529s and 429s
4
+
5
+ ## [0.0.13] - 2025-06-27
2
6
 
3
7
  - Add temperature to CreateChatCompletion inputs
4
8
 
@@ -27,6 +27,27 @@ module Foobara
27
27
  def build_request_headers
28
28
  self.request_headers = { "Content-Type" => "application/json", "Authorization" => "Bearer #{api_token}" }
29
29
  end
30
+
31
+ def issue_http_request(failures = 0)
32
+ super()
33
+
34
+ return if failures > 6
35
+
36
+ case response.code
37
+ when "429"
38
+ # :nocov:
39
+ sleep 2 ** failures
40
+ issue_http_request(failures + 1)
41
+ # :nocov:
42
+ when "529"
43
+ # Do these even happen with openai? or only anthropic?
44
+ # :nocov:
45
+ failures += 1
46
+ sleep failures
47
+ issue_http_request(failures)
48
+ # :nocov:
49
+ end
50
+ end
30
51
  end
31
52
  end
32
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-open-ai-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi