Skip to content

Commit 7edeb2a

Browse files
committed
Bump version to 0.1.0.pre35; refactor model response parsing and capabilities methods for providers
1 parent 211f7de commit 7edeb2a

File tree

14 files changed

+183
-36
lines changed

14 files changed

+183
-36
lines changed

lib/ruby_llm/models.json

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@
155155
"output_price_per_million": 15.0,
156156
"metadata": {}
157157
},
158+
{
159+
"id": "claude-3-7-sonnet-20250219",
160+
"created_at": "2025-02-19T00:00:00Z",
161+
"display_name": "Claude 3.7 Sonnet",
162+
"provider": "anthropic",
163+
"context_window": 200000,
164+
"max_tokens": 4096,
165+
"type": "chat",
166+
"family": "claude2",
167+
"supports_vision": true,
168+
"supports_functions": true,
169+
"supports_json_mode": true,
170+
"input_price_per_million": 3.0,
171+
"output_price_per_million": 15.0,
172+
"metadata": {}
173+
},
158174
{
159175
"id": "claude-3-haiku-20240307",
160176
"created_at": "2024-03-07T00:00:00Z",
@@ -830,6 +846,44 @@
830846
"owned_by": "google"
831847
}
832848
},
849+
{
850+
"id": "gemini-2.0-flash-lite",
851+
"created_at": null,
852+
"display_name": "Gemini 2.0 Flash Lite",
853+
"provider": "gemini",
854+
"context_window": 1048576,
855+
"max_tokens": 8192,
856+
"type": "chat",
857+
"family": "gemini20_flash_lite",
858+
"supports_vision": true,
859+
"supports_functions": false,
860+
"supports_json_mode": true,
861+
"input_price_per_million": 0.075,
862+
"output_price_per_million": 0.3,
863+
"metadata": {
864+
"object": "model",
865+
"owned_by": "google"
866+
}
867+
},
868+
{
869+
"id": "gemini-2.0-flash-lite-001",
870+
"created_at": null,
871+
"display_name": "Gemini 2.0 Flash Lite 001",
872+
"provider": "gemini",
873+
"context_window": 1048576,
874+
"max_tokens": 8192,
875+
"type": "chat",
876+
"family": "gemini20_flash_lite",
877+
"supports_vision": true,
878+
"supports_functions": false,
879+
"supports_json_mode": true,
880+
"input_price_per_million": 0.075,
881+
"output_price_per_million": 0.3,
882+
"metadata": {
883+
"object": "model",
884+
"owned_by": "google"
885+
}
886+
},
833887
{
834888
"id": "gemini-2.0-flash-lite-preview",
835889
"created_at": null,
@@ -868,6 +922,44 @@
868922
"owned_by": "google"
869923
}
870924
},
925+
{
926+
"id": "gemini-2.0-flash-mmgen-rev17",
927+
"created_at": null,
928+
"display_name": "Gemini 2.0 Flash Mmgen Rev17",
929+
"provider": "gemini",
930+
"context_window": 1048576,
931+
"max_tokens": 8192,
932+
"type": "chat",
933+
"family": "gemini20_flash",
934+
"supports_vision": true,
935+
"supports_functions": true,
936+
"supports_json_mode": true,
937+
"input_price_per_million": 0.1,
938+
"output_price_per_million": 0.4,
939+
"metadata": {
940+
"object": "model",
941+
"owned_by": "google"
942+
}
943+
},
944+
{
945+
"id": "gemini-2.0-flash-thinking-001",
946+
"created_at": null,
947+
"display_name": "Gemini 2.0 Flash Thinking 001",
948+
"provider": "gemini",
949+
"context_window": 1048576,
950+
"max_tokens": 8192,
951+
"type": "chat",
952+
"family": "gemini20_flash",
953+
"supports_vision": true,
954+
"supports_functions": true,
955+
"supports_json_mode": true,
956+
"input_price_per_million": 0.1,
957+
"output_price_per_million": 0.4,
958+
"metadata": {
959+
"object": "model",
960+
"owned_by": "google"
961+
}
962+
},
871963
{
872964
"id": "gemini-2.0-flash-thinking-exp",
873965
"created_at": null,
@@ -1077,6 +1169,25 @@
10771169
"owned_by": "google"
10781170
}
10791171
},
1172+
{
1173+
"id": "gemma-3-27b-it",
1174+
"created_at": null,
1175+
"display_name": "Gemma 3 27b It",
1176+
"provider": "gemini",
1177+
"context_window": 32768,
1178+
"max_tokens": 4096,
1179+
"type": "chat",
1180+
"family": "other",
1181+
"supports_vision": false,
1182+
"supports_functions": false,
1183+
"supports_json_mode": false,
1184+
"input_price_per_million": 0.075,
1185+
"output_price_per_million": 0.3,
1186+
"metadata": {
1187+
"object": "model",
1188+
"owned_by": "google"
1189+
}
1190+
},
10801191
{
10811192
"id": "gpt-3.5-turbo",
10821193
"created_at": "2023-02-28T19:56:42+01:00",
@@ -2046,6 +2157,25 @@
20462157
"owned_by": "system"
20472158
}
20482159
},
2160+
{
2161+
"id": "veo-2.0-generate-001",
2162+
"created_at": null,
2163+
"display_name": "Veo 2.0 Generate 001",
2164+
"provider": "gemini",
2165+
"context_window": 32768,
2166+
"max_tokens": 4096,
2167+
"type": "chat",
2168+
"family": "other",
2169+
"supports_vision": false,
2170+
"supports_functions": false,
2171+
"supports_json_mode": false,
2172+
"input_price_per_million": 0.075,
2173+
"output_price_per_million": 0.3,
2174+
"metadata": {
2175+
"object": "model",
2176+
"owned_by": "google"
2177+
}
2178+
},
20492179
{
20502180
"id": "whisper-1",
20512181
"created_at": "2023-02-27T22:13:04+01:00",

lib/ruby_llm/models.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ def default_model
5353
end
5454

5555
def refresh!
56-
@all = RubyLLM.providers.flat_map do |provider|
57-
provider.new.list_models
58-
end.sort_by(&:id)
56+
@all = RubyLLM.providers.flat_map(&:list_models).sort_by(&:id)
5957
end
6058
end
6159
end

lib/ruby_llm/provider.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def list_models
2323
req.headers.merge! headers
2424
end
2525

26-
parse_list_models_response response
26+
parse_list_models_response response, slug, capabilities
2727
end
2828

2929
def embed(text, model:)
@@ -150,15 +150,6 @@ def parse_error(response)
150150
body.is_a?(Hash) ? body.dig('error', 'message') : body
151151
end
152152

153-
def capabilities
154-
provider_name = self.class.name.split('::').last
155-
provider_name::Capabilities
156-
end
157-
158-
def slug
159-
self.class.name.split('::').last.downcase
160-
end
161-
162153
class << self
163154
def extended(base)
164155
base.extend(Methods)

lib/ruby_llm/providers/anthropic.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def headers
2424
'anthropic-version' => '2023-06-01'
2525
}
2626
end
27+
28+
def capabilities
29+
Anthropic::Capabilities
30+
end
31+
32+
def slug
33+
'anthropic'
34+
end
2735
end
2836
end
2937
end

