llm.rb 11.3.1 → 12.1.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +354 -2
  3. data/LICENSE +93 -17
  4. data/README.md +226 -616
  5. data/data/anthropic.json +322 -426
  6. data/data/bedrock.json +2634 -1144
  7. data/data/deepinfra.json +1513 -0
  8. data/data/deepseek.json +57 -28
  9. data/data/google.json +411 -771
  10. data/data/openai.json +1104 -771
  11. data/data/xai.json +141 -292
  12. data/data/zai.json +263 -141
  13. data/lib/llm/active_record/acts_as_agent.rb +3 -41
  14. data/lib/llm/active_record/acts_as_llm.rb +18 -0
  15. data/lib/llm/active_record.rb +3 -3
  16. data/lib/llm/agent.rb +25 -1
  17. data/lib/llm/context.rb +17 -5
  18. data/lib/llm/contract/completion.rb +2 -2
  19. data/lib/llm/json_adapter.rb +29 -3
  20. data/lib/llm/provider.rb +3 -3
  21. data/lib/llm/providers/deepinfra/audio.rb +66 -0
  22. data/lib/llm/providers/deepinfra/images.rb +90 -0
  23. data/lib/llm/providers/deepinfra/response_adapter.rb +36 -0
  24. data/lib/llm/providers/deepinfra.rb +100 -0
  25. data/lib/llm/providers/deepseek/images.rb +109 -0
  26. data/lib/llm/providers/deepseek/request_adapter.rb +32 -0
  27. data/lib/llm/providers/deepseek/response_adapter/image.rb +9 -0
  28. data/lib/llm/providers/deepseek/response_adapter.rb +29 -0
  29. data/lib/llm/providers/deepseek.rb +4 -2
  30. data/lib/llm/providers/google/request_adapter.rb +22 -5
  31. data/lib/llm/providers/google.rb +4 -4
  32. data/lib/llm/providers/llamacpp.rb +5 -5
  33. data/lib/llm/providers/openai/audio.rb +6 -2
  34. data/lib/llm/providers/openai/images.rb +9 -50
  35. data/lib/llm/providers/openai/request_adapter/respond.rb +38 -4
  36. data/lib/llm/providers/openai/response_adapter/audio.rb +5 -1
  37. data/lib/llm/providers/openai/response_adapter/completion.rb +1 -1
  38. data/lib/llm/providers/openai/response_adapter/image.rb +0 -4
  39. data/lib/llm/providers/openai/responses.rb +1 -0
  40. data/lib/llm/providers/openai/stream_parser.rb +5 -6
  41. data/lib/llm/providers/openai.rb +2 -2
  42. data/lib/llm/providers/xai/images.rb +49 -26
  43. data/lib/llm/providers/xai.rb +2 -2
  44. data/lib/llm/repl/input.rb +64 -0
  45. data/lib/llm/repl/status.rb +30 -0
  46. data/lib/llm/repl/stream.rb +46 -0
  47. data/lib/llm/repl/transcript.rb +61 -0
  48. data/lib/llm/repl/window.rb +107 -0
  49. data/lib/llm/repl.rb +78 -0
  50. data/lib/llm/response.rb +10 -0
  51. data/lib/llm/schema/leaf.rb +7 -1
  52. data/lib/llm/schema/renderer.rb +121 -0
  53. data/lib/llm/schema.rb +30 -0
  54. data/lib/llm/sequel/agent.rb +2 -43
  55. data/lib/llm/sequel/plugin.rb +25 -7
  56. data/lib/llm/tools/chdir.rb +23 -0
  57. data/lib/llm/tools/git.rb +41 -0
  58. data/lib/llm/tools/mkdir.rb +32 -0
  59. data/lib/llm/tools/pwd.rb +20 -0
  60. data/lib/llm/tools/read_file.rb +40 -0
  61. data/lib/llm/tools/rg.rb +46 -0
  62. data/lib/llm/tools/shell.rb +48 -0
  63. data/lib/llm/tools/swap_text.rb +25 -0
  64. data/lib/llm/tools/write_file.rb +24 -0
  65. data/lib/llm/tools.rb +5 -0
  66. data/lib/llm/tracer/telemetry.rb +4 -6
  67. data/lib/llm/tracer.rb +9 -21
  68. data/lib/llm/transport/execution.rb +16 -1
  69. data/lib/llm/transport/net_http_adapter.rb +1 -1
  70. data/lib/llm/uridata.rb +16 -0
  71. data/lib/llm/version.rb +1 -1
  72. data/lib/llm.rb +9 -0
  73. data/llm.gemspec +5 -18
  74. data/resources/deepdive.md +829 -263
  75. metadata +31 -18
  76. data/lib/llm/tracer/langsmith.rb +0 -144
