Module: LLM::Sequel::Plugin::InstanceMethods
- Defined in:
- lib/llm/sequel/plugin.rb
Constant Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
Calls into the stored context.
- #context_window ⇒ Integer
- #cost ⇒ LLM::Cost
- #functions ⇒ Array<LLM::Function>
- #image_url ⇒ LLM::Object
- #interrupt! ⇒ nil (also: #cancel!)
-
#llm ⇒ LLM::Provider
Returns the resolved provider instance for this record.
- #local_file ⇒ LLM::Object
- #messages ⇒ Array<LLM::Message>
- #mode ⇒ Symbol
- #model! ⇒ String
- #prompt ⇒ LLM::Prompt (also: #build_prompt)
- #remote_file ⇒ LLM::Object
-
#respond ⇒ LLM::Response
Continues the stored context through the Responses API and flushes it.
- #returns ⇒ Array<LLM::Function::Return>
-
#talk ⇒ LLM::Response
Continues the stored context with new input and flushes it.
- #tracer ⇒ LLM::Tracer
-
#usage ⇒ LLM::Object
Returns usage from the mapped usage columns.
-
#wait ⇒ Array<LLM::Function::Return>
Waits for queued tool work to finish.
Instance Method Details
#call ⇒ Object
Calls into the stored context.
189 190 191 |
# File 'lib/llm/sequel/plugin.rb', line 189 def call(...) ctx.call(...) end |
#context_window ⇒ Integer
240 241 242 243 244 |
# File 'lib/llm/sequel/plugin.rb', line 240 def context_window ctx.context_window rescue LLM::NoSuchModelError, LLM::NoSuchRegistryError 0 end |
#functions ⇒ Array<LLM::Function>
219 220 221 |
# File 'lib/llm/sequel/plugin.rb', line 219 def functions ctx.functions end |
#image_url ⇒ LLM::Object
277 278 279 |
# File 'lib/llm/sequel/plugin.rb', line 277 def image_url(...) ctx.image_url(...) end |
#interrupt! ⇒ nil Also known as: cancel!
261 262 263 |
# File 'lib/llm/sequel/plugin.rb', line 261 def interrupt! ctx.interrupt! end |
#llm ⇒ LLM::Provider
Returns the resolved provider instance for this record.
305 306 307 308 309 310 311 312 313 314 |
# File 'lib/llm/sequel/plugin.rb', line 305 def llm = self.class. columns = Utils.columns() provider = self[columns[:provider_column]] kwargs = Utils.(self, [:provider], Plugin::EMPTY_HASH) return @llm if @llm @llm = LLM.method(provider).call(**kwargs) @llm.tracer = Utils.resolve_option(self, [:tracer]) if [:tracer] @llm end |
#local_file ⇒ LLM::Object
284 285 286 |
# File 'lib/llm/sequel/plugin.rb', line 284 def local_file(...) ctx.local_file(...) end |
#messages ⇒ Array<LLM::Message>
203 204 205 |
# File 'lib/llm/sequel/plugin.rb', line 203 def ctx. end |
#mode ⇒ Symbol
196 197 198 |
# File 'lib/llm/sequel/plugin.rb', line 196 def mode ctx.mode end |
#model! ⇒ String
Note:
The bang is used because Sequel reserves ‘model` for the underlying model class on instances.
212 213 214 |
# File 'lib/llm/sequel/plugin.rb', line 212 def model! ctx.model end |
#prompt ⇒ LLM::Prompt Also known as: build_prompt
269 270 271 |
# File 'lib/llm/sequel/plugin.rb', line 269 def prompt(&) ctx.prompt(&) end |
#remote_file ⇒ LLM::Object
291 292 293 |
# File 'lib/llm/sequel/plugin.rb', line 291 def remote_file(...) ctx.remote_file(...) end |
#respond ⇒ LLM::Response
Continues the stored context through the Responses API and flushes it.
172 173 174 175 |
# File 'lib/llm/sequel/plugin.rb', line 172 def respond(...) = self.class. ctx.respond(...).tap { Utils.save(self, ctx, ) } end |
#returns ⇒ Array<LLM::Function::Return>
226 227 228 |
# File 'lib/llm/sequel/plugin.rb', line 226 def returns ctx.returns end |
#talk ⇒ LLM::Response
Continues the stored context with new input and flushes it.
163 164 165 166 |
# File 'lib/llm/sequel/plugin.rb', line 163 def talk(...) = self.class. ctx.talk(...).tap { Utils.save(self, ctx, ) } end |
#tracer ⇒ LLM::Tracer
298 299 300 |
# File 'lib/llm/sequel/plugin.rb', line 298 def tracer ctx.tracer end |
#usage ⇒ LLM::Object
Returns usage from the mapped usage columns.
249 250 251 252 253 254 255 256 |
# File 'lib/llm/sequel/plugin.rb', line 249 def usage columns = Utils.columns(self.class.) LLM::Object.from( input_tokens: self[columns[:input_tokens]] || 0, output_tokens: self[columns[:output_tokens]] || 0, total_tokens: self[columns[:total_tokens]] || 0 ) end |
#wait ⇒ Array<LLM::Function::Return>
Waits for queued tool work to finish.
181 182 183 |
# File 'lib/llm/sequel/plugin.rb', line 181 def wait(...) ctx.wait(...) end |