llm.rb 4.8.0 → 4.9.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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +337 -590
  3. data/data/anthropic.json +770 -0
  4. data/data/deepseek.json +75 -0
  5. data/data/google.json +1050 -0
  6. data/data/openai.json +1421 -0
  7. data/data/xai.json +792 -0
  8. data/data/zai.json +330 -0
  9. data/lib/llm/agent.rb +42 -41
  10. data/lib/llm/bot.rb +1 -263
  11. data/lib/llm/buffer.rb +7 -0
  12. data/lib/llm/{session → context}/deserializer.rb +4 -3
  13. data/lib/llm/context.rb +292 -0
  14. data/lib/llm/cost.rb +26 -0
  15. data/lib/llm/error.rb +8 -0
  16. data/lib/llm/function/array.rb +61 -0
  17. data/lib/llm/function/fiber_group.rb +91 -0
  18. data/lib/llm/function/task_group.rb +89 -0
  19. data/lib/llm/function/thread_group.rb +94 -0
  20. data/lib/llm/function.rb +75 -10
  21. data/lib/llm/mcp/command.rb +108 -0
  22. data/lib/llm/mcp/error.rb +31 -0
  23. data/lib/llm/mcp/pipe.rb +82 -0
  24. data/lib/llm/mcp/rpc.rb +118 -0
  25. data/lib/llm/mcp/transport/stdio.rb +85 -0
  26. data/lib/llm/mcp.rb +102 -0
  27. data/lib/llm/message.rb +13 -11
  28. data/lib/llm/model.rb +2 -2
  29. data/lib/llm/prompt.rb +17 -7
  30. data/lib/llm/provider.rb +32 -17
  31. data/lib/llm/providers/anthropic/files.rb +3 -3
  32. data/lib/llm/providers/anthropic.rb +19 -4
  33. data/lib/llm/providers/deepseek.rb +10 -3
  34. data/lib/llm/providers/{gemini → google}/audio.rb +6 -6
  35. data/lib/llm/providers/{gemini → google}/error_handler.rb +2 -2
  36. data/lib/llm/providers/{gemini → google}/files.rb +11 -11
  37. data/lib/llm/providers/{gemini → google}/images.rb +7 -7
  38. data/lib/llm/providers/{gemini → google}/models.rb +5 -5
  39. data/lib/llm/providers/{gemini → google}/request_adapter/completion.rb +7 -3
  40. data/lib/llm/providers/{gemini → google}/request_adapter.rb +1 -1
  41. data/lib/llm/providers/{gemini → google}/response_adapter/completion.rb +7 -7
  42. data/lib/llm/providers/{gemini → google}/response_adapter/embedding.rb +1 -1
  43. data/lib/llm/providers/{gemini → google}/response_adapter/file.rb +1 -1
  44. data/lib/llm/providers/{gemini → google}/response_adapter/files.rb +1 -1
  45. data/lib/llm/providers/{gemini → google}/response_adapter/image.rb +1 -1
  46. data/lib/llm/providers/{gemini → google}/response_adapter/models.rb +1 -1
  47. data/lib/llm/providers/{gemini → google}/response_adapter/web_search.rb +2 -2
  48. data/lib/llm/providers/{gemini → google}/response_adapter.rb +8 -8
  49. data/lib/llm/providers/{gemini → google}/stream_parser.rb +3 -3
  50. data/lib/llm/providers/{gemini.rb → google.rb} +41 -26
  51. data/lib/llm/providers/llamacpp.rb +10 -3
  52. data/lib/llm/providers/ollama.rb +19 -4
  53. data/lib/llm/providers/openai/files.rb +3 -3
  54. data/lib/llm/providers/openai/response_adapter/completion.rb +9 -1
  55. data/lib/llm/providers/openai/response_adapter/responds.rb +9 -1
  56. data/lib/llm/providers/openai/responses.rb +9 -1
  57. data/lib/llm/providers/openai/stream_parser.rb +2 -0
  58. data/lib/llm/providers/openai.rb +19 -4
  59. data/lib/llm/providers/xai.rb +10 -3
  60. data/lib/llm/providers/zai.rb +9 -2
  61. data/lib/llm/registry.rb +81 -0
  62. data/lib/llm/schema/parser.rb +109 -0
  63. data/lib/llm/schema.rb +4 -0
  64. data/lib/llm/server_tool.rb +5 -5
  65. data/lib/llm/session.rb +10 -1
  66. data/lib/llm/tool.rb +85 -4
  67. data/lib/llm/tracer/logger.rb +1 -1
  68. data/lib/llm/tracer/telemetry.rb +7 -7
  69. data/lib/llm/tracer.rb +3 -3
  70. data/lib/llm/usage.rb +5 -0
  71. data/lib/llm/version.rb +1 -1
  72. data/lib/llm.rb +39 -6
  73. data/llm.gemspec +45 -8
  74. metadata +81 -28
