llm_specs 0.1.1 → 0.1.3

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: 6920accbfa3bf50fabf644d681a5ceaf498828b72ea538a6e679822e7b7c488c
4
- data.tar.gz: 115f7d7daa49ba5d455161dc196bd65931c089c452fd385c4143f4063c147e21
3
+ metadata.gz: e55746ce8150b1e3fc1554277363ad1b03828eee4a13b3199d461dc811547e64
4
+ data.tar.gz: 320e3b24f5b6373f2e76d98be22d35d8589d727cd48914f7f26c0f419aece373
5
5
  SHA512:
6
- metadata.gz: 720806a631c89c2690c23ec4744c6ecfef396c1926a0c69787c2d2a3c946a9144f9f456bd9db00f715ec037c506d56fe9e781f6c49944e0ca8af3cfcbedd839e
7
- data.tar.gz: 2a99e8ac6b1baf77a608e30f660da6675f27979c82784f2fc59949649199be4235e2e027ac7b898f509aa9c2254296e40619e7d363404a46db1c3b174fb9d59a
6
+ metadata.gz: d3ccbf4b868ebca48dcdf748a48a37e14cea5b0fabd7170ec26cb76f602eb182acff5225b3bc36f246ba0b15db5db31f8dae7fe771e19c62788990355cffc267
7
+ data.tar.gz: 01047dcd8b33b838da2bdeb67781416b58a5564031848aa02a4f78a165cbfce6e2ea929a5eb9deb2850a8e38412a58ceadc4c0f5705e44f803e2cdb37b7e7929
data/README.md CHANGED
@@ -11,6 +11,35 @@ It provides a simple, efficient way to access model metadata with built-in cachi
11
11
  - Provides a queryable catalog of models via .models
12
12
  - Supports filtering and lookup by model attributes
13
13
 
14
+
15
+ ## Example Usage
16
+ ```ruby
17
+ require 'llm_specs'
18
+
19
+ models = LLMSpecs.models
20
+ ```
21
+
22
+ ### Find a model by ID
23
+ ```ruby
24
+ model = LLMSpecs.models.find("claude-3-sonnet")
25
+ ```
26
+
27
+ ### Filter models
28
+ ```ruby
29
+ # List all Anthropic models
30
+ anthropic_models = LLMSpecs.models.where(provider: "anthropic")
31
+
32
+ # List all Anthropic models by family "claude-3-7-sonnet"
33
+ claude_models = LLMSpecs.models.where(provider: "anthropic", family: "claude-3-7-sonnet")
34
+
35
+ # List all models that support streaming
36
+ streaming_models = LLMSpecs.models.select(&:streaming?)
37
+
38
+ # List all models that support audio output
39
+ audio_models = LLMSpecs.models.select(&:audio_output?)
40
+
41
+ ```
42
+
14
43
  ## Model Capabilities
15
44
  Each model is represented by an instance of `LLMSpecs::Model`, a value object that encapsulates:
16
45
 
@@ -27,36 +56,37 @@ Each model is represented by an instance of `LLMSpecs::Model`, a value object th
27
56
 
28
57
  - Pricing breakdowns via `input_pricing` and `output_pricing`
29
58
 
30
- You can easily check capabilities or pricing:
59
+ You can easily check capabilities:
31
60
  ```ruby
32
- model.function_calling? # => true/false
33
- model.input_pricing # => $ per 1M input tokens (default)
34
- model.output_pricing(:image_tokens)
61
+ model.supports?(:function_calling) # => true/false
62
+ model.function_calling? # => shortcut for above
63
+ # with multiple arguments
64
+ model.supports?(:function_calling, :batch) # => true/false
35
65
  ```
36
66
 
37
- ## Example Usage
67
+ or input or output modalities:
38
68
  ```ruby
39
- require 'llm_specs'
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?
40
74
 
41
- models = LLMSpecs.models
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?
42
81
  ```
43
82
 
44
- ### Find a model by ID
83
+ Pricing methods:
45
84
  ```ruby
46
- model = LLMSpecs.models.find("claude-3-sonnet")
85
+ model.input_pricing # => $ per 1M input tokens (default :text_tokens)
86
+ model.input_pricing(:text_tokens, :batch)
87
+ model.output_pricing(:embeddings)
47
88
  ```
48
89
 
49
- ### Filter models
50
- ```ruby
51
- anthropic_models = LLMSpecs.models.where(provider: "anthropic")
52
-
53
- claude_models = LLMSpecs.models.where(provider: "anthropic", family: "claude-3-7-sonnet")
54
- ```
55
-
56
- ### List all models that support streaming
57
- ```ruby
58
- streaming_models = LLMSpecs.models.select(&:streaming?)
59
- ```
60
90
 
61
91
  ## License
62
92
 
@@ -1,14 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
  module LLMSpecs
3
3
  class Model < Data.define(:id, :name, :provider, :family, :context_window, :max_output_tokens, :modalities, :capabilities, :pricing)
4
- def supports?(capability)
5
- capabilities.include?(capability.to_s)
4
+ def supports?(*caps)
5
+ caps.all? { capabilities.include?(it.to_s) }
6
+ end
7
+
8
+ def supports_input?(*modes)
9
+ modes.all? { input_modalities.include?(it.to_s) }
10
+ end
11
+
12
+ def supports_output?(*modes)
13
+ modes.all? { output_modalities.include?(it.to_s) }
6
14
  end
7
15
 
8
16
  %i[function_calling structured_output batch reasoning citations streaming].each do |capability|
9
17
  define_method(:"#{capability}?") { supports?(capability) }
10
18
  end
11
19
 
20
+ %i[text image audio].each do |method|
21
+ define_method(:"#{method}_input?") { supports_input?(method) }
22
+ end
23
+
24
+ %i[text image audio embeddings].each do |method|
25
+ define_method(:"#{method}_output?") { supports_output?(method) }
26
+ end
27
+
12
28
  def input_modalities
13
29
  modalities[:input]
14
30
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module LLMSpecs
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.3"
4
4
  end
data/lib/llm_specs.rb CHANGED
@@ -9,10 +9,17 @@ require_relative "llm_specs/collection"
9
9
  require_relative "llm_specs/model"
10
10
 
11
11
  module LLMSpecs
12
- API_URI = "https://api.parsera.org/v1/llm-specs"
13
- CACHE_PATH = "models.json"
12
+ API_URI = "https://api.parsera.org/v1/llm-specs"
14
13
 
15
- def self.models
16
- @models ||= Catalog.new(api_uri: API_URI, cache_path: CACHE_PATH).models
14
+ class << self
15
+ attr_writer :cache_path
16
+
17
+ def cache_path
18
+ @cache_path || "models.json"
19
+ end
20
+
21
+ def models
22
+ @models ||= Catalog.new(api_uri: API_URI, cache_path: cache_path).models
23
+ end
17
24
  end
18
25
  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.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Power