ruby_llm 1.10.0 → 1.12.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 +14 -2
- data/lib/ruby_llm/active_record/acts_as_legacy.rb +41 -7
- data/lib/ruby_llm/active_record/chat_methods.rb +41 -7
- data/lib/ruby_llm/agent.rb +323 -0
- data/lib/ruby_llm/aliases.json +50 -32
- data/lib/ruby_llm/chat.rb +27 -3
- data/lib/ruby_llm/configuration.rb +4 -0
- data/lib/ruby_llm/models.json +19806 -5991
- data/lib/ruby_llm/models.rb +35 -6
- data/lib/ruby_llm/provider.rb +13 -1
- data/lib/ruby_llm/providers/anthropic/media.rb +2 -2
- data/lib/ruby_llm/providers/azure/chat.rb +29 -0
- data/lib/ruby_llm/providers/azure/embeddings.rb +24 -0
- data/lib/ruby_llm/providers/azure/media.rb +45 -0
- data/lib/ruby_llm/providers/azure/models.rb +14 -0
- data/lib/ruby_llm/providers/azure.rb +56 -0
- data/lib/ruby_llm/providers/bedrock/auth.rb +122 -0
- data/lib/ruby_llm/providers/bedrock/chat.rb +297 -56
- data/lib/ruby_llm/providers/bedrock/media.rb +62 -33
- data/lib/ruby_llm/providers/bedrock/models.rb +88 -65
- data/lib/ruby_llm/providers/bedrock/streaming.rb +305 -8
- data/lib/ruby_llm/providers/bedrock.rb +61 -52
- data/lib/ruby_llm/providers/openai/media.rb +1 -1
- data/lib/ruby_llm/providers/xai/chat.rb +15 -0
- data/lib/ruby_llm/providers/xai/models.rb +75 -0
- data/lib/ruby_llm/providers/xai.rb +28 -0
- data/lib/ruby_llm/version.rb +1 -1
- data/lib/ruby_llm.rb +14 -8
- data/lib/tasks/models.rake +10 -4
- data/lib/tasks/vcr.rake +32 -0
- metadata +16 -13
- data/lib/ruby_llm/providers/bedrock/capabilities.rb +0 -167
- data/lib/ruby_llm/providers/bedrock/signing.rb +0 -831
- data/lib/ruby_llm/providers/bedrock/streaming/base.rb +0 -51
- data/lib/ruby_llm/providers/bedrock/streaming/content_extraction.rb +0 -128
- data/lib/ruby_llm/providers/bedrock/streaming/message_processing.rb +0 -67
- data/lib/ruby_llm/providers/bedrock/streaming/payload_processing.rb +0 -85
- data/lib/ruby_llm/providers/bedrock/streaming/prelude_handling.rb +0 -78
data/lib/ruby_llm/aliases.json
CHANGED
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"claude-haiku-4-5": {
|
|
41
41
|
"anthropic": "claude-haiku-4-5-20251001",
|
|
42
42
|
"openrouter": "anthropic/claude-haiku-4.5",
|
|
43
|
-
"bedrock": "anthropic.claude-haiku-4-5-20251001-v1:0"
|
|
43
|
+
"bedrock": "anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
44
|
+
"azure": "claude-haiku-4-5-20251001"
|
|
44
45
|
},
|
|
45
46
|
"claude-opus-4": {
|
|
46
47
|
"anthropic": "claude-opus-4-20250514",
|
|
@@ -53,12 +54,19 @@
|
|
|
53
54
|
"claude-opus-4-1": {
|
|
54
55
|
"anthropic": "claude-opus-4-1-20250805",
|
|
55
56
|
"openrouter": "anthropic/claude-opus-4.1",
|
|
56
|
-
"bedrock": "anthropic.claude-opus-4-1-20250805-v1:0"
|
|
57
|
+
"bedrock": "anthropic.claude-opus-4-1-20250805-v1:0",
|
|
58
|
+
"azure": "claude-opus-4-1-20250805"
|
|
57
59
|
},
|
|
58
60
|
"claude-opus-4-5": {
|
|
59
61
|
"anthropic": "claude-opus-4-5-20251101",
|
|
60
62
|
"openrouter": "anthropic/claude-opus-4.5",
|
|
61
|
-
"bedrock": "anthropic.claude-opus-4-5-20251101-v1:0"
|
|
63
|
+
"bedrock": "anthropic.claude-opus-4-5-20251101-v1:0",
|
|
64
|
+
"azure": "claude-opus-4-5-20251101"
|
|
65
|
+
},
|
|
66
|
+
"claude-opus-4-6": {
|
|
67
|
+
"anthropic": "claude-opus-4-6",
|
|
68
|
+
"openrouter": "anthropic/claude-opus-4.6",
|
|
69
|
+
"bedrock": "anthropic.claude-opus-4-6-v1"
|
|
62
70
|
},
|
|
63
71
|
"claude-sonnet-4": {
|
|
64
72
|
"anthropic": "claude-sonnet-4-20250514",
|
|
@@ -71,7 +79,8 @@
|
|
|
71
79
|
"claude-sonnet-4-5": {
|
|
72
80
|
"anthropic": "claude-sonnet-4-5-20250929",
|
|
73
81
|
"openrouter": "anthropic/claude-sonnet-4.5",
|
|
74
|
-
"bedrock": "anthropic.claude-sonnet-4-5-20250929-v1:0"
|
|
82
|
+
"bedrock": "anthropic.claude-sonnet-4-5-20250929-v1:0",
|
|
83
|
+
"azure": "claude-sonnet-4-5-20250929"
|
|
75
84
|
},
|
|
76
85
|
"deepseek-chat": {
|
|
77
86
|
"deepseek": "deepseek-chat",
|
|
@@ -98,10 +107,6 @@
|
|
|
98
107
|
"openrouter": "google/gemini-2.0-flash-001",
|
|
99
108
|
"vertexai": "gemini-2.0-flash-001"
|
|
100
109
|
},
|
|
101
|
-
"gemini-2.0-flash-exp": {
|
|
102
|
-
"gemini": "gemini-2.0-flash-exp",
|
|
103
|
-
"vertexai": "gemini-2.0-flash-exp"
|
|
104
|
-
},
|
|
105
110
|
"gemini-2.0-flash-lite": {
|
|
106
111
|
"gemini": "gemini-2.0-flash-lite",
|
|
107
112
|
"vertexai": "gemini-2.0-flash-lite"
|
|
@@ -120,10 +125,6 @@
|
|
|
120
125
|
"gemini": "gemini-2.5-flash-image",
|
|
121
126
|
"openrouter": "google/gemini-2.5-flash-image"
|
|
122
127
|
},
|
|
123
|
-
"gemini-2.5-flash-image-preview": {
|
|
124
|
-
"gemini": "gemini-2.5-flash-image-preview",
|
|
125
|
-
"openrouter": "google/gemini-2.5-flash-image-preview"
|
|
126
|
-
},
|
|
127
128
|
"gemini-2.5-flash-lite": {
|
|
128
129
|
"gemini": "gemini-2.5-flash-lite",
|
|
129
130
|
"openrouter": "google/gemini-2.5-flash-lite",
|
|
@@ -226,7 +227,8 @@
|
|
|
226
227
|
},
|
|
227
228
|
"gpt-4": {
|
|
228
229
|
"openai": "gpt-4",
|
|
229
|
-
"openrouter": "openai/gpt-4"
|
|
230
|
+
"openrouter": "openai/gpt-4",
|
|
231
|
+
"azure": "gpt-4"
|
|
230
232
|
},
|
|
231
233
|
"gpt-4-1106-preview": {
|
|
232
234
|
"openai": "gpt-4-1106-preview",
|
|
@@ -242,31 +244,38 @@
|
|
|
242
244
|
},
|
|
243
245
|
"gpt-4.1": {
|
|
244
246
|
"openai": "gpt-4.1",
|
|
245
|
-
"openrouter": "openai/gpt-4.1"
|
|
247
|
+
"openrouter": "openai/gpt-4.1",
|
|
248
|
+
"azure": "gpt-4.1"
|
|
246
249
|
},
|
|
247
250
|
"gpt-4.1-mini": {
|
|
248
251
|
"openai": "gpt-4.1-mini",
|
|
249
|
-
"openrouter": "openai/gpt-4.1-mini"
|
|
252
|
+
"openrouter": "openai/gpt-4.1-mini",
|
|
253
|
+
"azure": "gpt-4.1-mini"
|
|
250
254
|
},
|
|
251
255
|
"gpt-4.1-nano": {
|
|
252
256
|
"openai": "gpt-4.1-nano",
|
|
253
|
-
"openrouter": "openai/gpt-4.1-nano"
|
|
257
|
+
"openrouter": "openai/gpt-4.1-nano",
|
|
258
|
+
"azure": "gpt-4.1-nano"
|
|
254
259
|
},
|
|
255
260
|
"gpt-4o": {
|
|
256
261
|
"openai": "gpt-4o",
|
|
257
|
-
"openrouter": "openai/gpt-4o"
|
|
262
|
+
"openrouter": "openai/gpt-4o",
|
|
263
|
+
"azure": "gpt-4o"
|
|
258
264
|
},
|
|
259
265
|
"gpt-4o-2024-05-13": {
|
|
260
266
|
"openai": "gpt-4o-2024-05-13",
|
|
261
|
-
"openrouter": "openai/gpt-4o-2024-05-13"
|
|
267
|
+
"openrouter": "openai/gpt-4o-2024-05-13",
|
|
268
|
+
"azure": "gpt-4o-2024-05-13"
|
|
262
269
|
},
|
|
263
270
|
"gpt-4o-2024-08-06": {
|
|
264
271
|
"openai": "gpt-4o-2024-08-06",
|
|
265
|
-
"openrouter": "openai/gpt-4o-2024-08-06"
|
|
272
|
+
"openrouter": "openai/gpt-4o-2024-08-06",
|
|
273
|
+
"azure": "gpt-4o-2024-08-06"
|
|
266
274
|
},
|
|
267
275
|
"gpt-4o-2024-11-20": {
|
|
268
276
|
"openai": "gpt-4o-2024-11-20",
|
|
269
|
-
"openrouter": "openai/gpt-4o-2024-11-20"
|
|
277
|
+
"openrouter": "openai/gpt-4o-2024-11-20",
|
|
278
|
+
"azure": "gpt-4o-2024-11-20"
|
|
270
279
|
},
|
|
271
280
|
"gpt-4o-audio-preview": {
|
|
272
281
|
"openai": "gpt-4o-audio-preview",
|
|
@@ -274,11 +283,13 @@
|
|
|
274
283
|
},
|
|
275
284
|
"gpt-4o-mini": {
|
|
276
285
|
"openai": "gpt-4o-mini",
|
|
277
|
-
"openrouter": "openai/gpt-4o-mini"
|
|
286
|
+
"openrouter": "openai/gpt-4o-mini",
|
|
287
|
+
"azure": "gpt-4o-mini"
|
|
278
288
|
},
|
|
279
289
|
"gpt-4o-mini-2024-07-18": {
|
|
280
290
|
"openai": "gpt-4o-mini-2024-07-18",
|
|
281
|
-
"openrouter": "openai/gpt-4o-mini-2024-07-18"
|
|
291
|
+
"openrouter": "openai/gpt-4o-mini-2024-07-18",
|
|
292
|
+
"azure": "gpt-4o-mini-2024-07-18"
|
|
282
293
|
},
|
|
283
294
|
"gpt-4o-mini-search-preview": {
|
|
284
295
|
"openai": "gpt-4o-mini-search-preview",
|
|
@@ -328,21 +339,30 @@
|
|
|
328
339
|
"openai": "gpt-5.2",
|
|
329
340
|
"openrouter": "openai/gpt-5.2"
|
|
330
341
|
},
|
|
331
|
-
"gpt-5.2-
|
|
332
|
-
"openai": "gpt-5.2-
|
|
333
|
-
"openrouter": "openai/gpt-5.2-
|
|
342
|
+
"gpt-5.2-codex": {
|
|
343
|
+
"openai": "gpt-5.2-codex",
|
|
344
|
+
"openrouter": "openai/gpt-5.2-codex"
|
|
334
345
|
},
|
|
335
346
|
"gpt-5.2-pro": {
|
|
336
347
|
"openai": "gpt-5.2-pro",
|
|
337
348
|
"openrouter": "openai/gpt-5.2-pro"
|
|
338
349
|
},
|
|
350
|
+
"gpt-audio": {
|
|
351
|
+
"openai": "gpt-audio",
|
|
352
|
+
"openrouter": "openai/gpt-audio"
|
|
353
|
+
},
|
|
354
|
+
"gpt-audio-mini": {
|
|
355
|
+
"openai": "gpt-audio-mini",
|
|
356
|
+
"openrouter": "openai/gpt-audio-mini"
|
|
357
|
+
},
|
|
339
358
|
"o1": {
|
|
340
359
|
"openai": "o1",
|
|
341
360
|
"openrouter": "openai/o1"
|
|
342
361
|
},
|
|
343
362
|
"o1-pro": {
|
|
344
363
|
"openai": "o1-pro",
|
|
345
|
-
"openrouter": "openai/o1-pro"
|
|
364
|
+
"openrouter": "openai/o1-pro",
|
|
365
|
+
"azure": "o1-pro"
|
|
346
366
|
},
|
|
347
367
|
"o3": {
|
|
348
368
|
"openai": "o3",
|
|
@@ -354,7 +374,8 @@
|
|
|
354
374
|
},
|
|
355
375
|
"o3-mini": {
|
|
356
376
|
"openai": "o3-mini",
|
|
357
|
-
"openrouter": "openai/o3-mini"
|
|
377
|
+
"openrouter": "openai/o3-mini",
|
|
378
|
+
"azure": "o3-mini"
|
|
358
379
|
},
|
|
359
380
|
"o3-pro": {
|
|
360
381
|
"openai": "o3-pro",
|
|
@@ -362,14 +383,11 @@
|
|
|
362
383
|
},
|
|
363
384
|
"o4-mini": {
|
|
364
385
|
"openai": "o4-mini",
|
|
365
|
-
"openrouter": "openai/o4-mini"
|
|
386
|
+
"openrouter": "openai/o4-mini",
|
|
387
|
+
"azure": "o4-mini"
|
|
366
388
|
},
|
|
367
389
|
"o4-mini-deep-research": {
|
|
368
390
|
"openai": "o4-mini-deep-research",
|
|
369
391
|
"openrouter": "openai/o4-mini-deep-research"
|
|
370
|
-
},
|
|
371
|
-
"text-embedding-004": {
|
|
372
|
-
"gemini": "text-embedding-004",
|
|
373
|
-
"vertexai": "text-embedding-004"
|
|
374
392
|
}
|
|
375
393
|
}
|
data/lib/ruby_llm/chat.rb
CHANGED
|
@@ -38,10 +38,15 @@ module RubyLLM
|
|
|
38
38
|
|
|
39
39
|
alias say ask
|
|
40
40
|
|
|
41
|
-
def with_instructions(instructions, replace:
|
|
42
|
-
|
|
41
|
+
def with_instructions(instructions, append: false, replace: nil)
|
|
42
|
+
append ||= (replace == false) unless replace.nil?
|
|
43
|
+
|
|
44
|
+
if append
|
|
45
|
+
append_system_instruction(instructions)
|
|
46
|
+
else
|
|
47
|
+
replace_system_instruction(instructions)
|
|
48
|
+
end
|
|
43
49
|
|
|
44
|
-
add_message role: :system, content: instructions
|
|
45
50
|
self
|
|
46
51
|
end
|
|
47
52
|
|
|
@@ -222,5 +227,24 @@ module RubyLLM
|
|
|
222
227
|
def content_like?(object)
|
|
223
228
|
object.is_a?(Content) || object.is_a?(Content::Raw)
|
|
224
229
|
end
|
|
230
|
+
|
|
231
|
+
def append_system_instruction(instructions)
|
|
232
|
+
system_messages, non_system_messages = @messages.partition { |msg| msg.role == :system }
|
|
233
|
+
system_messages << Message.new(role: :system, content: instructions)
|
|
234
|
+
@messages = system_messages + non_system_messages
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def replace_system_instruction(instructions)
|
|
238
|
+
system_messages, non_system_messages = @messages.partition { |msg| msg.role == :system }
|
|
239
|
+
|
|
240
|
+
if system_messages.empty?
|
|
241
|
+
system_messages = [Message.new(role: :system, content: instructions)]
|
|
242
|
+
else
|
|
243
|
+
system_messages.first.content = instructions
|
|
244
|
+
system_messages = [system_messages.first]
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
@messages = system_messages + non_system_messages
|
|
248
|
+
end
|
|
225
249
|
end
|
|
226
250
|
end
|
|
@@ -8,6 +8,9 @@ module RubyLLM
|
|
|
8
8
|
:openai_organization_id,
|
|
9
9
|
:openai_project_id,
|
|
10
10
|
:openai_use_system_role,
|
|
11
|
+
:azure_api_base,
|
|
12
|
+
:azure_api_key,
|
|
13
|
+
:azure_ai_auth_token,
|
|
11
14
|
:anthropic_api_key,
|
|
12
15
|
:gemini_api_key,
|
|
13
16
|
:gemini_api_base,
|
|
@@ -20,6 +23,7 @@ module RubyLLM
|
|
|
20
23
|
:bedrock_region,
|
|
21
24
|
:bedrock_session_token,
|
|
22
25
|
:openrouter_api_key,
|
|
26
|
+
:xai_api_key,
|
|
23
27
|
:ollama_api_base,
|
|
24
28
|
:gpustack_api_base,
|
|
25
29
|
:gpustack_api_key,
|