data/llm.gemspec CHANGED
@@ -5,17 +5,52 @@ require_relative "lib/llm/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "llm.rb"
7
7
  spec.version = LLM::VERSION
8
- spec.authors = ["Antar Azri", "0x1eef"]
9
- spec.email = ["azantar@proton.me", "0x1eef@proton.me"]
8
+ spec.authors = ["Antar Azri", "0x1eef", "Christos Maris", "Rodrigo Serrano"]
9
+ spec.email = ["azantar@proton.me", "0x1eef@hardenedbsd.org"]
10
10
 
11
11
  spec.summary = <<~SUMMARY
12
- llm.rb is a zero-dependency Ruby toolkit for Large Language Models that
13
- includes OpenAI, Gemini, Anthropic, xAI (grok), zAI, DeepSeek, Ollama, and
14
- LlamaCpp. The toolkit includes full support for chat, streaming, tool calling,
15
- audio, images, files, and structured outputs.
12
+ llm.rb is a Ruby-centric toolkit for building real LLM-powered systems — where
13
+ LLMs are part of your architecture, not just API calls. It gives you explicit
14
+ control over contexts, tools, concurrency, and providers, so you can compose
15
+ reliable, production-ready workflows without hidden abstractions.
16
16
  SUMMARY
17
17
 
18
- spec.description = spec.summary
18
+ spec.description = <<~DESCRIPTION
19
+ llm.rb is a Ruby-centric toolkit for building real LLM-powered systems — where
20
+ LLMs are part of your architecture, not just API calls. It gives you explicit
21
+ control over contexts, tools, concurrency, and providers, so you can compose
22
+ reliable, production-ready workflows without hidden abstractions.
23
+
24
+ Built for engineers who want to understand and control their LLM systems. No
25
+ frameworks, no hidden magic — just composable primitives for building real
26
+ applications, from scripts to full systems like Relay.
27
+
28
+ ## Key Features
29
+
30
+ - **Contexts are central** — Hold history, tools, schema, usage, cost, persistence, and execution state
31
+ - **Tool execution is explicit** — Run local, provider-native, and MCP tools sequentially or concurrently
32
+ - **One API across providers** — Unified interface for OpenAI, Anthropic, Google, xAI, zAI, DeepSeek, Ollama, and LlamaCpp
33
+ - **Thread-safe where it matters** — Providers are shareable, while contexts stay isolated and stateful
34
+ - **Production-ready** — Cost tracking, observability, persistence, and performance tuning built in
35
+ - **Stdlib-only by default** — Runs on Ruby standard library, with optional features loaded only when used
36
+
37
+ ## Capabilities
38
+
39
+ - Chat & Contexts with persistence
40
+ - Streaming responses
41
+ - Tool calling with JSON Schema validation
42
+ - Concurrent execution (threads, fibers, async tasks)
43
+ - Agents with auto-execution
44
+ - Structured outputs
45
+ - MCP (Model Context Protocol) support
46
+ - Multimodal inputs (text, images, audio, documents)
47
+ - Audio generation, transcription, translation
48
+ - Image generation and editing
49
+ - Files API for document processing
50
+ - Embeddings and vector stores
51
+ - Local model registry for capabilities, limits, and pricing
52
+ DESCRIPTION
53
+
19
54
  spec.license = "0BSD"
20
55
  spec.required_ruby_version = ">= 3.2.0"
21
56
 
@@ -23,10 +58,12 @@ Gem::Specification.new do |spec|
23
58
  spec.metadata["homepage_uri"] = "https://github.com/llmrb/llm.rb"
24
59
  spec.metadata["source_code_uri"] = "https://github.com/llmrb/llm.rb"
25
60
  spec.metadata["documentation_uri"] = "https://0x1eef.github.io/x/llm.rb"
61
+ spec.metadata["changelog_uri"] = "https://0x1eef.github.io/x/llm.rb/file.CHANGELOG.html"
26
62
 
27
63
  spec.files = Dir[
28
64
  "README.md", "LICENSE",
29
65
  "lib/*.rb", "lib/**/*.rb",
66
+ "data/*.json",
30
67
  "llm.gemspec"
31
68
  ]
32
69
  spec.require_paths = ["lib"]
@@ -44,4 +81,4 @@ Gem::Specification.new do |spec|
44
81
  spec.add_development_dependency "net-http-persistent", "~> 4.0"
45
82
  spec.add_development_dependency "opentelemetry-sdk", "~> 1.10"
46
83
  spec.add_development_dependency "logger", "~> 1.7"
47
- end
84
+ end
metadata CHANGED
@@ -1,11 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antar Azri
8
8
  - '0x1eef'
