ruby_llm 1.1.2 → 1.2.0
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 +2 -2
- data/lib/ruby_llm/chat.rb +19 -6
- data/lib/ruby_llm/configuration.rb +2 -1
- data/lib/ruby_llm/models.json +103 -35
- data/lib/ruby_llm/providers/bedrock/models.rb +8 -1
- data/lib/ruby_llm/providers/openai/capabilities.rb +1 -1
- data/lib/ruby_llm/providers/openai.rb +1 -1
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm.rb +2 -2
- data/lib/tasks/models_docs.rake +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f06ce431337dc189e6172b0c98ed897fdba930200f3f118c39c15f4527ec135
|
4
|
+
data.tar.gz: 18f8ff36e7ee18cbee315e66db4b8f04619c98595a5de3b73d215bed248ca0d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f7603cfec24fa6cc59b1186d2d6a90af9e9076eb79124ac5ce09d73000fbcdb931ab90cafe21bf95b39417a52ff000ca9d02ba51c8a78877d1a1f47b70866f
|
7
|
+
data.tar.gz: 8513b6774ef3d745e7bbc8947f856608d13ade163ca658139c2992e923ad08d5ee00b99275cbfe762591182897b73db7bfc879fae8db7b8ce2f3ba1fea5ee235
|
data/README.md
CHANGED
@@ -118,7 +118,7 @@ end
|
|
118
118
|
## Have great conversations
|
119
119
|
|
120
120
|
```ruby
|
121
|
-
# Start a chat with the default model (
|
121
|
+
# Start a chat with the default model (gpt-4.1-nano)
|
122
122
|
chat = RubyLLM.chat
|
123
123
|
|
124
124
|
# Or specify what you want
|
@@ -169,7 +169,7 @@ class ToolCall < ApplicationRecord
|
|
169
169
|
end
|
170
170
|
|
171
171
|
# In a background job
|
172
|
-
chat = Chat.create! model_id: "gpt-
|
172
|
+
chat = Chat.create! model_id: "gpt-4.1-nano"
|
173
173
|
|
174
174
|
# Set personality or behavior with instructions (aka system prompts) - they're persisted too!
|
175
175
|
chat.with_instructions "You are a friendly Ruby expert who loves to help beginners"
|
data/lib/ruby_llm/chat.rb
CHANGED
@@ -8,14 +8,18 @@ module RubyLLM
|
|
8
8
|
# chat = RubyLLM.chat
|
9
9
|
# chat.ask "What's the best way to learn Ruby?"
|
10
10
|
# chat.ask "Can you elaborate on that?"
|
11
|
-
class Chat
|
11
|
+
class Chat # rubocop:disable Metrics/ClassLength
|
12
12
|
include Enumerable
|
13
13
|
|
14
14
|
attr_reader :model, :messages, :tools
|
15
15
|
|
16
|
-
def initialize(model: nil, provider: nil)
|
16
|
+
def initialize(model: nil, provider: nil, assume_model_exists: false) # rubocop:disable Metrics/MethodLength
|
17
|
+
if assume_model_exists && !provider
|
18
|
+
raise ArgumentError, 'Provider must be specified if assume_model_exists is true'
|
19
|
+
end
|
20
|
+
|
17
21
|
model_id = model || RubyLLM.config.default_model
|
18
|
-
with_model(model_id, provider: provider)
|
22
|
+
with_model(model_id, provider: provider, assume_exists: assume_model_exists)
|
19
23
|
@temperature = 0.7
|
20
24
|
@messages = []
|
21
25
|
@tools = {}
|
@@ -54,9 +58,18 @@ module RubyLLM
|
|
54
58
|
self
|
55
59
|
end
|
56
60
|
|
57
|
-
def with_model(model_id, provider: nil)
|
58
|
-
|
59
|
-
|
61
|
+
def with_model(model_id, provider: nil, assume_exists: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
62
|
+
if assume_exists
|
63
|
+
raise ArgumentError, 'Provider must be specified if assume_exists is true' unless provider
|
64
|
+
|
65
|
+
@provider = Provider.providers[provider.to_sym] || raise(Error, "Unknown provider: #{provider.to_sym}")
|
66
|
+
@model = Struct.new(:id, :provider, :supports_functions, :supports_vision).new(model_id, provider, true, true)
|
67
|
+
RubyLLM.logger.warn "Assuming model '#{model_id}' exists for provider '#{provider}'. " \
|
68
|
+
'Capabilities may not be accurately reflected.'
|
69
|
+
else
|
70
|
+
@model = Models.find model_id, provider
|
71
|
+
@provider = Provider.providers[@model.provider.to_sym] || raise(Error, "Unknown provider: #{@model.provider}")
|
72
|
+
end
|
60
73
|
self
|
61
74
|
end
|
62
75
|
|
@@ -12,6 +12,7 @@ module RubyLLM
|
|
12
12
|
class Configuration
|
13
13
|
# Provider-specific configuration
|
14
14
|
attr_accessor :openai_api_key,
|
15
|
+
:openai_api_base,
|
15
16
|
:anthropic_api_key,
|
16
17
|
:gemini_api_key,
|
17
18
|
:deepseek_api_key,
|
@@ -39,7 +40,7 @@ module RubyLLM
|
|
39
40
|
@retry_interval_randomness = 0.5
|
40
41
|
|
41
42
|
# Default models
|
42
|
-
@default_model = 'gpt-
|
43
|
+
@default_model = 'gpt-4.1-nano'
|
43
44
|
@default_embedding_model = 'text-embedding-3-small'
|
44
45
|
@default_image_model = 'dall-e-3'
|
45
46
|
end
|
data/lib/ruby_llm/models.json
CHANGED
@@ -270,36 +270,6 @@
|
|
270
270
|
]
|
271
271
|
}
|
272
272
|
},
|
273
|
-
{
|
274
|
-
"id": "anthropic.claude-3-7-sonnet-20250219-v1:0",
|
275
|
-
"created_at": null,
|
276
|
-
"display_name": "Claude 3.7 Sonnet",
|
277
|
-
"provider": "bedrock",
|
278
|
-
"context_window": 200000,
|
279
|
-
"max_tokens": 4096,
|
280
|
-
"type": "chat",
|
281
|
-
"family": "claude3_sonnet",
|
282
|
-
"supports_vision": true,
|
283
|
-
"supports_functions": true,
|
284
|
-
"supports_json_mode": true,
|
285
|
-
"input_price_per_million": 3.0,
|
286
|
-
"output_price_per_million": 15.0,
|
287
|
-
"metadata": {
|
288
|
-
"provider_name": "Anthropic",
|
289
|
-
"customizations_supported": [],
|
290
|
-
"inference_configurations": [
|
291
|
-
"INFERENCE_PROFILE"
|
292
|
-
],
|
293
|
-
"response_streaming_supported": true,
|
294
|
-
"input_modalities": [
|
295
|
-
"TEXT",
|
296
|
-
"IMAGE"
|
297
|
-
],
|
298
|
-
"output_modalities": [
|
299
|
-
"TEXT"
|
300
|
-
]
|
301
|
-
}
|
302
|
-
},
|
303
273
|
{
|
304
274
|
"id": "anthropic.claude-3-haiku-20240307-v1:0",
|
305
275
|
"created_at": null,
|
@@ -1918,7 +1888,8 @@
|
|
1918
1888
|
"output_token_limit": 65536,
|
1919
1889
|
"supported_generation_methods": [
|
1920
1890
|
"generateContent",
|
1921
|
-
"countTokens"
|
1891
|
+
"countTokens",
|
1892
|
+
"createCachedContent"
|
1922
1893
|
]
|
1923
1894
|
}
|
1924
1895
|
},
|
@@ -1943,7 +1914,8 @@
|
|
1943
1914
|
"output_token_limit": 65536,
|
1944
1915
|
"supported_generation_methods": [
|
1945
1916
|
"generateContent",
|
1946
|
-
"countTokens"
|
1917
|
+
"countTokens",
|
1918
|
+
"createCachedContent"
|
1947
1919
|
]
|
1948
1920
|
}
|
1949
1921
|
},
|
@@ -1968,7 +1940,8 @@
|
|
1968
1940
|
"output_token_limit": 65536,
|
1969
1941
|
"supported_generation_methods": [
|
1970
1942
|
"generateContent",
|
1971
|
-
"countTokens"
|
1943
|
+
"countTokens",
|
1944
|
+
"createCachedContent"
|
1972
1945
|
]
|
1973
1946
|
}
|
1974
1947
|
},
|
@@ -1993,7 +1966,8 @@
|
|
1993
1966
|
"output_token_limit": 65536,
|
1994
1967
|
"supported_generation_methods": [
|
1995
1968
|
"generateContent",
|
1996
|
-
"countTokens"
|
1969
|
+
"countTokens",
|
1970
|
+
"createCachedContent"
|
1997
1971
|
]
|
1998
1972
|
}
|
1999
1973
|
},
|
@@ -2068,7 +2042,8 @@
|
|
2068
2042
|
"output_token_limit": 65536,
|
2069
2043
|
"supported_generation_methods": [
|
2070
2044
|
"generateContent",
|
2071
|
-
"countTokens"
|
2045
|
+
"countTokens",
|
2046
|
+
"createCachedContent"
|
2072
2047
|
]
|
2073
2048
|
}
|
2074
2049
|
},
|
@@ -3082,6 +3057,31 @@
|
|
3082
3057
|
]
|
3083
3058
|
}
|
3084
3059
|
},
|
3060
|
+
{
|
3061
|
+
"id": "learnlm-2.0-flash-experimental",
|
3062
|
+
"created_at": null,
|
3063
|
+
"display_name": "LearnLM 2.0 Flash Experimental",
|
3064
|
+
"provider": "gemini",
|
3065
|
+
"context_window": 1048576,
|
3066
|
+
"max_tokens": 32768,
|
3067
|
+
"type": "chat",
|
3068
|
+
"family": "other",
|
3069
|
+
"supports_vision": true,
|
3070
|
+
"supports_functions": true,
|
3071
|
+
"supports_json_mode": true,
|
3072
|
+
"input_price_per_million": 0.075,
|
3073
|
+
"output_price_per_million": 0.3,
|
3074
|
+
"metadata": {
|
3075
|
+
"version": "2.0",
|
3076
|
+
"description": "LearnLM 2.0 Flash Experimental",
|
3077
|
+
"input_token_limit": 1048576,
|
3078
|
+
"output_token_limit": 32768,
|
3079
|
+
"supported_generation_methods": [
|
3080
|
+
"generateContent",
|
3081
|
+
"countTokens"
|
3082
|
+
]
|
3083
|
+
}
|
3084
|
+
},
|
3085
3085
|
{
|
3086
3086
|
"id": "o1",
|
3087
3087
|
"created_at": "2024-12-16T20:03:36+01:00",
|
@@ -3272,6 +3272,44 @@
|
|
3272
3272
|
"owned_by": "system"
|
3273
3273
|
}
|
3274
3274
|
},
|
3275
|
+
{
|
3276
|
+
"id": "o4-mini",
|
3277
|
+
"created_at": "2025-04-09T21:02:31+02:00",
|
3278
|
+
"display_name": "O4 Mini",
|
3279
|
+
"provider": "openai",
|
3280
|
+
"context_window": 4096,
|
3281
|
+
"max_tokens": 16384,
|
3282
|
+
"type": "chat",
|
3283
|
+
"family": "other",
|
3284
|
+
"supports_vision": false,
|
3285
|
+
"supports_functions": false,
|
3286
|
+
"supports_json_mode": false,
|
3287
|
+
"input_price_per_million": 0.5,
|
3288
|
+
"output_price_per_million": 1.5,
|
3289
|
+
"metadata": {
|
3290
|
+
"object": "model",
|
3291
|
+
"owned_by": "system"
|
3292
|
+
}
|
3293
|
+
},
|
3294
|
+
{
|
3295
|
+
"id": "o4-mini-2025-04-16",
|
3296
|
+
"created_at": "2025-04-08T19:31:46+02:00",
|
3297
|
+
"display_name": "O4 Mini 20250416",
|
3298
|
+
"provider": "openai",
|
3299
|
+
"context_window": 4096,
|
3300
|
+
"max_tokens": 16384,
|
3301
|
+
"type": "chat",
|
3302
|
+
"family": "other",
|
3303
|
+
"supports_vision": false,
|
3304
|
+
"supports_functions": false,
|
3305
|
+
"supports_json_mode": false,
|
3306
|
+
"input_price_per_million": 0.5,
|
3307
|
+
"output_price_per_million": 1.5,
|
3308
|
+
"metadata": {
|
3309
|
+
"object": "model",
|
3310
|
+
"owned_by": "system"
|
3311
|
+
}
|
3312
|
+
},
|
3275
3313
|
{
|
3276
3314
|
"id": "omni-moderation-2024-09-26",
|
3277
3315
|
"created_at": "2024-11-27T20:07:46+01:00",
|
@@ -3493,6 +3531,36 @@
|
|
3493
3531
|
"owned_by": "system"
|
3494
3532
|
}
|
3495
3533
|
},
|
3534
|
+
{
|
3535
|
+
"id": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
|
3536
|
+
"created_at": null,
|
3537
|
+
"display_name": "Claude 3.7 Sonnet",
|
3538
|
+
"provider": "bedrock",
|
3539
|
+
"context_window": 200000,
|
3540
|
+
"max_tokens": 4096,
|
3541
|
+
"type": "chat",
|
3542
|
+
"family": "claude3_sonnet",
|
3543
|
+
"supports_vision": true,
|
3544
|
+
"supports_functions": true,
|
3545
|
+
"supports_json_mode": true,
|
3546
|
+
"input_price_per_million": 3.0,
|
3547
|
+
"output_price_per_million": 15.0,
|
3548
|
+
"metadata": {
|
3549
|
+
"provider_name": "Anthropic",
|
3550
|
+
"customizations_supported": [],
|
3551
|
+
"inference_configurations": [
|
3552
|
+
"INFERENCE_PROFILE"
|
3553
|
+
],
|
3554
|
+
"response_streaming_supported": true,
|
3555
|
+
"input_modalities": [
|
3556
|
+
"TEXT",
|
3557
|
+
"IMAGE"
|
3558
|
+
],
|
3559
|
+
"output_modalities": [
|
3560
|
+
"TEXT"
|
3561
|
+
]
|
3562
|
+
}
|
3563
|
+
},
|
3496
3564
|
{
|
3497
3565
|
"id": "veo-2.0-generate-001",
|
3498
3566
|
"created_at": null,
|
@@ -42,13 +42,20 @@ module RubyLLM
|
|
42
42
|
|
43
43
|
def base_model_attributes(model_id, model, slug)
|
44
44
|
{
|
45
|
-
id: model_id,
|
45
|
+
id: model_id_with_prefix(model_id, model),
|
46
46
|
created_at: nil,
|
47
47
|
display_name: model['modelName'] || capabilities.format_display_name(model_id),
|
48
48
|
provider: slug
|
49
49
|
}
|
50
50
|
end
|
51
51
|
|
52
|
+
def model_id_with_prefix(model_id, model)
|
53
|
+
return model_id unless model['inferenceTypesSupported']&.include?('INFERENCE_PROFILE')
|
54
|
+
return model_id if model['inferenceTypesSupported']&.include?('ON_DEMAND')
|
55
|
+
|
56
|
+
"us.#{model_id}"
|
57
|
+
end
|
58
|
+
|
52
59
|
def capability_attributes(model_id, capabilities)
|
53
60
|
{
|
54
61
|
context_window: capabilities.context_window_for(model_id),
|
@@ -215,7 +215,7 @@ module RubyLLM
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def normalize_temperature(temperature, model_id)
|
218
|
-
if model_id.match?(/^o
|
218
|
+
if model_id.match?(/^o\d/)
|
219
219
|
RubyLLM.logger.debug "Model #{model_id} requires temperature=1.0, ignoring provided value"
|
220
220
|
1.0
|
221
221
|
else
|
data/lib/ruby_llm/version.rb
CHANGED
data/lib/ruby_llm.rb
CHANGED
@@ -30,8 +30,8 @@ module RubyLLM
|
|
30
30
|
class Error < StandardError; end
|
31
31
|
|
32
32
|
class << self
|
33
|
-
def chat(model: nil, provider: nil)
|
34
|
-
Chat.new(model
|
33
|
+
def chat(model: nil, provider: nil, assume_model_exists: false)
|
34
|
+
Chat.new(model:, provider:, assume_model_exists:)
|
35
35
|
end
|
36
36
|
|
37
37
|
def embed(...)
|
data/lib/tasks/models_docs.rake
CHANGED
@@ -86,10 +86,18 @@ namespace :models do # rubocop:disable Metrics/BlockLength
|
|
86
86
|
---
|
87
87
|
|
88
88
|
# Available Models
|
89
|
+
{: .no_toc }
|
89
90
|
|
90
91
|
This guide lists all models available in RubyLLM, automatically generated from the current model registry.
|
92
|
+
{: .fs-6 .fw-300 }
|
91
93
|
|
92
|
-
|
94
|
+
## Table of contents
|
95
|
+
{: .no_toc .text-delta }
|
96
|
+
|
97
|
+
1. TOC
|
98
|
+
{:toc}
|
99
|
+
|
100
|
+
---
|
93
101
|
|
94
102
|
## Contributing
|
95
103
|
|
@@ -115,6 +123,10 @@ namespace :models do # rubocop:disable Metrics/BlockLength
|
|
115
123
|
For more information about working with models, see the [Working with Models](/guides/models) guide.
|
116
124
|
|
117
125
|
## Models by Type
|
126
|
+
{: .d-inline-block }
|
127
|
+
|
128
|
+
Last updated: #{Time.now.utc.strftime('%Y-%m-%d')}
|
129
|
+
{: .label .label-green }
|
118
130
|
|
119
131
|
### Chat Models (#{RubyLLM.models.chat_models.count})
|
120
132
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_llm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carmine Paolino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|