llm_specs 0.2.2 → 0.2.4

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: 48e800a2dbfee7149fd20468bcbb8f68b0f5f4d30a1fdf86d03cc067d6b36f53
4
- data.tar.gz: 75ff11e8f37673d7ac209ba081f32c7b8a12bc461844e84b20a4b553ff9ab5d0
3
+ metadata.gz: 3cb2e8ade72b5fe9e057124190234502a235a56a43ed1c3cf1fe0f0311807682
4
+ data.tar.gz: f3369cd6edb1258ad214b78912e88c8f5e43eebe6df91606db49c47b4fe4de7d
5
5
  SHA512:
6
- metadata.gz: ca5b4d11c6d3f7b2c4aff772b4cf0170e2c7063091154c5f48ef1010b6e29e803154b37d09ae21cee49c2da6a89afd8b5a2bce527e75b8a02ad35fb55ed3ed75
7
- data.tar.gz: 72d975c0c18fc754ed7458b4784c1787beca7363948052567fc3310dda4ad314775025126d65bb84e256a9c04c207e10b2793adb9af4511773606e66b0c159fd
6
+ metadata.gz: b3dbbbe7ac817b114f834527c564d737cf15b11d959129a5a835a96416ebea1a9032ca7cd4cbef465ce5a7dc7846b480361d34f332e44c83d8a156cdec4c87ba
7
+ data.tar.gz: b4399e86752127360e59b61c72323343c38c7c7ad7ef342aff8497d9dde46526ad44270d9c9d2d17465f1177b54742f87d9ee4a212f2e8463a00d535647f9a9b
data/README.md CHANGED
@@ -22,6 +22,8 @@ models = LLMSpecs.gemini # provider specific models
22
22
  models = LLMSpecs.anthropic
23
23
  models = LLMSpecs.openai
24
24
  models = LLMSpecs.deepseek
25
+
26
+ providers = LLMSpecs.providers # a list of all providers covered by Parsera API
25
27
  ```
26
28
 
27
29
  ### Find a model by ID
@@ -91,7 +93,7 @@ model.embeddings_output?
91
93
 
92
94
  Pricing methods:
93
95
  ```ruby
94
- model.input_pricing # => returns a hash:
96
+ model.pricing # => returns a hash:
95
97
  # {
96
98
  # text_tokens: {
97
99
  # standard: {
@@ -115,6 +117,7 @@ model.input_pricing # => returns a hash:
115
117
  # }
116
118
 
117
119
  model.pricing.dig(:text_tokens, :standard, :input_per_million)
120
+ # input/output pricing
118
121
  model.input_pricing # 15.0 => $ per 1M input tokens (default to pricing[:text_tokens][:standard][:input_per_million])
119
122
  model.output_pricing # 75.0 => $ per 1M output tokens
120
123
 
@@ -10,23 +10,23 @@ module LLMSpecs
10
10
  return read if valid?
11
11
  yield.tap { write it }
12
12
  end
13
-
13
+
14
14
  def read
15
- File.read(@file)
15
+ File.read(@file) if exist?
16
16
  end
17
17
 
18
18
  def write(data)
19
- File.write(@file, data)
19
+ File.write(@file, data, mode: "wb")
20
20
  end
21
21
 
22
22
  def valid?
23
23
  exist? && fresh?
24
24
  end
25
-
25
+
26
26
  def exist?
27
27
  File.exist?(@file)
28
28
  end
29
-
29
+
30
30
  def fresh?
31
31
  Time.now - File.mtime(@file) < @ttl
32
32
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module LLMSpecs
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.4"
4
4
  end
data/lib/llm_specs.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require "json"
3
3
  require "net/http"
4
+ require_relative "llm_specs/version"
4
5
  require_relative "llm_specs/errors"
5
6
  require_relative "llm_specs/cache"
6
7
  require_relative "llm_specs/catalog"
@@ -21,6 +22,10 @@ module LLMSpecs
21
22
  @models ||= Catalog.new(api_uri: API_URI, cache_path: cache_path).models
22
23
  end
23
24
 
25
+ def providers
26
+ models.map(&:provider).uniq
27
+ end
28
+
24
29
  %i[anthropic deepseek gemini openai].each do |prov|
25
30
  define_method(prov) { models.where(provider: prov.to_s) }
26
31
  end
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.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Power