llm.rb 13.1.0 → 15.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +716 -1826
  3. data/README.md +668 -253
  4. data/bin/llm.rb +156 -56
  5. data/data/alibaba.json +1999 -0
  6. data/data/anthropic.json +195 -252
  7. data/data/bedrock.json +2189 -1854
  8. data/data/deepinfra.json +1312 -728
  9. data/data/deepseek.json +42 -39
  10. data/data/google.json +1024 -404
  11. data/data/mistral.json +481 -401
  12. data/data/moonshot.json +384 -0
  13. data/data/openai.json +985 -1354
  14. data/data/xai.json +220 -115
  15. data/data/zai.json +166 -166
  16. data/docs/deepdive/advanced/cancellation.md +74 -0
  17. data/docs/deepdive/advanced/compaction.md +85 -0
  18. data/docs/deepdive/advanced/context.md +280 -0
  19. data/docs/deepdive/advanced/guard.md +371 -0
  20. data/docs/deepdive/advanced/transformer.md +67 -0
  21. data/docs/deepdive/advanced/transports.md +45 -0
  22. data/docs/deepdive/features/builtin_tools.md +191 -0
  23. data/docs/deepdive/features/concurrency.md +110 -0
  24. data/docs/deepdive/features/database.md +449 -0
  25. data/docs/deepdive/features/embeddings.md +157 -0
  26. data/docs/deepdive/features/repl.md +141 -0
  27. data/docs/deepdive/fundamentals/agents.md +253 -0
  28. data/docs/deepdive/fundamentals/providers.md +159 -0
  29. data/docs/deepdive/fundamentals/schema.md +61 -0
  30. data/docs/deepdive/fundamentals/skills.md +111 -0
  31. data/docs/deepdive/fundamentals/stream.md +143 -0
  32. data/docs/deepdive/fundamentals/tools.md +329 -0
  33. data/docs/deepdive/media/audio.md +122 -0
  34. data/docs/deepdive/media/images.md +89 -0
  35. data/docs/deepdive/media/ocr.md +48 -0
  36. data/docs/deepdive/protocols/a2a.md +106 -0
  37. data/docs/deepdive/protocols/mcp.md +111 -0
  38. data/docs/deepdive/reference/cost.md +109 -0
  39. data/docs/deepdive/reference/model_registry.md +271 -0
  40. data/docs/deepdive/reference/object.md +108 -0
  41. data/docs/deepdive/reference/tracer.md +187 -0
  42. data/{resources → docs}/deepdive.md +37 -23
  43. data/lib/llm/a2a/transport/http.rb +1 -1
  44. data/lib/llm/active_record/acts_as_llm.rb +19 -5
  45. data/lib/llm/agent.rb +107 -17
  46. data/lib/llm/context.rb +164 -134
  47. data/lib/llm/cost.rb +114 -49
  48. data/lib/llm/error.rb +7 -8
  49. data/lib/llm/function/array.rb +1 -1
  50. data/lib/llm/function/async/task.rb +2 -0
  51. data/lib/llm/function/fiber/task.rb +2 -0
  52. data/lib/llm/function/fork/task.rb +16 -1
  53. data/lib/llm/function/ractor/task.rb +2 -0
  54. data/lib/llm/function/sequential/group.rb +20 -10
  55. data/lib/llm/function/sequential/task.rb +2 -9
  56. data/lib/llm/function/task.rb +4 -0
  57. data/lib/llm/function/thread/task.rb +2 -0
  58. data/lib/llm/function.rb +33 -4
  59. data/lib/llm/guard/loop.rb +89 -0
  60. data/lib/llm/guard/null.rb +19 -0
  61. data/lib/llm/guard.rb +61 -0
  62. data/lib/llm/message.rb +5 -4
  63. data/lib/llm/provider.rb +43 -0
  64. data/lib/llm/providers/alibaba/error_handler.rb +34 -0
  65. data/lib/llm/providers/alibaba/request_adapter.rb +13 -0
  66. data/lib/llm/providers/alibaba.rb +93 -0
  67. data/lib/llm/providers/anthropic/stream_parser.rb +1 -0
  68. data/lib/llm/providers/anthropic.rb +1 -9
  69. data/lib/llm/providers/bedrock/stream_parser.rb +1 -0
  70. data/lib/llm/providers/bedrock.rb +9 -9
  71. data/lib/llm/providers/deepseek/request_adapter.rb +2 -33
  72. data/lib/llm/providers/google/stream_parser.rb +1 -0
  73. data/lib/llm/providers/google.rb +1 -9
  74. data/lib/llm/providers/moonshot.rb +76 -0
  75. data/lib/llm/providers/ollama.rb +1 -9
  76. data/lib/llm/providers/openai/responses/stream_parser.rb +1 -0
  77. data/lib/llm/providers/openai/responses.rb +6 -9
  78. data/lib/llm/providers/openai/schema.rb +37 -0
  79. data/lib/llm/providers/openai/stream_parser.rb +1 -0
  80. data/lib/llm/providers/openai.rb +4 -12
  81. data/lib/llm/registry/model.rb +186 -0
  82. data/lib/llm/registry.rb +45 -14
  83. data/lib/llm/repl/bar.rb +11 -12
  84. data/lib/llm/repl/buffer.rb +43 -16
  85. data/lib/llm/repl/color.rb +85 -0
  86. data/lib/llm/repl/command.rb +12 -0
  87. data/lib/llm/repl/commands/model.rb +39 -0
  88. data/lib/llm/repl/input/cache.rb +45 -0
  89. data/lib/llm/repl/input/char.rb +46 -0
  90. data/lib/llm/repl/input/row.rb +39 -0
  91. data/lib/llm/repl/input.rb +327 -79
  92. data/lib/llm/repl/markdown/table.rb +6 -2
  93. data/lib/llm/repl/markdown.rb +56 -6
  94. data/lib/llm/repl/node.rb +7 -0
  95. data/lib/llm/repl/status.rb +54 -5
  96. data/lib/llm/repl/stream.rb +16 -4
  97. data/lib/llm/repl/walker.rb +3 -2
  98. data/lib/llm/repl/window.rb +111 -11
  99. data/lib/llm/repl.rb +47 -21
  100. data/lib/llm/sequel/plugin.rb +19 -5
  101. data/lib/llm/skill.rb +21 -8
  102. data/lib/llm/stream.rb +35 -7
  103. data/lib/llm/tool.rb +27 -0
  104. data/lib/llm/tools/rg.rb +2 -1
  105. data/lib/llm/transformer/null.rb +21 -0
  106. data/lib/llm/transformer.rb +55 -0
  107. data/lib/llm/transport/curb.rb +23 -3
  108. data/lib/llm/usage.rb +155 -9
  109. data/lib/llm/version.rb +1 -1
  110. data/lib/llm.rb +121 -29
  111. data/llm.gemspec +16 -10
  112. metadata +100 -13
  113. data/lib/llm/loop_guard.rb +0 -107
data/data/deepseek.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "deepseek-v4-flash": {
12
12
  "id": "deepseek-v4-flash",
13
13
  "name": "DeepSeek V4 Flash",
14
- "description": "Fast DeepSeek V4 lane for economical reasoning, coding, and long-context work",
14
+ "description": "Official DeepSeek V4 Flash release with enhanced agentic capabilities and integrated DSpark speculative decoding",
15
15
  "family": "deepseek-flash",
16
16
  "attachment": false,
17
17
  "reasoning": true,
@@ -22,6 +22,7 @@
22
22
  {
23
23
  "type": "effort",
24
24
  "values": [
25
+ "low",
25
26
  "high",
26
27
  "max"
27
28
  ]
@@ -34,39 +35,8 @@
34
35
  "structured_output": true,
35
36
  "temperature": true,
36
37
  "knowledge": "2025-05",
37
- "release_date": "2026-04-24",
38
- "last_updated": "2026-04-24",
39
- "modalities": {
40
- "input": [
41
- "text"
42
- ],
43
- "output": [
44
- "text"
45
- ]
46
- },
47
- "open_weights": true,
48
- "limit": {
49
- "context": 1000000,
50
- "output": 384000
51
- },
52
- "cost": {
53
- "input": 0.14,
54
- "output": 0.28,
55
- "cache_read": 0.0028
56
- }
57
- },
58
- "deepseek-chat": {
59
- "id": "deepseek-chat",
60
- "name": "DeepSeek Chat",
61
- "description": "DeepSeek chat model for instruction following, coding, and analysis",
62
- "family": "deepseek",
63
- "attachment": true,
64
- "reasoning": false,
65
- "tool_call": true,
66
- "temperature": true,
67
- "knowledge": "2025-09",
68
- "release_date": "2025-12-01",
69
- "last_updated": "2026-02-28",
38
+ "release_date": "2026-07-31",
39
+ "last_updated": "2026-07-31",
70
40
  "modalities": {
71
41
  "input": [
72
42
  "text"
@@ -83,13 +53,14 @@
83
53
  "cost": {
84
54
  "input": 0.14,
85
55
  "output": 0.28,
56
+ "reasoning": 0.28,
86
57
  "cache_read": 0.0028
87
58
  }
88
59
  },
89
60
  "deepseek-v4-pro": {
90
61
  "id": "deepseek-v4-pro",
91
62
  "name": "DeepSeek V4 Pro",
92
- "description": "Open MoE flagship with million-token context for coding and long agent runs",
63
+ "description": "DeepSeek V4 Pro snapshot with million-token context and support for thinking and non-thinking modes",
93
64
  "family": "deepseek-thinking",
94
65
  "attachment": false,
95
66
  "reasoning": true,
@@ -111,9 +82,8 @@
111
82
  },
112
83
  "structured_output": true,
113
84
  "temperature": true,
114
- "knowledge": "2025-05",
115
- "release_date": "2026-04-24",
116
- "last_updated": "2026-04-24",
85
+ "release_date": "2026-08-12",
86
+ "last_updated": "2026-08-12",
117
87
  "modalities": {
118
88
  "input": [
119
89
  "text"
@@ -122,7 +92,7 @@
122
92
  "text"
123
93
  ]
124
94
  },
125
- "open_weights": true,
95
+ "open_weights": false,
126
96
  "limit": {
127
97
  "context": 1000000,
128
98
  "output": 384000
@@ -130,9 +100,41 @@
130
100
  "cost": {
131
101
  "input": 0.435,
132
102
  "output": 0.87,
103
+ "reasoning": 0.87,
133
104
  "cache_read": 0.003625
134
105
  }
135
106
  },
107
+ "deepseek-chat": {
108
+ "id": "deepseek-chat",
109
+ "name": "DeepSeek Chat",
110
+ "description": "DeepSeek chat model for instruction following, coding, and analysis",
111
+ "family": "deepseek",
112
+ "attachment": true,
113
+ "reasoning": false,
114
+ "tool_call": true,
115
+ "temperature": true,
116
+ "knowledge": "2025-09",
117
+ "release_date": "2025-12-01",
118
+ "last_updated": "2026-02-28",
119
+ "modalities": {
120
+ "input": [
121
+ "text"
122
+ ],
123
+ "output": [
124
+ "text"
125
+ ]
126
+ },
127
+ "open_weights": true,
128
+ "limit": {
129
+ "context": 1000000,
130
+ "output": 384000
131
+ },
132
+ "cost": {
133
+ "input": 0.14,
134
+ "output": 0.28,
135
+ "cache_read": 0.0028
136
+ }
137
+ },
136
138
  "deepseek-reasoner": {
137
139
  "id": "deepseek-reasoner",
138
140
  "name": "DeepSeek Reasoner",
@@ -165,6 +167,7 @@
165
167
  "cost": {
166
168
  "input": 0.14,
167
169
  "output": 0.28,
170
+ "reasoning": 0.28,
168
171
  "cache_read": 0.0028
169
172
  }
170
173
  }