foobara-open-ai-api 0.0.8 → 0.0.9

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: b1134ded66f3c63f8f0def005ed37383f5c69522899e51fe3316dce02c1210f8
4
- data.tar.gz: 0170e54de38d1b4ac99b8d7c110d67ce67dbb2da53bebca8fdf94dda7c0f0027
3
+ metadata.gz: 5e6cb9bdbfee03bc629c3c4b2641363f846dec53e14317860cda02c7be0faa22
4
+ data.tar.gz: 60f99581e848a20defcbfbc5f9ba5b01fa4b30a61a49bb8399c557eb8cfd2921
5
5
  SHA512:
6
- metadata.gz: be8f41c655f0a08a2c3b44a2c13ad9f5bf2f39fb055b2119b537a3459e344fb476bb672087e2887ae5e3d779bca81b93b0f9a2c0771a56f98b24a72fe26c8f9f
7
- data.tar.gz: 2f091240994a101906585d51cd6915d0153dd7d2eb1f011f63d6cfa8f7e8593144be01ce1877ca47e8096870eef4b91cfa31a8966d617a8d24fce695d0675b39
6
+ metadata.gz: f79050ea578166386b43af65ed4efe7249e92aba4d3c87eced62d5e8859a65634c2e852fd18a304fccfd8d904a4a7a40d7c4a092ab030b89fe9c7cd0c684cb2f
7
+ data.tar.gz: 3ae087e54109610caa2ce6d065d8658587b751612bf7ddc26e0a7b00b4f69a4ce5db72b1a85073979ca2f47d9ae951d6ce57e4e4c4a453e5eccb207961fb8d91
data/CHANGELOG.md CHANGED
@@ -1,9 +1,10 @@
1
- ## [0.0.7] - 2025-02-17
1
+ ## [0.0.8] - 2025-02-17
2
2
 
3
3
  - Add support for some newly added fields
4
4
  - Make sure our models don't break when OpenAI adds new attributes to their responses
5
5
  before we have a chance to update them
6
6
  - Implement ListModels
7
+ - Provide a way to set api token on project module
7
8
 
8
9
  ## [0.0.6] - 2025-02-16
9
10
 
@@ -4,18 +4,24 @@ module Foobara
4
4
  module Ai
5
5
  module OpenAiApi
6
6
  class BaseCommand < Foobara::Command
7
+ class << self
8
+ attr_accessor :api_token
9
+ end
10
+
7
11
  include HttpApiCommand
8
12
 
9
13
  base_url "https://api.openai.com/v1"
10
14
 
11
15
  inputs do
12
- # TODO: come up with some kind of execution context object to wrap all of these calls upon which
13
- # data wrapping a "request" can live instead of being passed around?
14
16
  api_token :string
15
17
  end
16
18
 
17
19
  def api_token
18
- inputs[:api_token] || ENV.fetch("OPENAI_API_KEY", nil)
20
+ inputs[:api_token] || BaseCommand.api_token || api_token_from_env
21
+ end
22
+
23
+ def api_token_from_env
24
+ ENV.fetch("OPENAI_API_KEY", nil)
19
25
  end
20
26
 
21
27
  def build_request_headers
@@ -5,6 +5,16 @@ module Foobara
5
5
  module Ai
6
6
  module OpenAiApi
7
7
  foobara_domain!
8
+
9
+ class << self
10
+ def api_token=(token)
11
+ BaseCommand.api_token = token
12
+ end
13
+
14
+ def api_token
15
+ BaseCommand.api_token
16
+ end
17
+ end
8
18
  end
9
19
  end
10
20
  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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi