llm_specs 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +50 -20
- data/lib/llm_specs/model.rb +18 -2
- data/lib/llm_specs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fb186c06a052eb3818811b07ff649ce0122313ac7be76036d48ed8810aaf825
|
4
|
+
data.tar.gz: 0ac219ca8e0619e96876bd113c09047a0b43d17f9d92ff555a9c50d3b194d782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb8025aa56c42285c3bb97c325dba24ed5b81a6fafe0c8ded5b739b759df82d4c2d3b830215ba6a2741df0e0e3b5704f02139f4ad98d96172d3ac3fb89665223
|
7
|
+
data.tar.gz: 02542bf9b714b4319b53307c26d36d695094adb7eb8a70fa237a506afe98afe765ab19475e2396d892c4dbbcca8257706108691636a38d2a5ade427a200590a6
|
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
|
59
|
+
You can easily check capabilities:
|
31
60
|
```ruby
|
32
|
-
model.function_calling
|
33
|
-
model.
|
34
|
-
|
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
|
-
|
67
|
+
or input or output modalities:
|
38
68
|
```ruby
|
39
|
-
|
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
|
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
|
-
|
83
|
+
Pricing methods:
|
45
84
|
```ruby
|
46
|
-
model
|
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
|
|
data/lib/llm_specs/model.rb
CHANGED
@@ -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?(
|
5
|
-
capabilities.include?(
|
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
|
data/lib/llm_specs/version.rb
CHANGED