foobara-open-ai-api 0.0.9 → 0.0.11

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: 5e6cb9bdbfee03bc629c3c4b2641363f846dec53e14317860cda02c7be0faa22
4
- data.tar.gz: 60f99581e848a20defcbfbc5f9ba5b01fa4b30a61a49bb8399c557eb8cfd2921
3
+ metadata.gz: 8c61e466a2f1f4ce7908a205c89f8518e0c0bae5f05f507011352b546e796aa5
4
+ data.tar.gz: 0afacf44c3eaf6ff404bcb4e171fc74ecc833d8b97110fac1967ce650045d949
5
5
  SHA512:
6
- metadata.gz: f79050ea578166386b43af65ed4efe7249e92aba4d3c87eced62d5e8859a65634c2e852fd18a304fccfd8d904a4a7a40d7c4a092ab030b89fe9c7cd0c684cb2f
7
- data.tar.gz: 3ae087e54109610caa2ce6d065d8658587b751612bf7ddc26e0a7b00b4f69a4ce5db72b1a85073979ca2f47d9ae951d6ce57e4e4c4a453e5eccb207961fb8d91
6
+ metadata.gz: 1dd6e5433e7d018fd9fb30a45f7fe4af6bcaf899ef2323ec1175bbe4d7383361f4abdf8eed6cff746a5964283bc2f269c43d2e3f0dac301b0b467c53a13c8531
7
+ data.tar.gz: db2e7fe5d1f4f8d013d444f164cd727f6c49d5a95d276899545d5a26f144233a0eae3c708dbebff4da44906dbd6f7a108a9d42f4493b79f32ce03a965fb8ad5c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.0.11] - 2025-02-19
2
+
3
+ - Cache the list of models in ListModels
4
+ - Automatically construct the list of valid model names for model_enum at startup
5
+
6
+ ## [0.0.10] - 2025-02-18
7
+
8
+ - Add a ModelEnum
9
+
1
10
  ## [0.0.8] - 2025-02-17
2
11
 
3
12
  - Add support for some newly added fields
@@ -1,4 +1,5 @@
1
- # TODO: consider moving this to src/ and deleting lib/
2
1
  require "foobara/all"
3
2
 
3
+ require_relative "../../src/foobara/ai/open_ai_api"
4
+
4
5
  Foobara::Util.require_directory "#{__dir__}/../../src"
@@ -8,7 +8,7 @@ module Foobara
8
8
  http_method :post
9
9
 
10
10
  add_inputs do
11
- model :string, default: "gpt-3.5-turbo", one_of: %w[gpt-3.5-turbo gpt-4]
11
+ model :model, default: Types::ModelEnum::GPT_3_5_TURBO
12
12
  messages :array do
13
13
  role :string, one_of: %w[system user assistant]
14
14
  content :string
@@ -1,12 +1,16 @@
1
+ require_relative "base_command"
2
+ require_relative "types/model"
3
+ require "foobara/cached_command"
4
+
1
5
  module Foobara
2
6
  module Ai
3
7
  module OpenAiApi
4
8
  class ListModels < BaseCommand
5
- path "/models"
9
+ include CachedCommand
6
10
 
7
- inputs do
8
- api_token :string
9
- end
11
+ self.foobara_cache_expiry = 24 * 60 * 60
12
+
13
+ path "/models"
10
14
 
11
15
  result [Types::Model]
12
16
 
@@ -0,0 +1,15 @@
1
+ require_relative "../list_models"
2
+
3
+ module Foobara
4
+ module Ai
5
+ module OpenAiApi
6
+ module Types
7
+ model_list = ListModels.run!.map(&:id).sort
8
+
9
+ ModelEnum = Foobara::Enumerated.make_module(model_list)
10
+
11
+ OpenAiApi.foobara_register_type(:model, :string, one_of: ModelEnum)
12
+ end
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-open-ai-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-17 00:00:00.000000000 Z
10
+ date: 2025-02-19 00:00:00.000000000 Z
11
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: foobara-cached-command
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
12
26
  - !ruby/object:Gem::Dependency
13
27
  name: foobara-http-api-command
14
28
  requirement: !ruby/object:Gem::Requirement
@@ -44,6 +58,7 @@ files:
44
58
  - src/foobara/ai/open_ai_api/types/chat_completion/message.rb
45
59
  - src/foobara/ai/open_ai_api/types/chat_completion/usage.rb
46
60
  - src/foobara/ai/open_ai_api/types/model.rb
61
+ - src/foobara/ai/open_ai_api/types/model_enum.rb
47
62
  homepage: https://github.com/foobara/open-ai-api
48
63
  licenses:
49
64
  - Apache-2.0