data/data/xai.json CHANGED
@@ -7,20 +7,34 @@
7
7
  "name": "xAI",
8
8
  "doc": "https://docs.x.ai/docs/models",
9
9
  "models": {
10
- "grok-4.20-0309-non-reasoning": {
11
- "id": "grok-4.20-0309-non-reasoning",
12
- "name": "Grok 4.20 (Non-Reasoning)",
10
+ "grok-4.20-multi-agent-0309": {
11
+ "id": "grok-4.20-multi-agent-0309",
12
+ "name": "Grok 4.20 Multi-Agent",
13
+ "description": "Grok model for agentic tool use, reasoning, coding, and live assistance",
13
14
  "family": "grok",
14
15
  "attachment": true,
15
- "reasoning": false,
16
- "tool_call": true,
16
+ "reasoning": true,
17
+ "reasoning_options": [
18
+ {
19
+ "type": "effort",
20
+ "values": [
21
+ "low",
22
+ "medium",
23
+ "high",
24
+ "xhigh"
25
+ ]
26
+ }
27
+ ],
28
+ "tool_call": false,
29
+ "structured_output": true,
17
30
  "temperature": true,
18
31
  "release_date": "2026-03-09",
19
32
  "last_updated": "2026-03-09",
20
33
  "modalities": {
21
34
  "input": [
22
35
  "text",
23
- "image"
36
+ "image",
37
+ "pdf"
24
38
  ],
25
39
  "output": [
26
40
  "text"
@@ -28,17 +42,17 @@
28
42
  },
29
43
  "open_weights": false,
30
44
  "limit": {
31
- "context": 2000000,
45
+ "context": 1000000,
32
46
  "output": 30000
33
47
  },
34
48
  "cost": {
35
- "input": 2,
36
- "output": 6,
49
+ "input": 1.25,
50
+ "output": 2.5,
37
51
  "cache_read": 0.2,
38
52
  "tiers": [
39
53
  {
40
- "input": 4,
41
- "output": 12,
54
+ "input": 2.5,
55
+ "output": 5,
42
56
  "cache_read": 0.4,
43
57
  "tier": {
44
58
  "type": "context",
@@ -47,26 +61,29 @@
47
61
  }
48
62
  ],
49
63
  "context_over_200k": {
50
- "input": 4,
51
- "output": 12,
64
+ "input": 2.5,
65
+ "output": 5,
52
66
  "cache_read": 0.4
53
67
  }
54
68
  }
55
69
  },
56
- "grok-4.20-0309-reasoning": {
57
- "id": "grok-4.20-0309-reasoning",
58
- "name": "Grok 4.20 (Reasoning)",
70
+ "grok-4.20-0309-non-reasoning": {
71
+ "id": "grok-4.20-0309-non-reasoning",
72
+ "name": "Grok 4.20 (Non-Reasoning)",
73
+ "description": "Grok model for agentic tool use, reasoning, coding, and live assistance",
59
74
  "family": "grok",
60
75
  "attachment": true,
61
- "reasoning": true,
76
+ "reasoning": false,
62
77
  "tool_call": true,
78
+ "structured_output": true,
63
79
  "temperature": true,
64
80
  "release_date": "2026-03-09",
65
81
  "last_updated": "2026-03-09",
66
82
  "modalities": {
67
83
  "input": [
68
84
  "text",
69
- "image"
85
+ "image",
86
+ "pdf"
70
87
  ],
71
88
  "output": [
72
89
  "text"
@@ -74,17 +91,17 @@
74
91
  },
75
92
  "open_weights": false,
76
93
  "limit": {
77
- "context": 2000000,
94
+ "context": 1000000,
78
95
  "output": 30000
79
96
  },
80
97
  "cost": {
81
- "input": 2,
82
- "output": 6,
98
+ "input": 1.25,
99
+ "output": 2.5,
83
100
  "cache_read": 0.2,
84
101
  "tiers": [
85
102
  {
86
- "input": 4,
87
- "output": 12,
103
+ "input": 2.5,
104
+ "output": 5,
88
105
  "cache_read": 0.4,
89
106
  "tier": {
90
107
  "type": "context",
@@ -93,58 +110,40 @@
93
110
  }
94
111
  ],
95
112
  "context_over_200k": {
96
- "input": 4,
97
- "output": 12,
113
+ "input": 2.5,
114
+ "output": 5,
98
115
  "cache_read": 0.4
99
116
  }
100
117
  }
101
118
  },
102
- "grok-vision-beta": {
103
- "id": "grok-vision-beta",
104
- "name": "Grok Vision Beta",
105
- "family": "grok-vision",
106
- "attachment": true,
107
- "reasoning": false,
108
- "tool_call": true,
109
- "temperature": true,
110
- "knowledge": "2024-08",
111
- "release_date": "2024-11-01",
112
- "last_updated": "2024-11-01",
113
- "modalities": {
114
- "input": [
115
- "text",
116
- "image"
117
- ],
118
- "output": [
119
- "text"
120
- ]
121
- },
122
- "open_weights": false,
123
- "limit": {
124
- "context": 8192,
125
- "output": 4096
126
- },
127
- "cost": {
128
- "input": 5,
129
- "output": 15,
130
- "cache_read": 5
131
- }
132
- },
133
- "grok-2-vision-1212": {
134
- "id": "grok-2-vision-1212",
135
- "name": "Grok 2 Vision (1212)",
119
+ "grok-4.3": {
120
+ "id": "grok-4.3",
121
+ "name": "Grok 4.3",
122
+ "description": "xAI's default Grok for chat, coding, agentic tools, and lower hallucination risk",
136
123
  "family": "grok",
137
124
  "attachment": true,
138
- "reasoning": false,
125
+ "reasoning": true,
126
+ "reasoning_options": [
127
+ {
128
+ "type": "effort",
129
+ "values": [
130
+ "none",
131
+ "low",
132
+ "medium",
133
+ "high"
134
+ ]
135
+ }
136
+ ],
139
137
  "tool_call": true,
138
+ "structured_output": true,
140
139
  "temperature": true,
141
- "knowledge": "2024-08",
142
- "release_date": "2024-08-20",
143
- "last_updated": "2024-12-12",
140
+ "release_date": "2026-04-17",
141
+ "last_updated": "2026-04-17",
144
142
  "modalities": {
145
143
  "input": [
146
144
  "text",
147
- "image"
145
+ "image",
146
+ "pdf"
148
147
  ],
149
148
  "output": [
150
149
  "text"
@@ -152,115 +151,76 @@
152
151
  },
153
152
  "open_weights": false,
154
153
  "limit": {
155
- "context": 8192,
156
- "output": 4096
154
+ "context": 1000000,
155
+ "output": 30000
157
156
  },
158
157
  "cost": {
159
- "input": 2,
160
- "output": 10,
161
- "cache_read": 2
158
+ "input": 1.25,
159
+ "output": 2.5,
160
+ "cache_read": 0.2,
161
+ "tiers": [
162
+ {
163
+ "input": 2.5,
164
+ "output": 5,
165
+ "cache_read": 0.4,
166
+ "tier": {
167
+ "type": "context",
168
+ "size": 200000
169
+ }
170
+ }
171
+ ],
172
+ "context_over_200k": {
173
+ "input": 2.5,
174
+ "output": 5,
175
+ "cache_read": 0.4
176
+ }
162
177
  }
163
178
  },
164
179
  "grok-imagine-image-quality": {
165
180
  "id": "grok-imagine-image-quality",
166
181
  "name": "Grok Imagine Image Quality",
182
+ "description": "Image model for prompt-driven generation, editing, and visual design workflows",
167
183
  "family": "grok",
168
184
  "attachment": true,
169
185
  "reasoning": false,
170
186
  "tool_call": false,
171
187
  "temperature": false,
172
- "release_date": "2026-04",
173
- "last_updated": "2026-05-16",
188
+ "release_date": "2026-04-03",
189
+ "last_updated": "2026-04-03",
174
190
  "modalities": {
175
191
  "input": [
176
192
  "text",
177
- "image"
193
+ "image",
194
+ "pdf"
178
195
  ],
179
196
  "output": [
180
- "image"
197
+ "image",
198
+ "pdf"
181
199
  ]
182
200
  },
183
201
  "open_weights": false,
184
202
  "limit": {
185
- "context": 1024,
203
+ "context": 8000,
186
204
  "output": 0
187
205
  }
188
206
  },
189
- "grok-2-1212": {
190
- "id": "grok-2-1212",
191
- "name": "Grok 2 (1212)",
192
- "family": "grok",
193
- "attachment": false,
194
- "reasoning": false,
195
- "tool_call": true,
196
- "temperature": true,
197
- "knowledge": "2024-08",
198
- "release_date": "2024-12-12",
199
- "last_updated": "2024-12-12",
200
- "modalities": {
201
- "input": [
202
- "text"
203
- ],
204
- "output": [
205
- "text"
206
- ]
207
- },
208
- "open_weights": false,
209
- "limit": {
210
- "context": 131072,
211
- "output": 8192
212
- },
213
- "cost": {
214
- "input": 2,
215
- "output": 10,
216
- "cache_read": 2
217
- }
218
- },
219
- "grok-beta": {
220
- "id": "grok-beta",
221
- "name": "Grok Beta",
222
- "family": "grok-beta",
223
- "attachment": false,
224
- "reasoning": false,
225
- "tool_call": true,
226
- "temperature": true,
227
- "knowledge": "2024-08",
228
- "release_date": "2024-11-01",
229
- "last_updated": "2024-11-01",
230
- "modalities": {
231
- "input": [
232
- "text"
233
- ],
234
- "output": [
235
- "text"
236
- ]
237
- },
238
- "open_weights": false,
239
- "limit": {
240
- "context": 131072,
241
- "output": 4096
242
- },
243
- "cost": {
244
- "input": 5,
245
- "output": 15,
246
- "cache_read": 5
247
- }
248
- },
249
207
  "grok-imagine-video": {
250
208
  "id": "grok-imagine-video",
251
209
  "name": "Grok Imagine Video",
210
+ "description": "Image model for prompt-driven generation, editing, and visual design workflows",
252
211
  "family": "grok",
253
212
  "attachment": true,
254
213
  "reasoning": false,
255
214
  "tool_call": false,
256
215
  "temperature": false,
257
- "release_date": "2026-03",
258
- "last_updated": "2026-05-16",
216
+ "release_date": "2026-01-28",
217
+ "last_updated": "2026-01-28",
259
218
  "modalities": {
260
219
  "input": [
261
220
  "text",
262
221
  "image",
263
- "video"
222
+ "video",
223
+ "pdf"
264
224
  ],
265
225
  "output": [
266
226
  "video"
@@ -272,106 +232,24 @@
272
232
  "output": 0
273
233
  }
274
234
  },
275
- "grok-2": {
276
- "id": "grok-2",
277
- "name": "Grok 2",
278
- "family": "grok",
279
- "attachment": false,
280
- "reasoning": false,
281
- "tool_call": true,
282
- "temperature": true,
283
- "knowledge": "2024-08",
284
- "release_date": "2024-08-20",
285
- "last_updated": "2024-08-20",
286
- "modalities": {
287
- "input": [
288
- "text"
289
- ],
290
- "output": [
291
- "text"
292
- ]
293
- },
294
- "open_weights": false,
295
- "limit": {
296
- "context": 131072,
297
- "output": 8192
298
- },
299
- "cost": {
300
- "input": 2,
301
- "output": 10,
302
- "cache_read": 2
303
- }
304
- },
305
- "grok-2-vision-latest": {
306
- "id": "grok-2-vision-latest",
307
- "name": "Grok 2 Vision Latest",
308
- "family": "grok",
309
- "attachment": true,
310
- "reasoning": false,
311
- "tool_call": true,
312
- "temperature": true,
313
- "knowledge": "2024-08",
314
- "release_date": "2024-08-20",
315
- "last_updated": "2024-12-12",
316
- "modalities": {
317
- "input": [
318
- "text",
319
- "image"
320
- ],
321
- "output": [
322
- "text"
323
- ]
324
- },
325
- "open_weights": false,
326
- "limit": {
327
- "context": 8192,
328
- "output": 4096
329
- },
330
- "cost": {
331
- "input": 2,
332
- "output": 10,
333
- "cache_read": 2
334
- }
335
- },
336
- "grok-imagine-image": {
337
- "id": "grok-imagine-image",
338
- "name": "Grok Imagine Image",
339
- "family": "grok",
340
- "attachment": true,
341
- "reasoning": false,
342
- "tool_call": false,
343
- "temperature": false,
344
- "release_date": "2026-03",
345
- "last_updated": "2026-05-16",
346
- "modalities": {
347
- "input": [
348
- "text",
349
- "image"
350
- ],
351
- "output": [
352
- "image"
353
- ]
354
- },
355
- "open_weights": false,
356
- "limit": {
357
- "context": 1024,
358
- "output": 0
359
- }
360
- },
361
- "grok-4.3": {
362
- "id": "grok-4.3",
363
- "name": "Grok 4.3",
235
+ "grok-4.20-0309-reasoning": {
236
+ "id": "grok-4.20-0309-reasoning",
237
+ "name": "Grok 4.20 (Reasoning)",
238
+ "description": "Reasoning Grok for document-heavy analysis and long-horizon tool use",
364
239
  "family": "grok",
365
240
  "attachment": true,
366
241
  "reasoning": true,
242
+ "reasoning_options": [],
367
243
  "tool_call": true,
244
+ "structured_output": true,
368
245
  "temperature": true,
369
- "release_date": "2026-05-01",
370
- "last_updated": "2026-05-01",
246
+ "release_date": "2026-03-09",
247
+ "last_updated": "2026-03-09",
371
248
  "modalities": {
372
249
  "input": [
373
250
  "text",
374
- "image"
251
+ "image",
252
+ "pdf"
375
253
  ],
376
254
  "output": [
377
255
  "text"
@@ -404,81 +282,52 @@
404
282
  }
405
283
  }
406
284
  },
407
- "grok-2-vision": {
408
- "id": "grok-2-vision",
409
- "name": "Grok 2 Vision",
285
+ "grok-imagine-image": {
286
+ "id": "grok-imagine-image",
287
+ "name": "Grok Imagine Image",
288
+ "description": "Image model for prompt-driven generation, editing, and visual design workflows",
410
289
  "family": "grok",
411
290
  "attachment": true,
412
291
  "reasoning": false,
413
- "tool_call": true,
414
- "temperature": true,
415
- "knowledge": "2024-08",
416
- "release_date": "2024-08-20",
417
- "last_updated": "2024-08-20",
292
+ "tool_call": false,
293
+ "temperature": false,
294
+ "release_date": "2026-01-28",
295
+ "last_updated": "2026-01-28",
418
296
  "modalities": {
419
297
  "input": [
420
298
  "text",
421
- "image"
422
- ],
423
- "output": [
424
- "text"
425
- ]
426
- },
427
- "open_weights": false,
428
- "limit": {
429
- "context": 8192,
430
- "output": 4096
431
- },
432
- "cost": {
433
- "input": 2,
434
- "output": 10,
435
- "cache_read": 2
436
- }
437
- },
438
- "grok-2-latest": {
439
- "id": "grok-2-latest",
440
- "name": "Grok 2 Latest",
441
- "family": "grok",
442
- "attachment": false,
443
- "reasoning": false,
444
- "tool_call": true,
445
- "temperature": true,
446
- "knowledge": "2024-08",
447
- "release_date": "2024-08-20",
448
- "last_updated": "2024-12-12",
449
- "modalities": {
450
- "input": [
451
- "text"
299
+ "image",
300
+ "pdf"
452
301
  ],
453
302
  "output": [
454
- "text"
303
+ "image",
304
+ "pdf"
455
305
  ]
456
306
  },
457
307
  "open_weights": false,
458
308
  "limit": {
459
- "context": 131072,
460
- "output": 8192
461
- },
462
- "cost": {
463
- "input": 2,
464
- "output": 10,
465
- "cache_read": 2
309
+ "context": 8000,
310
+ "output": 0
466
311
  }
467
312
  },
468
- "grok-4.20-multi-agent-0309": {
469
- "id": "grok-4.20-multi-agent-0309",
470
- "name": "Grok 4.20 Multi-Agent",
471
- "family": "grok",
313
+ "grok-build-0.1": {
314
+ "id": "grok-build-0.1",
315
+ "name": "Grok Build 0.1",
316
+ "description": "Fast Grok coding model tuned for agentic engineering and iterative edits",
317
+ "family": "grok-build",
472
318
  "attachment": true,
473
319
  "reasoning": true,
474
- "tool_call": false,
320
+ "reasoning_options": [],
321
+ "tool_call": true,
322
+ "structured_output": true,
475
323
  "temperature": true,
476
- "release_date": "2026-03-09",
477
- "last_updated": "2026-03-09",
324
+ "release_date": "2026-04-16",
325
+ "last_updated": "2026-04-16",
478
326
  "modalities": {
479
327
  "input": [
480
328
  "text",
481
- "image"
329
+ "image",
330
+ "pdf"
482
331
  ],
483
332
  "output": [
484
333
  "text"
@@ -486,17 +335,17 @@
486
335
  },
487
336
  "open_weights": false,
488
337
  "limit": {
489
- "context": 2000000,
490
- "output": 30000
338
+ "context": 256000,
339
+ "output": 256000
491
340
  },
492
341
  "cost": {
493
- "input": 2,
494
- "output": 6,
342
+ "input": 1,
343
+ "output": 2,
495
344
  "cache_read": 0.2,
496
345
  "tiers": [
497
346
  {
498
- "input": 4,
499
- "output": 12,
347
+ "input": 2,
348
+ "output": 4,
500
349
  "cache_read": 0.4,
501
350
  "tier": {
502
351
  "type": "context",
@@ -505,8 +354,8 @@
505
354
  }
506
355
  ],
507
356
  "context_over_200k": {
508
- "input": 4,
509
- "output": 12,
357
+ "input": 2,
358
+ "output": 4,
510
359
  "cache_read": 0.4
511
360
  }
512
361
  }