9
+ - Christos Maris
10
+ - Rodrigo Serrano
9
11
  bindir: bin
10
12
  cert_chain: []
11
13
  date: 1980-01-02 00:00:00.000000000 Z
@@ -192,26 +194,65 @@ dependencies:
192
194
  - - "~>"
193
195
  - !ruby/object:Gem::Version
194
196
  version: '1.7'
195
- description: llm.rb is a zero-dependency Ruby toolkit for Large Language Models that
196
- includes OpenAI, Gemini, Anthropic, xAI (grok), zAI, DeepSeek, Ollama, and LlamaCpp.
197
- The toolkit includes full support for chat, streaming, tool calling, audio, images,
198
- files, and structured outputs.
197
+ description: |
198
+ llm.rb is a Ruby-centric toolkit for building real LLM-powered systems — where
199
+ LLMs are part of your architecture, not just API calls. It gives you explicit
200
+ control over contexts, tools, concurrency, and providers, so you can compose
201
+ reliable, production-ready workflows without hidden abstractions.
202
+
203
+ Built for engineers who want to understand and control their LLM systems. No
204
+ frameworks, no hidden magic — just composable primitives for building real
205
+ applications, from scripts to full systems like Relay.
206
+
207
+ ## Key Features
208
+
209
+ - **Contexts are central** — Hold history, tools, schema, usage, cost, persistence, and execution state
210
+ - **Tool execution is explicit** — Run local, provider-native, and MCP tools sequentially or concurrently
211
+ - **One API across providers** — Unified interface for OpenAI, Anthropic, Google, xAI, zAI, DeepSeek, Ollama, and LlamaCpp
212
+ - **Thread-safe where it matters** — Providers are shareable, while contexts stay isolated and stateful
213
+ - **Production-ready** — Cost tracking, observability, persistence, and performance tuning built in
214
+ - **Stdlib-only by default** — Runs on Ruby standard library, with optional features loaded only when used
215
+
216
+ ## Capabilities
217
+
218
+ - Chat & Contexts with persistence
219
+ - Streaming responses
220
+ - Tool calling with JSON Schema validation
221
+ - Concurrent execution (threads, fibers, async tasks)
222
+ - Agents with auto-execution
223
+ - Structured outputs
224
+ - MCP (Model Context Protocol) support
225
+ - Multimodal inputs (text, images, audio, documents)
226
+ - Audio generation, transcription, translation
227
+ - Image generation and editing
228
+ - Files API for document processing
229
+ - Embeddings and vector stores
230
+ - Local model registry for capabilities, limits, and pricing
199
231
  email:
200
232
  - azantar@proton.me
201
- - 0x1eef@proton.me
233
+ - 0x1eef@hardenedbsd.org
202
234
  executables: []
203
235
  extensions: []
204
236
  extra_rdoc_files: []
205
237
  files:
206
238
  - LICENSE
207
239
  - README.md
240
+ - data/anthropic.json
241
+ - data/deepseek.json
242
+ - data/google.json
243
+ - data/openai.json
244
+ - data/xai.json
245
+ - data/zai.json
208
246
  - lib/llm.rb
209
247
  - lib/llm/agent.rb
210
248
  - lib/llm/bot.rb
211
249
  - lib/llm/buffer.rb
212
250
  - lib/llm/client.rb
251
+ - lib/llm/context.rb
252
+ - lib/llm/context/deserializer.rb
213
253
  - lib/llm/contract.rb
214
254
  - lib/llm/contract/completion.rb
255
+ - lib/llm/cost.rb
215
256
  - lib/llm/error.rb
216
257
  - lib/llm/eventhandler.rb
217
258
  - lib/llm/eventstream.rb
@@ -219,8 +260,18 @@ files:
219
260
  - lib/llm/eventstream/parser.rb
220
261
  - lib/llm/file.rb
221
262
  - lib/llm/function.rb
263
+ - lib/llm/function/array.rb
264
+ - lib/llm/function/fiber_group.rb
265
+ - lib/llm/function/task_group.rb
266
+ - lib/llm/function/thread_group.rb
222
267
  - lib/llm/function/tracing.rb
223
268
  - lib/llm/json_adapter.rb
269
+ - lib/llm/mcp.rb
270
+ - lib/llm/mcp/command.rb
271
+ - lib/llm/mcp/error.rb
272
+ - lib/llm/mcp/pipe.rb
273
+ - lib/llm/mcp/rpc.rb
274
+ - lib/llm/mcp/transport/stdio.rb
224
275
  - lib/llm/message.rb
225
276
  - lib/llm/mime.rb
226
277
  - lib/llm/model.rb
@@ -247,23 +298,23 @@ files:
247
298
  - lib/llm/providers/deepseek.rb
248
299
  - lib/llm/providers/deepseek/request_adapter.rb
