llm.rb 13.1.0 → 14.0.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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +320 -0
  3. data/README.md +340 -31
  4. data/bin/llm.rb +36 -12
  5. data/data/anthropic.json +206 -263
  6. data/data/bedrock.json +2138 -1860
  7. data/data/deepinfra.json +1003 -624
  8. data/data/deepseek.json +38 -34
  9. data/data/google.json +1079 -371
  10. data/data/mistral.json +448 -368
  11. data/data/moonshot.json +384 -0
  12. data/data/openai.json +974 -1343
  13. data/data/xai.json +154 -126
  14. data/data/zai.json +191 -191
  15. data/lib/llm/agent.rb +47 -14
  16. data/lib/llm/context.rb +71 -88
  17. data/lib/llm/cost.rb +23 -17
  18. data/lib/llm/error.rb +0 -8
  19. data/lib/llm/function/async/task.rb +2 -0
  20. data/lib/llm/function/fiber/task.rb +2 -0
  21. data/lib/llm/function/fork/task.rb +2 -0
  22. data/lib/llm/function/ractor/task.rb +2 -0
  23. data/lib/llm/function/sequential/group.rb +4 -1
  24. data/lib/llm/function/sequential/task.rb +1 -1
  25. data/lib/llm/function/task.rb +4 -0
  26. data/lib/llm/function/thread/task.rb +2 -0
  27. data/lib/llm/function.rb +32 -4
  28. data/lib/llm/guard/loop.rb +89 -0
  29. data/lib/llm/guard/null.rb +19 -0
  30. data/lib/llm/guard.rb +61 -0
  31. data/lib/llm/provider.rb +36 -0
  32. data/lib/llm/providers/anthropic/stream_parser.rb +1 -0
  33. data/lib/llm/providers/anthropic.rb +1 -8
  34. data/lib/llm/providers/bedrock/stream_parser.rb +1 -0
  35. data/lib/llm/providers/bedrock.rb +1 -8
  36. data/lib/llm/providers/google/stream_parser.rb +1 -0
  37. data/lib/llm/providers/google.rb +1 -8
  38. data/lib/llm/providers/moonshot.rb +76 -0
  39. data/lib/llm/providers/ollama.rb +1 -8
  40. data/lib/llm/providers/openai/responses/stream_parser.rb +1 -0
  41. data/lib/llm/providers/openai/responses.rb +6 -8
  42. data/lib/llm/providers/openai/stream_parser.rb +1 -0
  43. data/lib/llm/providers/openai.rb +3 -10
  44. data/lib/llm/repl/bar.rb +4 -3
  45. data/lib/llm/repl/buffer.rb +42 -15
  46. data/lib/llm/repl/color.rb +78 -0
  47. data/lib/llm/repl/input/char.rb +46 -0
  48. data/lib/llm/repl/input/row.rb +39 -0
  49. data/lib/llm/repl/input.rb +251 -66
  50. data/lib/llm/repl/markdown/table.rb +6 -2
  51. data/lib/llm/repl/markdown.rb +31 -5
  52. data/lib/llm/repl/status.rb +38 -3
  53. data/lib/llm/repl/stream.rb +16 -4
  54. data/lib/llm/repl/walker.rb +3 -2
  55. data/lib/llm/repl/window.rb +25 -5
  56. data/lib/llm/repl.rb +29 -13
  57. data/lib/llm/stream.rb +8 -7
  58. data/lib/llm/tool.rb +29 -0
  59. data/lib/llm/transformer/null.rb +21 -0
  60. data/lib/llm/transformer.rb +55 -0
  61. data/lib/llm/version.rb +1 -1
  62. data/lib/llm.rb +12 -2
  63. data/llm.gemspec +1 -0
  64. data/resources/deepdive/advanced/cancellation.md +74 -0
  65. data/resources/deepdive/advanced/compaction.md +83 -0
  66. data/resources/deepdive/advanced/context.md +267 -0
  67. data/resources/deepdive/advanced/guard.md +371 -0
  68. data/resources/deepdive/advanced/tracer.md +180 -0
  69. data/resources/deepdive/advanced/transformer.md +67 -0
  70. data/resources/deepdive/advanced/transports.md +45 -0
  71. data/resources/deepdive/everything_else/audio.md +122 -0
  72. data/resources/deepdive/everything_else/cost.md +99 -0
  73. data/resources/deepdive/everything_else/images.md +89 -0
  74. data/resources/deepdive/everything_else/object.md +108 -0
  75. data/resources/deepdive/everything_else/ocr.md +48 -0
  76. data/resources/deepdive/fundamentals/agents.md +202 -0
  77. data/resources/deepdive/fundamentals/builtin_tools.md +191 -0
  78. data/resources/deepdive/fundamentals/concurrency.md +104 -0
  79. data/resources/deepdive/fundamentals/database.md +449 -0
  80. data/resources/deepdive/fundamentals/embeddings.md +157 -0
  81. data/resources/deepdive/fundamentals/repl.md +87 -0
  82. data/resources/deepdive/fundamentals/schema.md +61 -0
  83. data/resources/deepdive/fundamentals/skills.md +106 -0
  84. data/resources/deepdive/fundamentals/stream.md +110 -0
  85. data/resources/deepdive/fundamentals/tools.md +265 -0
  86. data/resources/deepdive/protocols/a2a.md +106 -0
  87. data/resources/deepdive/protocols/mcp.md +111 -0
  88. data/resources/deepdive.md +7 -1
  89. metadata +36 -3
  90. data/lib/llm/loop_guard.rb +0 -107
