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/lib/llm.rb CHANGED
@@ -37,6 +37,7 @@ module LLM
37
37
  require_relative "llm/server_tool"
38
38
  require_relative "llm/mcp"
39
39
  require_relative "llm/a2a"
40
+ require_relative "llm/uridata"
40
41
 
41
42
  ##
42
43
  # Thread-safe monitors for different contexts
@@ -154,6 +155,14 @@ module LLM
154
155
  LLM::OpenAI.new(**)
155
156
  end
156
157
 
158
+ ##
159
+ # @param key (see LLM::Provider#initialize)
160
+ # @return (see LLM::DeepInfra#initialize)
161
+ def deepinfra(**)
162
+ lock(:require) { require_relative "llm/providers/deepinfra" unless defined?(LLM::DeepInfra) }
163
+ LLM::DeepInfra.new(**)
164
+ end
165
+
157
166
  ##
158
167
  # @param (see LLM::Bedrock#initialize)
159
168
  # @return (see LLM::Bedrock#initialize)
data/llm.gemspec CHANGED
@@ -5,27 +5,14 @@ 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 = ["Robert (0x1eef)", "Antar Azri", "Rodrigo Serrano"]
8
+ spec.authors = ["bsdrobert", "Antar Azri", "Rodrigo Serrano"]
9
9
  spec.email = ["robert@r.uby.dev"]
10
10
 
11
11
  spec.summary = "Ruby's capable AI runtime"
12
- spec.description = <<~DESC
13
- llm.rb is Ruby's capable AI runtime.
14
-
15
- It runs on Ruby's standard library by default. loads optional pieces
16
- only when needed, and offers a single runtime for providers, agents,
17
- tools, skills, MCP, A2A (Agent2Agent), RAG (vector stores & embeddings),
18
- streaming, files, and persisted state. As a bonus, llm.rb is also available
19
- for mruby.
20
-
21
- It supports OpenAI, OpenAI-compatible endpoints, Anthropic, Google
22
- Gemini, DeepSeek, xAI, Z.ai, AWS Bedrock, Ollama, and llama.cpp. It
23
- also includes built-in ActiveRecord and Sequel support, plus concurrent
24
- tool execution through threads, tasks (via async gem), fibers, ractors,
25
- and fork (via xchan.rb gem).
26
- DESC
27
-
28
- spec.license = "0BSD"
12
+ spec.description = "llm.rb is not a library, framework or toolkit but " \
13
+ "an advanced runtime for building highly capable AI " \
14
+ "applications on CRuby."
15
+ spec.license = "BUSL-1.1"
29
16
  spec.required_ruby_version = ">= 3.3.0"
30
17
 
31
18
  spec.homepage = "https://r.uby.dev/llm/"