249
300
  - lib/llm/providers/deepseek/request_adapter/completion.rb
250
- - lib/llm/providers/gemini.rb
251
- - lib/llm/providers/gemini/audio.rb
252
- - lib/llm/providers/gemini/error_handler.rb
253
- - lib/llm/providers/gemini/files.rb
254
- - lib/llm/providers/gemini/images.rb
255
- - lib/llm/providers/gemini/models.rb
256
- - lib/llm/providers/gemini/request_adapter.rb
257
- - lib/llm/providers/gemini/request_adapter/completion.rb
258
- - lib/llm/providers/gemini/response_adapter.rb
259
- - lib/llm/providers/gemini/response_adapter/completion.rb
260
- - lib/llm/providers/gemini/response_adapter/embedding.rb
261
- - lib/llm/providers/gemini/response_adapter/file.rb
262
- - lib/llm/providers/gemini/response_adapter/files.rb
263
- - lib/llm/providers/gemini/response_adapter/image.rb
264
- - lib/llm/providers/gemini/response_adapter/models.rb
265
- - lib/llm/providers/gemini/response_adapter/web_search.rb
266
- - lib/llm/providers/gemini/stream_parser.rb
301
+ - lib/llm/providers/google.rb
302
+ - lib/llm/providers/google/audio.rb
303
+ - lib/llm/providers/google/error_handler.rb
304
+ - lib/llm/providers/google/files.rb
305
+ - lib/llm/providers/google/images.rb
306
+ - lib/llm/providers/google/models.rb
307
+ - lib/llm/providers/google/request_adapter.rb
308
+ - lib/llm/providers/google/request_adapter/completion.rb
309
+ - lib/llm/providers/google/response_adapter.rb
310
+ - lib/llm/providers/google/response_adapter/completion.rb
311
+ - lib/llm/providers/google/response_adapter/embedding.rb
312
+ - lib/llm/providers/google/response_adapter/file.rb
313
+ - lib/llm/providers/google/response_adapter/files.rb
314
+ - lib/llm/providers/google/response_adapter/image.rb
315
+ - lib/llm/providers/google/response_adapter/models.rb
316
+ - lib/llm/providers/google/response_adapter/web_search.rb
317
+ - lib/llm/providers/google/stream_parser.rb
267
318
  - lib/llm/providers/llamacpp.rb
268
319
  - lib/llm/providers/ollama.rb
269
320
  - lib/llm/providers/ollama/error_handler.rb
@@ -304,6 +355,7 @@ files:
304
355
  - lib/llm/providers/xai.rb
305
356
  - lib/llm/providers/xai/images.rb
306
357
  - lib/llm/providers/zai.rb
358
+ - lib/llm/registry.rb
307
359
  - lib/llm/response.rb
308
360
  - lib/llm/schema.rb
309
361
  - lib/llm/schema/array.rb
@@ -314,11 +366,11 @@ files:
314
366
  - lib/llm/schema/null.rb
315
367
  - lib/llm/schema/number.rb
316
368
  - lib/llm/schema/object.rb
369
+ - lib/llm/schema/parser.rb
317
370
  - lib/llm/schema/string.rb
318
371
  - lib/llm/schema/version.rb
319
372
  - lib/llm/server_tool.rb
320
373
  - lib/llm/session.rb
321
- - lib/llm/session/deserializer.rb
322
374
  - lib/llm/tool.rb
323
375
  - lib/llm/tool/param.rb
324
376
  - lib/llm/tracer.rb
@@ -337,6 +389,7 @@ metadata:
337
389
  homepage_uri: https://github.com/llmrb/llm.rb
338
390
  source_code_uri: https://github.com/llmrb/llm.rb
339
391
  documentation_uri: https://0x1eef.github.io/x/llm.rb
392
+ changelog_uri: https://0x1eef.github.io/x/llm.rb/file.CHANGELOG.html
340
393
  rdoc_options: []
341
394
  require_paths:
342
395
  - lib
@@ -353,8 +406,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
353
406
  requirements: []
354
407
  rubygems_version: 3.6.9
355
408
  specification_version: 4
356
- summary: llm.rb is a zero-dependency Ruby toolkit for Large Language Models that includes
357
- OpenAI, Gemini, Anthropic, xAI (grok), zAI, DeepSeek, Ollama, and LlamaCpp. The
358
- toolkit includes full support for chat, streaming, tool calling, audio, images,
359
- files, and structured outputs.
409
+ summary: llm.rb is a Ruby-centric toolkit for building real LLM-powered systems
410
+ where LLMs are part of your architecture, not just API calls. It gives you explicit
411
+ control over contexts, tools, concurrency, and providers, so you can compose reliable,
412
+ production-ready workflows without hidden abstractions.
360
413
  test_files: []