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 +4 -4
- data/CHANGELOG.md +5 -1
- data/src/foobara/ai/open_ai_api/base_command.rb +21 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580b42b00a345b7c65f43977cc32b59b80f8b5ff73994cdcd9ac5a91dbfa8dae
|
4
|
+
data.tar.gz: 5007d18f07b4b5277f03c5300f364f746ab2f345bf7b42548e243d4526744b4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 594659af8ea5b44b664e41a8ef994c54ccda0c491802c35fc7d13bb66053db9b5332f4fed28459901d0883d639829e42b7af78e0faeb97d02193c98f89f1147a
|
7
|
+
data.tar.gz: de6260ca616e0d89198631585283ab4df2f8674e0b59d4f264d89372aabf5326a771bcec75640f17347bb14d9c33c2b237df181c31a4732e47665e12f7a90d37
|
data/CHANGELOG.md
CHANGED
@@ -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
|