foobara-open-ai-api 0.0.10 → 0.0.12

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: c561a0e79f029a99ffad41fe5c090ddfab2c7e008c7fd0f16b6d21e4d7901085
4
- data.tar.gz: 284fdd95baef9a2bdbd33fd89aeed1dc1644017a93d36e5045ce17cb58c471f6
3
+ metadata.gz: b3c5966b6692ffdef84569de5e5087aade3acb26a9d1d9883fff6a0e090c26a8
4
+ data.tar.gz: bd73776101d5e3fa6d1e8f731892161c88ef8f58b3938d2750cd90430da097bf
5
5
  SHA512:
6
- metadata.gz: 1e7bd6525404df690f81f902e01bc7e611e23ff5ba71b5d61df07a3743239effb8ae7a96438a52463ef89bee7e3afa6c1941846d66574342b039e996c2e5ea78
7
- data.tar.gz: 4a13093a70ab33d82a6e2854c622fc2ebae81e447f17c0532251ef84ad5dcfda1ef1e6997e3e5ebd21d14a940749fcbc0b3365b4eb19d74d9145530b64e013ca
6
+ metadata.gz: 713b5bdc80f81c35da510acc44aff511de9e9eff0100fddc808d49a4c93e64fea826d604d610a9ced37682c10e957af76f8dd06fd2ef4a0a3b0899d0110e60d0
7
+ data.tar.gz: 4a3828d31cea93a4b8163a62182bf3bb2521acf23ba2679c21274b73fa31eab86bd57998aceae94bf0149349648a4eee0db882ecc95f961f15040390d63fd93f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
- ## [0.0.9] - 2025-02-18
1
+ ## [0.0.12] - 2025-03-01
2
+
3
+ - Rename :model to :model_enum to avoid collision with Model in filesystems that are case-insensitive
4
+
5
+ ## [0.0.11] - 2025-02-19
6
+
7
+ - Cache the list of models in ListModels
8
+ - Automatically construct the list of valid model names for model_enum at startup
9
+
10
+ ## [0.0.10] - 2025-02-18
2
11
 
3
12
  - Add a ModelEnum
4
13
 
@@ -8,7 +8,7 @@ module Foobara
8
8
  http_method :post
9
9
 
10
10
  add_inputs do
11
- model :model, default: Types::ModelEnum::GPT_3_5_TURBO
11
+ model :model_enum, 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
 
@@ -1,72 +1,14 @@
1
+ require_relative "../list_models"
2
+
1
3
  module Foobara
2
4
  module Ai
3
5
  module OpenAiApi
4
6
  module Types
5
- # Can grab an updated list by running something like:
6
- #
7
- # irb(main):001> require "foobara/open_ai_api"
8
- # irb(main):002> Foobara::Ai::OpenAiApi.api_token = File.read("tokens/open_ai_token.txt") and nil
9
- # irb(main):003> Foobara::Ai::OpenAiApi::ListModels.run!.map(&:id).sort
10
- # =>
11
- # ["babbage-002",
12
- # "chatgpt-4o-latest",
13
- # "dall-e-2",
14
- # "dall-e-3",
15
- # "davinci-002",
16
- # "gpt-3.5-turbo",
17
- # ...
18
- ModelEnum = Foobara::Enumerated.make_module(
19
- "babbage-002",
20
- "chatgpt-4o-latest",
21
- "dall-e-2",
22
- "dall-e-3",
23
- "davinci-002",
24
- "gpt-3.5-turbo",
25
- "gpt-3.5-turbo-0125",
26
- "gpt-3.5-turbo-1106",
27
- "gpt-3.5-turbo-16k",
28
- "gpt-3.5-turbo-instruct",
29
- "gpt-3.5-turbo-instruct-0914",
30
- "gpt-4",
31
- "gpt-4-0125-preview",
32
- "gpt-4-0613",
33
- "gpt-4-1106-preview",
34
- "gpt-4-turbo",
35
- "gpt-4-turbo-2024-04-09",
36
- "gpt-4-turbo-preview",
37
- "gpt-4o",
38
- "gpt-4o-2024-05-13",
39
- "gpt-4o-2024-08-06",
40
- "gpt-4o-2024-11-20",
41
- "gpt-4o-audio-preview",
42
- "gpt-4o-audio-preview-2024-10-01",
43
- "gpt-4o-audio-preview-2024-12-17",
44
- "gpt-4o-mini",
45
- "gpt-4o-mini-2024-07-18",
46
- "gpt-4o-mini-audio-preview",
47
- "gpt-4o-mini-audio-preview-2024-12-17",
48
- "gpt-4o-mini-realtime-preview",
49
- "gpt-4o-mini-realtime-preview-2024-12-17",
50
- "gpt-4o-realtime-preview",
51
- "gpt-4o-realtime-preview-2024-10-01",
52
- "gpt-4o-realtime-preview-2024-12-17",
53
- "o1-mini",
54
- "o1-mini-2024-09-12",
55
- "o1-preview",
56
- "o1-preview-2024-09-12",
57
- "omni-moderation-2024-09-26",
58
- "omni-moderation-latest",
59
- "text-embedding-3-large",
60
- "text-embedding-3-small",
61
- "text-embedding-ada-002",
62
- "tts-1",
63
- "tts-1-1106",
64
- "tts-1-hd",
65
- "tts-1-hd-1106",
66
- "whisper-1"
67
- )
7
+ model_list = ListModels.run!.map(&:id).sort
8
+
9
+ ModelEnum = Foobara::Enumerated.make_module(model_list)
68
10
 
69
- OpenAiApi.foobara_register_type(:model, :string, one_of: ModelEnum)
11
+ OpenAiApi.foobara_register_type(:model_enum, :string, one_of: ModelEnum)
70
12
  end
71
13
  end
72
14
  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.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-18 00:00:00.000000000 Z
10
+ date: 2025-03-01 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