llm.rb 4.18.0 → 4.19.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42357f605b8995c24722c0a2d285d98de0e99fe6f9687e2f4451339dcfbc2e87
4
- data.tar.gz: 2953c742deeec6dc7c7acc9ed77f4520846a92299a4df94e415416d5c623033c
3
+ metadata.gz: 18c28f7b5ec05ad6f9629a6a328be4dd377a6efb43a13c2ac99dd0abf015b1f8
4
+ data.tar.gz: a0c03de362af927d090a6bc09b2170ddb7eb5766f26b1f8f657a37bd10d0162e
5
5
  SHA512:
6
- metadata.gz: 534fad616562768b0a851142f411117634d824a92187577d6baad4427c1e0eddf7a765dbfe3b662f76ba52011d760803793473a1881b4f69b8f4c7f9fc16bdc3
7
- data.tar.gz: f1d90ad7f7b71f4817fcfa494f48a4e7f189560674d7b86d618f1f4e217e2a34189e15156e71ecdcfffe81e9588315f4759a82f4ec3eaed3846a29c77a906a66
6
+ metadata.gz: c8255c9435bec0a7a06fb427f3a1ade4e0b5ce47f111d33f4cbf1218fce1f89f1438c71980b52c3de7542563690f08bcf54417cb7d427720248a22f8b30a12fb
7
+ data.tar.gz: 54aebea9a5f8ac687163d3df3c2c3d31091f8f8d6d96b5ad242199daa8fdfb8e5e17e2b626f7a682158ba9251202362fc9fddaed6c08e6eb8399c8b0509659d8
data/CHANGELOG.md CHANGED
@@ -2,8 +2,39 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ Changes since `v4.19.0`.
6
+
7
+ ## v4.19.0
8
+
5
9
  Changes since `v4.18.0`.
6
10
 
11
+ This release tightens the ActiveRecord and ORM integration layer. It adds
12
+ inline agent DSL blocks to `acts_as_agent` so agent defaults can be defined
13
+ where the wrapper is declared, and it exposes the resolved provider through
14
+ public `llm` methods on the ActiveRecord and Sequel wrappers.
15
+
16
+ ### Change
17
+
18
+ * **Make ORM provider access public through `llm`** <br>
19
+ Expose the resolved provider on the Sequel plugin and the ActiveRecord
20
+ `acts_as_llm` / `acts_as_agent` wrappers through a public `llm` method.
21
+
22
+ * **Allow inline agent DSL blocks in `acts_as_agent`** <br>
23
+ Let ActiveRecord models configure `model`, `tools`, `schema`,
24
+ `instructions`, and `concurrency` directly inside the `acts_as_agent`
25
+ declaration block.
26
+
27
+ ## v4.18.0
28
+
29
+ Changes since `v4.17.0`.
30
+
31
+ This release improves tracing and tool execution behavior across llm.rb.
32
+ It makes provider tracers default to the provider instance, adds
33
+ `LLM::Provider#with_tracer` for scoped overrides, restores tool tracing for
34
+ concurrent and streamed tool execution, extends streamed tracing to MCP tools,
35
+ and adds symbol-based ORM option hooks alongside experimental ractor tool
36
+ concurrency.
37
+
7
38
  ### Change
8
39
 
9
40
  * **Make provider tracers default to the provider instance** <br>
@@ -42,17 +73,6 @@ Changes since `v4.18.0`.
42
73
  is especially useful for CPU-bound tools, while `:task`, `:fiber`, or
43
74
  `:thread` may be a better fit for I/O-bound work.
44
75
 
45
- ## v4.18.0
46
-
47
- Changes since `v4.17.0`.
48
-
49
- This release improves tracing and tool execution behavior across llm.rb.
50
- It makes provider tracers default to the provider instance, adds
51
- `LLM::Provider#with_tracer` for scoped overrides, restores tool tracing for
52
- concurrent and streamed tool execution, extends streamed tracing to MCP tools,
53
- and adds symbol-based ORM option hooks alongside experimental ractor tool
54
- concurrency.
55
-
56
76
  ## v4.17.0
57
77
 
58
78
  Changes since `v4.16.1`.
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <p align="center">
5
5
  <a href="https://0x1eef.github.io/x/llm.rb?rebuild=1"><img src="https://img.shields.io/badge/docs-0x1eef.github.io-blue.svg" alt="RubyDoc"></a>
