llm_specs 0.2.0 → 0.2.1

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: 81de39be8dfae6778725b265ee16a65cdfbbc5f10becd03fb1537c895cb7f8d4
4
- data.tar.gz: 3c53b4ee94aaadd71070f89d9c76ddcf7f5a662e1cce2bc62b2626d63e81383e
3
+ metadata.gz: 871a4897a574a252d630c5cf9732ba40bb1110aaa8b8f5acc4d0e1776124f4c2
4
+ data.tar.gz: e52ffa700f2aa1d0cf04a4a4692708e396331ad62e24e26ecb636681ca962834
5
5
  SHA512:
6
- metadata.gz: fc192a767f25c7563c6eb6c3ca32b66d08fc905ae6b4a856c597e3b2074ecf517a417ab46ccd3a59da215a98a1e827d3e93cb9b5b9717ac3f2a7359fe0fde23d
7
- data.tar.gz: 7e7bebb57d8f2875f604c519bac4685f78cf9d0227107bcebabc32e9d1fd4b6efa2febb62d04484ed1c1ee47c2cd4277821fabae60d7d9bab0284bd62747675d
6
+ metadata.gz: efb7f63e343f54e3537e87157ecdbc665681bbc413113480699fe2a9595d4e08257c41f198a679690541f0bc1c01d91b06f39c7c208296dd4ebb12ecd70d6d6a
7
+ data.tar.gz: 8d54eb1c1a54a86c534f68f549d71b3464cf1ba23f363054bcddd553723e278a70698d5fac40cea24a10410ab8971b8786bf949097885edb951056c167bfdcaf
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # LLMSpecs
2
2
 
3
- LLMSpecs is a lightweight Ruby interface for fetching and caching
3
+ LLMSpecs is a lightweight Ruby interface for fetching
4
4
  large language model (LLM) specifications from the [Parsera API](https://llmspecs.parsera.org).
5
5
  It provides a simple, efficient way to access model metadata with built-in caching and query support.
6
6
 
@@ -63,7 +63,7 @@ Each model is represented by an instance of `LLMSpecs::Model`, a value object th
63
63
  - `citations?`
64
64
  - `batch?`
65
65
 
66
- - Pricing breakdowns via `input_pricing` and `output_pricing`
66
+ - Pricing breakdowns via `pricing`, `input_pricing` and `output_pricing`
67
67
 
68
68
  You can easily check capabilities:
69
69
  ```ruby
@@ -91,11 +91,35 @@ model.embeddings_output?
91
91
 
92
92
  Pricing methods:
93
93
  ```ruby
94
- model.input_pricing # 1.1 => $ per 1M input tokens (default :text_tokens)
95
- model.output_pricing
94
+ model.input_pricing # => returns a hash:
95
+ # {
96
+ # text_tokens: {
97
+ # standard: {
98
+ # input_per_million: 15.0,
99
+ # cached_input_per_million: 18.75,
100
+ # output_per_million: 75.0
101
+ # },
102
+ # batch: {
103
+ # input_per_million: nil,
104
+ # output_per_million: nil
105
+ # }
106
+ # },
107
+ # embeddings: {
108
+ # standard: {
109
+ # input_per_million: nil
110
+ # },
111
+ # batch: {
112
+ # input_per_million: nil
113
+ # }
114
+ # }
115
+ # }
116
+
117
+ model.pricing.dig(:text_tokens, :standard, :input_per_million)
118
+ model.input_pricing # 15.0 => $ per 1M input tokens (default to pricing[:text_tokens][:standard][:input_per_million])
119
+ model.output_pricing # 75.0 => $ per 1M output tokens
96
120
 
97
121
  model.input_pricing(:text_tokens, :batch)
98
- model.output_pricing(:embeddings)
122
+ model.input_pricing(:embeddings)
99
123
  ```
100
124
 
101
125
  ## Cache configuration
@@ -5,22 +5,22 @@ module LLMSpecs
5
5
  @file = file
6
6
  @ttl = ttl
7
7
  end
8
-
8
+
9
9
  def fetch
10
10
  return read if valid?
11
11
  yield.tap { write it }
12
12
  end
13
-
13
+
14
14
  def valid?
15
15
  File.exist?(@file) && (Time.now - File.mtime(@file) < @ttl)
16
16
  end
17
-
17
+
18
18
  def read
19
- JSON.parse(File.read(@file), symbolize_names: true)
19
+ File.read(@file)
20
20
  end
21
21
 
22
22
  def write(data)
23
- File.write(@file, JSON.pretty_generate(data)) if data
23
+ File.write(@file, data) if data
24
24
  end
25
25
  end
26
26
  end
@@ -13,13 +13,11 @@ module LLMSpecs
13
13
  private
14
14
 
15
15
  def fetch
16
- @cache.fetch do
17
- parse Net::HTTP.get_response(@uri).tap(&:value) # raises Net::HTTPError if not 2xx
18
- end
19
- end
20
-
21
- def parse(response)
22
- JSON.parse(response.body, symbolize_names: true)
16
+ @cache.fetch {
17
+ Net::HTTP.get_response(@uri).tap(&:value).body # .value raises Net::HTTPError if not 2xx
18
+ }.then {
19
+ JSON.parse it, symbolize_names: true
20
+ }
23
21
  end
24
22
  end
25
23
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module LLMSpecs
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Power
@@ -23,9 +23,9 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '1.0'
26
- description: LLMSpecs is a lightweight Ruby interface for fetching and caching large
27
- language model (LLM) specifications from the Parsera API. It provides a simple,
28
- efficient way to access model metadata with built-in caching and query support.
26
+ description: LLMSpecs is a lightweight Ruby interface for fetching large language
27
+ model (LLM) specifications from the Parsera API. It provides a simple, efficient
28
+ way to access model metadata with built-in caching and query support.
29
29
  email:
30
30
  - kevin.melchert@gmail.com
31
31
  executables: []
@@ -56,14 +56,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 3.2.0
59
+ version: 3.4.0
60
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.6.7
66
+ rubygems_version: 3.6.9
67
67
  specification_version: 4
68
68
  summary: Ruby interface for fetching LLM specifications from the Parsera API
69
69
  test_files: []