foobara-open-ai-api 0.0.12 → 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: b3c5966b6692ffdef84569de5e5087aade3acb26a9d1d9883fff6a0e090c26a8
4
- data.tar.gz: bd73776101d5e3fa6d1e8f731892161c88ef8f58b3938d2750cd90430da097bf
3
+ metadata.gz: 580b42b00a345b7c65f43977cc32b59b80f8b5ff73994cdcd9ac5a91dbfa8dae
4
+ data.tar.gz: 5007d18f07b4b5277f03c5300f364f746ab2f345bf7b42548e243d4526744b4d
5
5
  SHA512:
6
- metadata.gz: 713b5bdc80f81c35da510acc44aff511de9e9eff0100fddc808d49a4c93e64fea826d604d610a9ced37682c10e957af76f8dd06fd2ef4a0a3b0899d0110e60d0
7
- data.tar.gz: 4a3828d31cea93a4b8163a62182bf3bb2521acf23ba2679c21274b73fa31eab86bd57998aceae94bf0149349648a4eee0db882ecc95f961f15040390d63fd93f
6
+ metadata.gz: 594659af8ea5b44b664e41a8ef994c54ccda0c491802c35fc7d13bb66053db9b5332f4fed28459901d0883d639829e42b7af78e0faeb97d02193c98f89f1147a
7
+ data.tar.gz: de6260ca616e0d89198631585283ab4df2f8674e0b59d4f264d89372aabf5326a771bcec75640f17347bb14d9c33c2b237df181c31a4732e47665e12f7a90d37
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
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
6
+
7
+ - Add temperature to CreateChatCompletion inputs
8
+
1
9
  ## [0.0.12] - 2025-03-01
2
10
 
3
11
  - Rename :model to :model_enum to avoid collision with Model in filesystems that are case-insensitive
@@ -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
@@ -10,15 +10,16 @@ module Foobara
10
10
  add_inputs do
11
11
  model :model_enum, default: Types::ModelEnum::GPT_3_5_TURBO
12
12
  messages :array do
13
- role :string, one_of: %w[system user assistant]
13
+ role :string, one_of: ["system", "user", "assistant"]
14
14
  content :string
15
15
  end
16
+ temperature :float
16
17
  end
17
18
 
18
19
  result Types::ChatCompletion
19
20
 
20
21
  def build_request_body
21
- self.request_body = { model:, messages: }
22
+ self.request_body = { model:, messages:, temperature: }
22
23
  end
23
24
 
24
25
  def build_result
@@ -8,7 +8,7 @@ module Foobara
8
8
  index :integer
9
9
  message Message
10
10
  logprobs :duck # what is this? null in documentation
11
- finish_reason :string, one_of: %w[stop] # what are the real values here?
11
+ finish_reason :string, one_of: ["stop"] # what are the real values here?
12
12
  end
13
13
  end
14
14
  end
@@ -5,7 +5,7 @@ module Foobara
5
5
  class ChatCompletion < Foobara::Model
6
6
  class Message < Foobara::Model
7
7
  attributes do
8
- role :string, one_of: %w[assistant user system]
8
+ role :string, one_of: ["assistant", "user", "system"]
9
9
  content :string
10
10
  refusal :string, :allow_nil
11
11
  end
@@ -12,7 +12,7 @@ module Foobara
12
12
  system_fingerprint :string, :allow_nil
13
13
  choices [Choice]
14
14
  usage Usage
15
- service_tier :string, :allow_nil, one_of: %w[auto default]
15
+ service_tier :string, :allow_nil, one_of: ["auto", "default"]
16
16
  end
17
17
  end
18
18
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-open-ai-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara-cached-command
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.6.3
86
+ rubygems_version: 3.6.9
87
87
  specification_version: 4
88
88
  summary: Foobara commands and models for OpenAI's API
89
89
  test_files: []