llm_specs 0.1.3 → 0.1.5

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: e55746ce8150b1e3fc1554277363ad1b03828eee4a13b3199d461dc811547e64
4
- data.tar.gz: 320e3b24f5b6373f2e76d98be22d35d8589d727cd48914f7f26c0f419aece373
3
+ metadata.gz: 79037b669b30677efe9d924a7b8083f426f943f54d66ea975de9e3b9757bc85f
4
+ data.tar.gz: d778a3d458ef032b79cf451a6c1ccfd28ba8aac22472613c7535153bed8f4498
5
5
  SHA512:
6
- metadata.gz: d3ccbf4b868ebca48dcdf748a48a37e14cea5b0fabd7170ec26cb76f602eb182acff5225b3bc36f246ba0b15db5db31f8dae7fe771e19c62788990355cffc267
7
- data.tar.gz: 01047dcd8b33b838da2bdeb67781416b58a5564031848aa02a4f78a165cbfce6e2ea929a5eb9deb2850a8e38412a58ceadc4c0f5705e44f803e2cdb37b7e7929
6
+ metadata.gz: ef501f8bdc9550691ce68b124d047115bb66c3c14b0ee73a4bd49405d05be00ed03d021f9afb25f51c26a11378c2220be1dc57fd16d8ce423a19e396571b7a50
7
+ data.tar.gz: 791ea85d4793569859f2389fbbfd0ecf847a365f2e1004805fff5410b60cda2234fa2588fbf7fc54a17e4708dbd642aa1dfc5c36b9bacd636d777573745bd165
data/README.md CHANGED
@@ -66,27 +66,34 @@ model.supports?(:function_calling, :batch) # => true/false
66
66
 
67
67
  or input or output modalities:
68
68
  ```ruby
69
- models.supports_input?(:audio) # => true/false
70
- models.supports_input?(:audio, :text) # multiple argument
71
- models.audio_input? # shortcut
72
- models.image_input?
73
- models.text_input?
74
-
75
- models.supports_output?(:audio) # => true/false
76
- models.supports_output?(:audio, :embeddings) # multiple argument
77
- models.audio_output? # shortcut
78
- models.image_output?
79
- models.text_output?
80
- models.embeddings_output?
69
+ model.supports_input?(:audio) # => true/false
70
+ model.supports_input?(:audio, :text) # multiple argument
71
+ model.audio_input? # shortcut
72
+ model.image_input?
73
+ model.text_input?
74
+
75
+ model.supports_output?(:audio) # => true/false
76
+ model.supports_output?(:audio, :embeddings) # multiple argument
77
+ model.audio_output? # shortcut
78
+ model.image_output?
79
+ model.text_output?
80
+ model.embeddings_output?
81
81
  ```
82
82
 
83
83
  Pricing methods:
84
84
  ```ruby
85
- model.input_pricing # => $ per 1M input tokens (default :text_tokens)
85
+ model.input_pricing # 1.1 => $ per 1M input tokens (default :text_tokens)
86
+ model.output_pricing
87
+
86
88
  model.input_pricing(:text_tokens, :batch)
87
89
  model.output_pricing(:embeddings)
88
90
  ```
89
91
 
92
+ ## Cache configuration
93
+
94
+ ```ruby
95
+ LLMSpecs.cache_path = Rails.root.join("tmp", "cache", "llm-specs-cache.json")
96
+ ```
90
97
 
91
98
  ## License
92
99
 
@@ -8,9 +8,7 @@ module LLMSpecs
8
8
 
9
9
  def fetch
10
10
  return read if valid?
11
- data = yield
12
- write(data)
13
- data
11
+ yield.tap { write(it) }
14
12
  end
15
13
 
16
14
  def valid?
@@ -14,10 +14,14 @@ module LLMSpecs
14
14
 
15
15
  def fetch
16
16
  @cache.fetch do
17
- response = Net::HTTP.get_response(@uri)
18
- raise FetchError.new(response) unless response.is_a? Net::HTTPSuccess
19
- JSON.parse(response.body, symbolize_names: true)
17
+ parse Net::HTTP.get_response(@uri).tap(&:value) # raises Net::HTTPError if not 2xx
20
18
  end
21
19
  end
20
+
21
+ def parse(response)
22
+ JSON.parse(response.body, symbolize_names: true)
23
+ end
22
24
  end
23
25
  end
26
+
27
+
@@ -5,12 +5,4 @@ module LLMSpecs
5
5
  super("Couldn't find model with id='#{id}'")
6
6
  end
7
7
  end
8
-
9
- class FetchError < StandardError
10
- attr_reader :response
11
- def initialize(response)
12
- @response = response
13
- super("HTTP fetch failed (status: #{response.status})")
14
- end
15
- end
16
8
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module LLMSpecs
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.5"
4
4
  end
data/lib/llm_specs.rb CHANGED
@@ -15,7 +15,7 @@ module LLMSpecs
15
15
  attr_writer :cache_path
16
16
 
17
17
  def cache_path
18
- @cache_path || "models.json"
18
+ @cache_path || "llm-specs.json"
19
19
  end
20
20
 
21
21
  def models
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_specs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Power
@@ -43,7 +43,6 @@ files:
43
43
  - lib/llm_specs/errors.rb
44
44
  - lib/llm_specs/model.rb
45
45
  - lib/llm_specs/version.rb
46
- - models.json
47
46
  - sig/llm_specs.rbs
48
47
  homepage: https://github.com/max-power/llm_specs
49
48
  licenses: