llm.rb 12.0.0 β†’ 12.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +193 -1
  3. data/LICENSE +5 -4
  4. data/README.md +56 -18
  5. data/data/anthropic.json +85 -372
  6. data/data/bedrock.json +498 -3
  7. data/data/deepinfra.json +567 -47
  8. data/data/deepseek.json +4 -0
  9. data/data/google.json +54 -0
  10. data/data/mistral.json +968 -0
  11. data/data/openai.json +51 -0
  12. data/data/xai.json +67 -0
  13. data/data/zai.json +14 -0
  14. data/lib/llm/agent.rb +41 -1
  15. data/lib/llm/context.rb +9 -1
  16. data/lib/llm/function.rb +6 -0
  17. data/lib/llm/json_adapter.rb +29 -3
  18. data/lib/llm/provider.rb +3 -3
  19. data/lib/llm/providers/anthropic.rb +2 -2
  20. data/lib/llm/providers/google.rb +3 -1
  21. data/lib/llm/providers/llamacpp.rb +5 -5
  22. data/lib/llm/providers/mistral/request_adapter/completion.rb +122 -0
  23. data/lib/llm/providers/mistral/request_adapter.rb +20 -0
  24. data/lib/llm/providers/mistral.rb +96 -0
  25. data/lib/llm/repl/input.rb +64 -0
  26. data/lib/llm/repl/status.rb +30 -0
  27. data/lib/llm/repl/stream.rb +46 -0
  28. data/lib/llm/repl/transcript.rb +61 -0
  29. data/lib/llm/repl/window.rb +107 -0
  30. data/lib/llm/repl.rb +78 -0
  31. data/lib/llm/tools/chdir.rb +23 -0
  32. data/lib/llm/tools/git.rb +41 -0
  33. data/lib/llm/tools/mkdir.rb +32 -0
  34. data/lib/llm/tools/pwd.rb +20 -0
  35. data/lib/llm/tools/read_file.rb +40 -0
  36. data/lib/llm/tools/rg.rb +46 -0
  37. data/lib/llm/tools/shell.rb +48 -0
  38. data/lib/llm/tools/swap_text.rb +25 -0
  39. data/lib/llm/tools/write_file.rb +24 -0
  40. data/lib/llm/tools.rb +5 -0
  41. data/lib/llm/version.rb +1 -1
  42. data/lib/llm.rb +9 -0
  43. data/llm.gemspec +1 -1
  44. data/resources/deepdive.md +32 -0
  45. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e042f679a5f682feed6726430dd1b28fd6728c9223cbd0e0499c92e8952a06e6
4
- data.tar.gz: 0cb3f55e70a321bea3f1903261142bf3aa842fface494331a548f684aac520d8
3
+ metadata.gz: 20d8c7c9c3d9d270f371781b28e7537a5c6921cff138cfc895bdbf0042003d07
4
+ data.tar.gz: 11b1abd397f1b13afadf4fe56e9670037a7c6ee586e945fd6a909505a4114122
5
5
  SHA512:
6
- metadata.gz: ba64ba9b87d1343f9d94a06b97cb6cc0ec0ca5d7a8c4b235e52c9ed489c5670848b44e0549e838b01b12be89d19005ba571a6dd9557a8f2f5f4e62a3ec018ec9
7
- data.tar.gz: 81a489afa510edf608b74a3a83abc16b6d81c6f59f614df6460f638dbcf1e0a539d8d2b6b2e5a98a3772d5c9d7c7233d7b231bbf447dda7cfcf8df1861819c8d
6
+ metadata.gz: d99ad697a3b3d5d13a0804ab3cea569ffbf5dc88d853aabe7461c4ae59020519e140aa0de1c2b26336b03998212410449da238ea8df5f6a190012f026093464c
7
+ data.tar.gz: dd6314a5e1e7ba3899d1ab13ba4f076508481bc2e24d3502bfa5cc4ebfb66a2203772ffc9acb4987b741eea413997493b8f85a2a7a841cf768e80d9b412886a8
data/CHANGELOG.md CHANGED
@@ -13,7 +13,199 @@
13
13
  > Changelog <br>
14
14
  > a [r.uby.dev](https://r.uby.dev) project
15
15
 
16
- ## Unreleased
16
+ ## What's next
17
+
18
+ Changes since `v12.2.0`.
19
+
20
+ ## v12.2.0
21
+
22
+ Changes since `v12.1.0`.
23
+
24
+ This release adds Mistral as a new provider with chat completions, streaming, tool calls,
25
+ structured outputs, file/image attachments, and embeddings support. It introduces
26
+ the `trace:` option to `LLM::Agent#repl` for keeping the tracer active during
27
+ interactive sessions.
28
+
29
+ Several fixes land for the Google provider (generationConfig parameter leakage),
30
+ `LLM::Context#tracer=` (always assigning nil), `LLM::Provider#with_tracer(nil)`
31
+ (nil fallback), and `LLM::Context#repair!` (dropping Struct returns).
32
+
33
+ The default HTTP timeout has been increased from 60s to 180s to better accommodate
34
+ reasoning models and large structured outputs, and the Anthropic default model has
35
+ been updated to `claude-opus-4-8`. Model metadata has been refreshed across
36
+ Anthropic, AWS Bedrock, DeepInfra, Google, and xAI, with Mistral model data added
37
+ to the registry.
38
+
39
+ ### Add
40
+
41
+ * **Add `trace:` option to `LLM::Agent#repl`** <br>
42
+ `LLM::Agent#repl` now accepts a `trace:` keyword argument. By default
43
+ the tracer is disabled for the duration of the repl session to prevent
44
+ curses UI interference from output written to `$stdout` or `$stderr`.
45
+ Set `trace: true` to keep the tracer active during the session, which
46
+ is useful when the tracer writes to a file rather than the terminal.
47
+
48
+ * **Add a new provider: LLM::Mistral** <br>
49
+ [Mistral](https://mistral.ai) is now supported through its
50
+ OpenAI-compatible API. The provider supports chat completions,
51
+ streaming, tool calls, structured output (schema), file/image
52
+ attachments, and embeddings. Use `LLM.mistral(...)` to create a
53
+ provider instance.
54
+
55
+ * **Add `LLM.mistral(...)` convenience method** <br>
56
+ A new top-level accessor (`LLM.mistral`) returns an `LLM::Mistral`
57
+ provider instance, matching the pattern used by other providers.
58
+
59
+ ### Fix
60
+
61
+ * **Fix Google `generationConfig` parameter leakage** <br>
62
+ Fix a bug in the Google provider where non-generation parameters
63
+ (`role`, `model`, `messages`, `stream`) were leaking into the
64
+ `generationConfig` object alongside legitimate generation config
65
+ parameters such as `temperature`. Non-config parameters are now
66
+ filtered out before constructing `generationConfig`.
67
+
68
+ * **Fix `LLM::Context#tracer=` always assigning `nil`** <br>
69
+ The `LLM::Context#tracer=` setter had a bug where it always assigned
70
+ `nil` regardless of the tracer value passed. It now correctly assigns
71
+ the given tracer or falls back to `LLM::Tracer::Null`.
72
+
73
+ * **Fix `LLM::Provider#with_tracer(nil)` fallback** <br>
74
+ `LLM::Provider#with_tracer(nil)` now falls back to
75
+ `LLM::Tracer::Null` instead of setting a `nil` tracer directly.
76
+
77
+ * **Fix `LLM::Context#repair!` dropping `Struct` returns** <br>
78
+ `LLM::Context#repair!` used `[*prompt]` to wrap the prompt before
79
+ grepping for return objects. Since `LLM::Function::Return` is a
80
+ `Struct`, the splat operator expanded it into its member values
81
+ instead of wrapping it, causing the grep to silently drop returns.
82
+ The fix wraps both sources in an array before flattening.
83
+
84
+ ### Change
85
+
86
+ * **Increase default provider timeout from 60s to 180s** <br>
87
+ The default HTTP timeout for all providers has been increased from
88
+ 60 to 180 seconds to better accommodate long-running requests such
89
+ as reasoning models and large structured outputs.
90
+
91
+ * **Change Anthropic default model to `claude-opus-4-8`** <br>
92
+ The default Anthropic chat model has been updated from
93
+ `claude-sonnet-4-20250514` to `claude-opus-4-8`, reflecting the
94
+ latest model release from Anthropic.
95
+
96
+ * **Refresh model metadata** <br>
97
+ Update model listings, pricing, and capabilities for Anthropic,
98
+ AWS Bedrock, DeepInfra, Google, and xAI. Add Mistral model data
99
+ to the registry.
100
+
101
+ ## v12.1.0
102
+
103
+ Changes since `v12.0.0`.
104
+
105
+ This release adds `LLM::Agent#repl` with a curses-based
106
+ interactive read-eval-print loop. It requires the optional
107
+ dependency `curses` and it is probably the most notable
108
+ feature in this release.
109
+
110
+ Multiple _opt-in_ tools have been added to the `llm/tools/*.rb`
111
+ directory. They serve as examples and as general-purpose tools
112
+ that happen to power the repository's agents.
113
+
114
+ The BSL license has been extended to grant additional free waivers
115
+ for non-profits, charities and for companies with 50 or less
116
+ employees.
117
+
118
+ Other changes include small-ish bug fixes. <br>
119
+ As always, see the changelog details for a thorough overview.
120
+
121
+ ### Add
122
+
123
+ * **Add `LLM::Agent#repl`** <br>
124
+ Add a curses-based read-eval-print loop for `LLM::Agent` that lets
125
+ developers interact with an agent after it has been set up or has
126
+ performed a task. It is similar to `binding.pry`: once you exit,
127
+ you can continue with the rest of your program. It requires the
128
+ `curses` gem.
129
+
130
+ * **Add `#tracer=` setter on Provider, Context and Agent** <br>
131
+ `LLM::Provider`, `LLM::Context` and `LLM::Agent` can now configure
132
+ the tracer after initialization via the `#tracer=` setter. It accepts
133
+ a subclass of `LLM::Tracer` or `nil` to disable the tracer.
134
+
135
+ * **Add `LLM::Tool::Shell`** <br>
136
+ Add a built-in shell tool that can run a command with arguments. <br>
137
+ It must be required explicitly with `require "llm/tools/shell"` and
138
+ requires the `test-cmd.rb` gem.
139
+
140
+ * **Add `LLM::Tool::ReadFile`** <br>
141
+ Add a built-in tool for reading the contents of a file, with optional
142
+ `start` and `stop` line offsets. <br>
143
+ It must be required explicitly with `require "llm/tools/read_file"`.
144
+
145
+ * **Add `LLM::Tool::Chdir`** <br>
146
+ Add a built-in tool for changing the current working directory. <br>
147
+ It must be required explicitly with `require "llm/tools/chdir"`.
148
+
149
+ * **Add `LLM::Tool::Git`** <br>
150
+ Add a built-in tool that can perform git actions (`log`, `diff`,
151
+ `show`, `commit`, `checkout`, `branch`). <br>
152
+ It must be required explicitly with `require "llm/tools/git"` and requires the `test-cmd.rb` gem.
153
+
154
+ * **Add `LLM::Tool::Rg`** <br>
155
+ Add a built-in tool that wraps the `rg` (ripgrep) command for
156
+ recursively searching the current directory for patterns. <br>
157
+ It must be required explicitly with `require "llm/tools/rg"` and requires the `test-cmd.rb` gem.
158
+
159
+ * **Add `LLM::Tool::SwapText`** <br>
160
+ Add a built-in tool that can replace an exact snippet of text in a
161
+ file with a new piece of text. <br>
162
+ It must be required explicitly with `require "llm/tools/swap_text"`.
163
+
164
+ * **Add `LLM::Tool::Pwd`** <br>
165
+ Add a built-in tool that returns the current working directory. <br>
166
+ It must be required explicitly with `require "llm/tools/pwd"`.
167
+
168
+ * **Add `LLM::Tool::WriteFile`** <br>
169
+ Add a built-in tool that can write a given string to a given file
170
+ path. <br>
171
+ It must be required explicitly with `require "llm/tools/write_file"`.
172
+
173
+ * **Add `LLM::Tool::Mkdir`** <br>
174
+ Add a built-in tool that can create a tree of new directories. <br>
175
+ It must be required explicitly with `require "llm/tools/mkdir"` and
176
+ requires the `test-cmd.rb` gem.
177
+
178
+ ### Change
179
+
180
+ * **Extend BSL additional use grant** <br>
181
+ The Business Source License additional use grant has been extended to
182
+ include non-profits, charities, and companies with 50 or fewer
183
+ employees, in addition to the existing personal, education, and
184
+ evaluation uses.
185
+
186
+ * **Change LlamaCpp default port (8080 => 8013)** <br>
187
+ The default port for the LlamaCpp provider has changed from `8080` to
188
+ `8013` since llamacpp itself defaults to that port.
189
+
190
+ * **Change LlamaCpp default model to `nil`** <br>
191
+ The default model for LlamaCpp is now `nil`, letting whatever model
192
+ is served by the llamacpp server act as the default. Previously it
193
+ defaulted to `qwen3`.
194
+
195
+ ### Fix
196
+
197
+ * **Fix `LLM::Agent.tools` Symbol resolution** <br>
198
+ When an agent defined tools via `tools :method_name`, the resolved
199
+ symbol was incorrectly forwarded as `[:method_name]` (an array) to
200
+ `LLM::Context`. This fix copies the same pattern used by other
201
+ attribute resolvers (e.g., `skills`) so a single Symbol is resolved
202
+ through the agent instance correctly.
203
+
204
+ * **Encode strings as UTF-8 in the JSON adapter** <br>
205
+ The `json` gem will reject BINARY-encoded strings from version 3 and
206
+ beyond. The `LLM::JSONAdapter.dump` method now walks serialized data
207
+ and encodes every string into UTF-8, using `String#scrub` to replace
208
+ bytes that are not valid UTF-8.
17
209
 
18
210
  ## v12.0.0
19
211
 
data/LICENSE CHANGED
@@ -10,10 +10,11 @@ Licensor: Robert Gleeson
10
10
  Licensed Work: llm.rb
11
11
 
12
12
  Additional Use Grant:
13
- Free for personal use.
14
- Free for education.
15
- Free for evaluation, development, and testing.
16
- Commercial production use requires a commercial license.
13
+ - Free for personal use
14
+ - Free for students and their teachers
15
+ - Free for evaluation, development, and testing
16
+ - Free for non-profits and charities
17
+ - Free for companies with less than or equal to 50 employees
17
18
 
18
19
  Change Date:
19
20
  Four years after the first public release of each specific version of the
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  </a>
11
11
  </p>
12
12
 
13
- > A [r.uby.dev](https://r.uby.dev) project.
13
+ > A [r.uby.dev](https://r.uby.dev/llm) project.
14
14
 
15
15
  Welcome to the canonical llm.rb repository.
16
16
 
@@ -23,7 +23,7 @@ that are opt-in.
23
23
  ## Features
24
24
 
25
25
  The runtime supports OpenAI, OpenAI-compatible endpoints, Anthropic, Google
26
- Gemini, DeepSeek, DeepInfra, xAI, Z.ai, AWS Bedrock, Ollama, and llama.cpp.
26
+ Gemini, Mistral, DeepSeek, DeepInfra, xAI, Z.ai, AWS Bedrock, Ollama, and llama.cpp.
27
27
  It has first-class support for streaming, tool calls, MCP
28
28
  and A2A, embeddings, vector stores and the RAG pattern.
29
29
 
@@ -117,6 +117,24 @@ agent = LLM::Agent.new(llm, stream: MyStream.new)
117
117
  agent.talk "Explain Ruby fibers."
118
118
  ```
119
119
 
120
+ #### LLM::REPL
121
+
122
+ The [LLM::Agent#repl](https://r.uby.dev/api-docs/llm.rb/LLM/Agent.html#repl-instance_method)
123
+ method allows an agent to spawn a read-eval-print loop
124
+ that can be useful during the development and operation
125
+ of agents. It can be used to debug tool calls, confirm an
126
+ agent has done what was expected, or improve the agent
127
+ by asking questions about what it has done up to that point.
128
+
129
+ This feature requires that the [curses](https://github.com/ruby/curses)
130
+ library is installed and available to require.
131
+
132
+ ```ruby
133
+ llm = LLM.deepseek(key: ENV["KEY"])
134
+ agent = LLM::Agent.new(llm)
135
+ agent.repl
136
+ ```
137
+
120
138
  #### LLM::MCP
121
139
 
122
140
  The Model Context Protocol (MCP) has first-class support
@@ -247,28 +265,37 @@ agent.talk "perform research"
247
265
  <summary>What providers does llm.rb support?</summary>
248
266
  <br>
249
267
  <p>
250
- China-based
251
268
 
252
- * DeepSeek
253
- * zAI
269
+ **Cloud**
270
+
271
+ The following cloud-based providers are available to choose from. <br>
272
+ In no particular order:
273
+
274
+ πŸ‡ΊπŸ‡Έ OpenAI <br>
275
+ πŸ‡ΊπŸ‡Έ DeepInfra <br>
276
+ πŸ‡ΊπŸ‡Έ xAI <br>
277
+ πŸ‡ΊπŸ‡Έ Google (Gemini) <br>
278
+ πŸ‡ΊπŸ‡Έ AWS bedrock <br>
279
+ πŸ‡ΊπŸ‡Έ Anthropic <br>
280
+ πŸ‡¨πŸ‡³ DeepSeek <br>
281
+ πŸ‡¨πŸ‡³ zAI <br>
282
+ πŸ‡ͺπŸ‡Ί Mistral <br>
254
283
 
255
- US-based
284
+ **Weights**
256
285
 
257
- * OpenAI
258
- * Google (Gemini)
259
- * xAI
260
- * AWS bedrock
261
- * DeepInfra
262
- * Anthropic
286
+ The following providers provide access to open-weight models. <br>
287
+ In no particular order:
263
288
 
264
- Openweights
289
+ πŸ‡ΊπŸ‡Έ DeepInfra <br>
290
+ πŸ‡ΊπŸ‡Έ AWS bedrock <br>
291
+ πŸ‡¨πŸ‡³ DeepSeek <br>
292
+ πŸ‡¨πŸ‡³ zAI <br>
293
+ πŸ‡ͺπŸ‡Ί Mistral <br>
265
294
 
266
- * DeepSeek
267
- * zAI
268
- * DeepInfra
269
- * AWS bedrock
295
+ **Local**
270
296
 
271
- Host your own
297
+ The following providers can be run locally on your own hardware. <br>
298
+ In no particular order:
272
299
 
273
300
  * Ollama
274
301
  * Llamacpp
@@ -335,3 +362,14 @@ Each version converts to the [BSD Zero Clause](https://choosealicense.com/licens
335
362
  four years after its first public release.
336
363
  <br>
337
364
  Contact [robert@r.uby.dev](mailto:robert@r.uby.dev) for a commercial license.
365
+
366
+ ### Waivers
367
+
368
+ Waivers are automatically granted for: <br>
369
+
370
+ * Personal use
371
+ * Students
372
+ * Teachers
373
+ * Evaluation, development, and testing
374
+ * Non-profits and charities
375
+ * Companies with less than or equal to 50 employees