lib/ruby_llm/providers/anthropic/models.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def models_url
1111
'/v1/models'
1212
end
1313

14-
def parse_list_models_response(response) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
14+
def parse_list_models_response(response, slug, capabilities) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
1515
(response.body['data'] || []).map do |model|
1616
ModelInfo.new(
1717
id: model['id'],

lib/ruby_llm/providers/deepseek.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ def headers
1717
'Authorization' => "Bearer #{RubyLLM.config.deepseek_api_key}"
1818
}
1919
end
20+
21+
def capabilities
22+
DeepSeek::Capabilities
23+
end
24+
25+
def slug
26+
'deepseek'
27+
end
2028
end
2129
end
2230
end

lib/ruby_llm/providers/gemini.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def headers
1818
'Authorization' => "Bearer #{RubyLLM.config.gemini_api_key}"
1919
}
2020
end
21+
22+
def capabilities
23+
Gemini::Capabilities
24+
end
25+
26+
def slug
27+
'gemini'
28+
end
2129
end
2230
end
2331
end

lib/ruby_llm/providers/gemini/capabilities.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def pricing_family(model_id) # rubocop:disable Metrics/CyclomaticComplexity
126126
end
127127
end
128128

129-
private
130-
131129
def long_context_model?(model_id)
132130
model_id.match?(/gemini-1\.5-(?:pro|flash)/)
133131
end

lib/ruby_llm/providers/gemini/models.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ module Gemini
77
module Models
88
module_function
99

10-
def parse_list_models_response(response)
10+
def parse_list_models_response(response, slug, capabilities)
1111
response.body['data']&.each do |model|
1212
model['id'] = model['id'].delete_prefix('models/')
1313
end
1414

15-
OpenAI::Models.parse_list_models_response(response)
15+
OpenAI::Models.parse_list_models_response(response, slug, capabilities)
1616
end
1717
end
1818
end

lib/ruby_llm/providers/openai.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ def headers
3737
'Authorization' => "Bearer #{RubyLLM.config.openai_api_key}"
3838
}
3939
end
40+
41+
def capabilities
42+
OpenAI::Capabilities
43+
end
44+
45+
def slug
46+
'openai'
47+
end
4048
end
4149
end
4250
end

0 commit comments

Comments
 (0)