6
6
  <a href="https://opensource.org/license/0bsd"><img src="https://img.shields.io/badge/License-0BSD-orange.svg?" alt="License"></a>
7
- <a href="https://github.com/llmrb/llm.rb/tags"><img src="https://img.shields.io/badge/version-4.18.0-green.svg?" alt="Version"></a>
7
+ <a href="https://github.com/llmrb/llm.rb/tags"><img src="https://img.shields.io/badge/version-4.19.0-green.svg?" alt="Version"></a>
8
8
  </p>
9
9
 
10
10
  ## About
@@ -254,11 +254,18 @@ require "active_record"
254
254
  require "llm/active_record"
255
255
 
256
256
  class Ticket < ApplicationRecord
257
- acts_as_agent provider: -> { { key: ENV["#{provider.upcase}_SECRET"], persistent: true } }
258
- model "gpt-5.4-mini"
259
- instructions "You are a concise support assistant."
260
- tools SearchDocs, Escalate
261
- concurrency :thread
257
+ acts_as_agent provider: :set_provider do
258
+ model "gpt-5.4-mini"
259
+ instructions "You are a concise support assistant."
260
+ tools SearchDocs, Escalate
261
+ concurrency :thread
262
+ end
263
+
264
+ private
265
+
266
+ def set_provider
267
+ { key: ENV["#{provider.upcase}_SECRET"], persistent: true }
268
+ end
262
269
  end
263
270
 
264
271
  ticket = Ticket.create!(provider: "openai", model: "gpt-5.4-mini")
@@ -71,18 +71,21 @@ module LLM::ActiveRecord
71
71
  # @option options [Proc, Symbol, LLM::Tracer, nil] :tracer
72
72
  # Optional tracer, method name, or proc that resolves to one and is
73
73
  # assigned through `llm.tracer = ...` on the resolved provider.
74
+ # @yield
75
+ # Evaluated in the model class after the wrapper is installed, so agent
76
+ # DSL methods such as `model`, `tools`, `schema`, `instructions`, and
77
+ # `concurrency` can be configured inline.
74
78
  # @return [void]
75
- def acts_as_agent(options = EMPTY_HASH)
79
+ def acts_as_agent(options = EMPTY_HASH, &block)
76
80
  options = DEFAULTS.merge(options)
77
81
  usage_columns = DEFAULT_USAGE_COLUMNS.merge(options[:usage_columns] || EMPTY_HASH)
78
82
  class_attribute :llm_agent_options, instance_accessor: false, default: DEFAULTS unless respond_to?(:llm_agent_options)
79
83
  self.llm_agent_options = options.merge(usage_columns: usage_columns.freeze).freeze
80
84
  extend Hooks
85
+ class_exec(&block) if block
81
86
  end
82
87
 
83
88
  module InstanceMethods
84
- private
85
-
86
89
  ##
87
90
  # Returns the resolved provider instance for this record.
88
91
  # @return [LLM::Provider]
@@ -96,6 +99,8 @@ module LLM::ActiveRecord
96
99
  @llm
97
100
  end
98
101
 
102
+ private
103
+
99
104
  ##
100
105
  # @return [LLM::Agent]
101
106
  def ctx
@@ -206,8 +206,6 @@ module LLM::ActiveRecord
206
206
  ctx.tracer
207
207
  end
208
208
 
209
- private
210
-
211
209
  ##
212
210
  # Returns the resolved provider instance for this record.
213
211
  # @return [LLM::Provider]
@@ -221,6 +219,8 @@ module LLM::ActiveRecord
221
219
  @llm
222
220
  end
223
221
 
222
+ private
223
+
224
224
  ##
225
225
  # @return [LLM::Context]
226
226
  def ctx
@@ -224,8 +224,6 @@ module LLM::Sequel
224
224
  ctx.tracer
225
225
  end
226
226
 
227
- private
228
-
229
227
  ##
230
228
  # Returns the resolved provider instance for this record.
231
229
  # @return [LLM::Provider]
@@ -239,6 +237,8 @@ module LLM::Sequel
239
237
  @llm
240
238
  end
241
239
 
240
+ private
241
+
242
242
  ##
243
243
  # @return [LLM::Context]
244
244
  def ctx
data/lib/llm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLM
4
- VERSION = "4.18.0"
4
+ VERSION = "4.19.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.18.0
4
+ version: 4.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antar Azri