Module: LLM::Sequel::Plugin::InstanceMethods
- Defined in:
- lib/llm/sequel/plugin.rb
Constant Summary collapse
Instance Method Summary collapse
-
#unwrap! ⇒ LLM::Context, LLM::Agent
Returns the runtime this record wraps: an LLM::Context for
plugin :llm, and an LLM::Agent forplugin :agent. -
#ask ⇒ LLM::Response
Continues the stored context with new input.
-
#wait ⇒ Array<LLM::Function::Return>
Waits for queued tool work to finish.
- #mode ⇒ Symbol
- #messages ⇒ LLM::Buffer
- #messages! ⇒ LLM::Buffer
- #model! ⇒ String
- #pending_functions ⇒ Array<LLM::Function>
- #pending_functions? ⇒ Boolean
- #returns ⇒ Array<LLM::Function::Return>
- #cost ⇒ LLM::Cost
- #context_window ⇒ Integer
-
#context_used ⇒ Integer
Returns how many tokens have been used within the context window.
-
#context_usage ⇒ Rational?
Returns context window usage as a Rational.
-
#token_usage ⇒ LLM::Usage
(also: #usage)
Returns usage from the mapped usage columns.
- #interrupt! ⇒ nil (also: #cancel!)
- #prompt ⇒ LLM::Prompt (also: #build_prompt)
- #image_url ⇒ LLM::Object
- #local_file ⇒ LLM::Object
- #remote_file ⇒ LLM::Object
- #tracer ⇒ LLM::Tracer
-
#llm ⇒ LLM::Provider
Returns the resolved provider instance for this record.
-
#talk ⇒ LLM::Response
Continues the stored context with new input.
Instance Method Details
#unwrap! ⇒ LLM::Context, LLM::Agent
Returns the runtime this record wraps: an
LLM::Context for plugin :llm, and an
LLM::Agent for plugin :agent. The runtime is
memoized, so every call returns the same object.
347 348 349 |
# File 'lib/llm/sequel/plugin.rb', line 347 def unwrap! __context__ end |
#ask ⇒ LLM::Response
Continues the stored context with new input.
The conversation is saved by LLM::Step at each request.
177 178 179 |
# File 'lib/llm/sequel/plugin.rb', line 177 def ask(...) __context__.ask(...) end |
#wait ⇒ Array<LLM::Function::Return>
Waits for queued tool work to finish.
185 186 187 |
# File 'lib/llm/sequel/plugin.rb', line 185 def wait(...) __context__.wait(...) end |
#mode ⇒ Symbol
192 193 194 |
# File 'lib/llm/sequel/plugin.rb', line 192 def mode __context__.mode end |
#messages ⇒ LLM::Buffer
There is no view over the jsonb column on this side, so a record always loads the runtime to answer this - unlike ActiveRecord, where a jsonb record reads the column directly. The two wrappers are written to mirror each other, and this is the one place they do not.
204 205 206 |
# File 'lib/llm/sequel/plugin.rb', line 204 def __context__. end |
#messages! ⇒ LLM::Buffer
The same call #messages makes here, and here for the sake of the name: on ActiveRecord the two differ for a jsonb record, and a wrapper that answered to a name the other one does not is the next reader's surprise.
215 216 217 |
# File 'lib/llm/sequel/plugin.rb', line 215 def __context__. end |
#model! ⇒ String
The bang is used because Sequel reserves model for the
underlying model class on instances.
224 225 226 |
# File 'lib/llm/sequel/plugin.rb', line 224 def model! __context__.model end |
#pending_functions ⇒ Array<LLM::Function>
231 232 233 |
# File 'lib/llm/sequel/plugin.rb', line 231 def pending_functions __context__.pending_functions end |
#pending_functions? ⇒ Boolean
238 239 240 |
# File 'lib/llm/sequel/plugin.rb', line 238 def pending_functions? __context__.pending_functions? end |
#returns ⇒ Array<LLM::Function::Return>
245 246 247 |
# File 'lib/llm/sequel/plugin.rb', line 245 def returns __context__.returns end |
#cost ⇒ LLM::Cost
252 253 254 |
# File 'lib/llm/sequel/plugin.rb', line 252 def cost __context__.cost end |
#context_window ⇒ Integer
259 260 261 |
# File 'lib/llm/sequel/plugin.rb', line 259 def context_window __context__.context_window end |
#context_used ⇒ Integer
Returns how many tokens have been used within the context window
267 268 269 |
# File 'lib/llm/sequel/plugin.rb', line 267 def context_used __context__.context_used end |
#context_usage ⇒ Rational?
Returns context window usage as a Rational
274 275 276 |
# File 'lib/llm/sequel/plugin.rb', line 274 def context_usage __context__.context_usage end |
#token_usage ⇒ LLM::Usage Also known as: usage
Returns usage from the mapped usage columns.
281 282 283 |
# File 'lib/llm/sequel/plugin.rb', line 281 def token_usage __context__.token_usage end |
#interrupt! ⇒ nil Also known as: cancel!
289 290 291 |
# File 'lib/llm/sequel/plugin.rb', line 289 def interrupt! __context__.interrupt! end |
#prompt ⇒ LLM::Prompt Also known as: build_prompt
297 298 299 |
# File 'lib/llm/sequel/plugin.rb', line 297 def prompt(&) __context__.prompt(&) end |
#image_url ⇒ LLM::Object
305 306 307 |
# File 'lib/llm/sequel/plugin.rb', line 305 def image_url(...) __context__.image_url(...) end |
#local_file ⇒ LLM::Object
312 313 314 |
# File 'lib/llm/sequel/plugin.rb', line 312 def local_file(...) __context__.local_file(...) end |
#remote_file ⇒ LLM::Object
319 320 321 |
# File 'lib/llm/sequel/plugin.rb', line 319 def remote_file(...) __context__.remote_file(...) end |
#tracer ⇒ LLM::Tracer
326 327 328 |
# File 'lib/llm/sequel/plugin.rb', line 326 def tracer __context__.tracer end |
#llm ⇒ LLM::Provider
Returns the resolved provider instance for this record.
333 334 335 336 337 338 339 |
# File 'lib/llm/sequel/plugin.rb', line 333 def llm = self.class. return @llm if @llm @llm = Utils.resolve_provider(self, , Plugin::EMPTY_HASH) @llm.tracer = Utils.resolve_option(self, [:tracer]) if [:tracer] @llm end |
#talk ⇒ LLM::Response
Continues the stored context with new input.
The conversation is saved by LLM::Step at each request.
167 168 169 |
# File 'lib/llm/sequel/plugin.rb', line 167 def talk(...) __context__.talk(...) end |