@@ -0,0 +1,384 @@
1
+ {
2
+ "id": "moonshotai",
3
+ "env": [
4
+ "MOONSHOT_API_KEY"
5
+ ],
6
+ "npm": "@ai-sdk/openai-compatible",
7
+ "api": "https://api.moonshot.ai/v1",
8
+ "name": "Moonshot AI",
9
+ "doc": "https://platform.moonshot.ai/docs/api/chat",
10
+ "models": {
11
+ "kimi-k2.5": {
12
+ "id": "kimi-k2.5",
13
+ "name": "Kimi K2.5",
14
+ "description": "Earlier Kimi frontier model for long-context agents, coding, and multimodal work",
15
+ "family": "kimi-k2",
16
+ "attachment": false,
17
+ "reasoning": true,
18
+ "reasoning_options": [
19
+ {
20
+ "type": "toggle"
21
+ }
22
+ ],
23
+ "tool_call": true,
24
+ "interleaved": {
25
+ "field": "reasoning_content"
26
+ },
27
+ "structured_output": true,
28
+ "temperature": false,
29
+ "knowledge": "2025-01",
30
+ "release_date": "2026-01",
31
+ "last_updated": "2026-01",
32
+ "modalities": {
33
+ "input": [
34
+ "text",
35
+ "image",
36
+ "video"
37
+ ],
38
+ "output": [
39
+ "text"
40
+ ]
41
+ },
42
+ "open_weights": true,
43
+ "limit": {
44
+ "context": 262144,
45
+ "output": 262144
46
+ },
47
+ "cost": {
48
+ "input": 0.6,
49
+ "output": 3,
50
+ "cache_read": 0.1
51
+ }
52
+ },
53
+ "kimi-k2-thinking-turbo": {
54
+ "id": "kimi-k2-thinking-turbo",
55
+ "name": "Kimi K2 Thinking Turbo",
56
+ "description": "Kimi reasoning model for long-horizon research, planning, and tool use",
57
+ "family": "kimi-thinking",
58
+ "attachment": false,
59
+ "reasoning": true,
60
+ "reasoning_options": [],
61
+ "tool_call": true,
62
+ "interleaved": {
63
+ "field": "reasoning_content"
64
+ },
65
+ "temperature": true,
66
+ "knowledge": "2024-08",
67
+ "release_date": "2025-11-06",
68
+ "last_updated": "2025-11-06",
69
+ "modalities": {
70
+ "input": [
71
+ "text"
72
+ ],
73
+ "output": [
74
+ "text"
75
+ ]
76
+ },
77
+ "open_weights": true,
78
+ "limit": {
79
+ "context": 262144,
80
+ "output": 262144
81
+ },
82
+ "cost": {
83
+ "input": 1.15,
84
+ "output": 8,
85
+ "cache_read": 0.15
86
+ }
87
+ },
88
+ "kimi-k2-0711-preview": {
89
+ "id": "kimi-k2-0711-preview",
90
+ "name": "Kimi K2 0711",
91
+ "description": "Kimi model for long-context chat, coding, and agentic reasoning",
92
+ "family": "kimi-k2",
93
+ "attachment": false,
94
+ "reasoning": false,
95
+ "tool_call": true,
96
+ "temperature": true,
97
+ "knowledge": "2024-10",
98
+ "release_date": "2025-07-14",
99
+ "last_updated": "2025-07-14",
100
+ "modalities": {
101
+ "input": [
102
+ "text"
103
+ ],
104
+ "output": [
105
+ "text"
106
+ ]
107
+ },
108
+ "open_weights": true,
109
+ "limit": {
110
+ "context": 131072,
111
+ "output": 16384
112
+ },
113
+ "cost": {
114
+ "input": 0.6,
115
+ "output": 2.5,
116
+ "cache_read": 0.15
117
+ }
118
+ },
119
+ "kimi-k2.7-code-highspeed": {
120
+ "id": "kimi-k2.7-code-highspeed",
121
+ "name": "Kimi K2.7 Code HighSpeed",
122
+ "description": "Coding-focused Kimi model, stronger on long-horizon repo work with less overthinking",
123
+ "family": "kimi-k2",
124
+ "attachment": true,
125
+ "reasoning": true,
126
+ "reasoning_options": [],
127
+ "tool_call": true,
128
+ "interleaved": {
129
+ "field": "reasoning_content"
130
+ },
131
+ "structured_output": true,
132
+ "temperature": false,
133
+ "knowledge": "2025-01",
134
+ "release_date": "2026-06-12",
135
+ "last_updated": "2026-06-12",
136
+ "modalities": {
137
+ "input": [
138
+ "text",
139
+ "image",
140
+ "video"
141
+ ],
142
+ "output": [
143
+ "text"
144
+ ]
145
+ },
146
+ "open_weights": true,
147
+ "limit": {
148
+ "context": 262144,
149
+ "output": 262144
150
+ },
151
+ "cost": {
152
+ "input": 1.9,
153
+ "output": 8,
154
+ "cache_read": 0.38
155
+ }
156
+ },
157
+ "kimi-k2.6": {
158
+ "id": "kimi-k2.6",
159
+ "name": "Kimi K2.6",
160
+ "description": "Multimodal Kimi workhorse for agent loops, coding tasks, and visual context",
161
+ "family": "kimi-k2",
162
+ "attachment": true,
163
+ "reasoning": true,
164
+ "reasoning_options": [
165
+ {
166
+ "type": "toggle"
167
+ }
168
+ ],
169
+ "tool_call": true,
170
+ "interleaved": {
171
+ "field": "reasoning_content"
172
+ },
173
+ "structured_output": true,
174
+ "temperature": true,
175
+ "knowledge": "2025-01",
176
+ "release_date": "2026-04-21",
177
+ "last_updated": "2026-04-21",
178
+ "modalities": {
179
+ "input": [
180
+ "text",
181
+ "image",
182
+ "video"
183
+ ],
184
+ "output": [
185
+ "text"
186
+ ]
187
+ },
188
+ "open_weights": true,
189
+ "limit": {
190
+ "context": 262144,
191
+ "output": 262144
192
+ },
193
+ "cost": {
194
+ "input": 0.95,
195
+ "output": 4,
196
+ "cache_read": 0.16
197
+ }
198
+ },
199
+ "kimi-k2-turbo-preview": {
200
+ "id": "kimi-k2-turbo-preview",
201
+ "name": "Kimi K2 Turbo",
202
+ "description": "Fast Kimi model for responsive chat, coding help, and agent loops",
203
+ "family": "kimi-k2",
204
+ "attachment": false,
205
+ "reasoning": false,
206
+ "tool_call": true,
207
+ "temperature": true,
208
+ "knowledge": "2024-10",
209
+ "release_date": "2025-09-05",
210
+ "last_updated": "2025-09-05",
211
+ "modalities": {
212
+ "input": [
213
+ "text"
214
+ ],
215
+ "output": [
216
+ "text"
217
+ ]
218
+ },
219
+ "open_weights": true,
220
+ "limit": {
221
+ "context": 262144,
222
+ "output": 262144
223
+ },
224
+ "cost": {
225
+ "input": 2.4,
226
+ "output": 10,
227
+ "cache_read": 0.6
228
+ }
229
+ },
230
+ "kimi-k2-0905-preview": {
231
+ "id": "kimi-k2-0905-preview",
232
+ "name": "Kimi K2 0905",
233
+ "description": "Kimi model for long-context chat, coding, and agentic reasoning",
234
+ "family": "kimi-k2",
235
+ "attachment": false,
236
+ "reasoning": false,
237
+ "tool_call": true,
238
+ "temperature": true,
239
+ "knowledge": "2024-10",
240
+ "release_date": "2025-09-05",
241
+ "last_updated": "2025-09-05",
242
+ "modalities": {
243
+ "input": [
244
+ "text"
245
+ ],
246
+ "output": [
247
+ "text"
248
+ ]
249
+ },
250
+ "open_weights": true,
251
+ "limit": {
252
+ "context": 262144,
253
+ "output": 262144
254
+ },
255
+ "cost": {
256
+ "input": 0.6,
257
+ "output": 2.5,
258
+ "cache_read": 0.15
259
+ }
260
+ },
261
+ "kimi-k2.7-code": {
262
+ "id": "kimi-k2.7-code",
263
+ "name": "Kimi K2.7 Code",
264
+ "description": "Coding-focused Kimi model, stronger on long-horizon repo work with less overthinking",
265
+ "family": "kimi-k2",
266
+ "attachment": true,
267
+ "reasoning": true,
268
+ "reasoning_options": [],
269
+ "tool_call": true,
270
+ "interleaved": {
271
+ "field": "reasoning_content"
272
+ },
273
+ "structured_output": true,
274
+ "temperature": false,
275
+ "knowledge": "2025-01",
276
+ "release_date": "2026-06-12",
277
+ "last_updated": "2026-06-12",
278
+ "modalities": {
279
+ "input": [
280
+ "text",
281
+ "image",
282
+ "video"
283
+ ],
284
+ "output": [
285
+ "text"
286
+ ]
287
+ },
288
+ "open_weights": true,
289
+ "limit": {
290
+ "context": 262144,
291
+ "output": 262144
292
+ },
293
+ "cost": {
294
+ "input": 0.95,
295
+ "output": 4,
296
+ "cache_read": 0.19
297
+ }
298
+ },
299
+ "kimi-k2-thinking": {
300
+ "id": "kimi-k2-thinking",
301
+ "name": "Kimi K2 Thinking",
302
+ "description": "Thinking Kimi model for slower research passes, planning, and hard technical questions",
303
+ "family": "kimi-thinking",
304
+ "attachment": false,
305
+ "reasoning": true,
306
+ "reasoning_options": [],
307
+ "tool_call": true,
308
+ "interleaved": {
309
+ "field": "reasoning_content"
310
+ },
311
+ "temperature": true,
312
+ "knowledge": "2024-08",
313
+ "release_date": "2025-11-06",
314
+ "last_updated": "2025-11-06",
315
+ "modalities": {
316
+ "input": [
317
+ "text"
318
+ ],
319
+ "output": [
320
+ "text"
321
+ ]
322
+ },
323
+ "open_weights": true,
324
+ "limit": {
325
+ "context": 262144,
326
+ "output": 262144
327
+ },
328
+ "cost": {
329
+ "input": 0.6,
330
+ "output": 2.5,
331
+ "cache_read": 0.15
332
+ }
333
+ },
334
+ "kimi-k3": {
335
+ "id": "kimi-k3",
336
+ "name": "Kimi K3",
337
+ "description": "Multimodal Kimi model with 1M context and toggleable max-effort thinking for long-horizon agent work",
338
+ "family": "kimi-k3",
339
+ "attachment": true,
340
+ "reasoning": true,
341
+ "reasoning_options": [
342
+ {
343
+ "type": "toggle"
344
+ },
345
+ {
346
+ "type": "effort",
347
+ "values": [
348
+ "low",
349
+ "high",
350
+ "max"
351
+ ]
352
+ }
353
+ ],
354
+ "tool_call": true,
355
+ "interleaved": {
356
+ "field": "reasoning_content"
357
+ },
358
+ "structured_output": true,
359
+ "temperature": false,
360
+ "release_date": "2026-07-16",
361
+ "last_updated": "2026-07-16",
362
+ "modalities": {
363
+ "input": [
364
+ "text",
365
+ "image",
366
+ "video"
367
+ ],
368
+ "output": [
369
+ "text"
370
+ ]
371
+ },
372
+ "open_weights": true,
373
+ "limit": {
374
+ "context": 1048576,
375
+ "output": 131072
376
+ },
377
+ "cost": {
378
+ "input": 3,
379
+ "output": 15,
380
+ "cache_read": 0.3
381
+ }
382
+ }
383
+ }
384
+ }