Module: LLM::Sequel::Plugin::InstanceMethods
- Defined in:
- lib/llm/sequel/plugin.rb
Constant Summary collapse
Instance Method Summary collapse
- #context_window ⇒ Integer
- #cost ⇒ LLM::Cost
- #functions ⇒ Array<LLM::Function>
- #functions? ⇒ Boolean
- #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
#context_window ⇒ Integer
236 237 238 239 240 |
# File 'lib/llm/sequel/plugin.rb', line 236 def context_window ctx.context_window rescue LLM::NoSuchModelError, LLM::NoSuchRegistryError 0 end |
#functions ⇒ Array<LLM::Function>
208 209 210 |
# File 'lib/llm/sequel/plugin.rb', line 208 def functions ctx.functions end |
#functions? ⇒ Boolean
215 216 217 |
# File 'lib/llm/sequel/plugin.rb', line 215 def functions? ctx.functions? end |
#image_url ⇒ LLM::Object
268 269 270 |
# File 'lib/llm/sequel/plugin.rb', line 268 def image_url(...) ctx.image_url(...) end |
#interrupt! ⇒ nil Also known as: cancel!
252 253 254 |
# File 'lib/llm/sequel/plugin.rb', line 252 def interrupt! ctx.interrupt! end |
#llm ⇒ LLM::Provider
Returns the resolved provider instance for this record.
296 297 298 299 300 301 302 |
# File 'lib/llm/sequel/plugin.rb', line 296 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 |
#local_file ⇒ LLM::Object
275 276 277 |
# File 'lib/llm/sequel/plugin.rb', line 275 def local_file(...) ctx.local_file(...) end |
#messages ⇒ Array<LLM::Message>
192 193 194 |
# File 'lib/llm/sequel/plugin.rb', line 192 def ctx. end |
#mode ⇒ Symbol
185 186 187 |
# File 'lib/llm/sequel/plugin.rb', line 185 def mode ctx.mode end |
#model! ⇒ String
Note:
The bang is used because Sequel reserves ‘model` for the underlying model class on instances.
201 202 203 |
# File 'lib/llm/sequel/plugin.rb', line 201 def model! ctx.model end |
#prompt ⇒ LLM::Prompt Also known as: build_prompt
260 261 262 |
# File 'lib/llm/sequel/plugin.rb', line 260 def prompt(&) ctx.prompt(&) end |
#remote_file ⇒ LLM::Object
282 283 284 |
# File 'lib/llm/sequel/plugin.rb', line 282 def remote_file(...) ctx.remote_file(...) end |
#respond ⇒ LLM::Response
Continues the stored context through the Responses API and flushes it.
169 170 171 172 |
# File 'lib/llm/sequel/plugin.rb', line 169 def respond(...) = self.class. ctx.respond(...).tap { Utils.save(self, ctx, ) } end |
#returns ⇒ Array<LLM::Function::Return>
222 223 224 |
# File 'lib/llm/sequel/plugin.rb', line 222 def returns ctx.returns end |
#talk ⇒ LLM::Response
Continues the stored context with new input and flushes it.
160 161 162 163 |
# File 'lib/llm/sequel/plugin.rb', line 160 def talk(...) = self.class. ctx.talk(...).tap { Utils.save(self, ctx, ) } end |
#tracer ⇒ LLM::Tracer
289 290 291 |
# File 'lib/llm/sequel/plugin.rb', line 289 def tracer ctx.tracer end |
#usage ⇒ LLM::Object
Returns usage from the mapped usage columns.
245 246 247 |
# File 'lib/llm/sequel/plugin.rb', line 245 def usage ctx.usage || LLM::Object.from(input_tokens: 0, output_tokens: 0, total_tokens: 0) end |
#wait ⇒ Array<LLM::Function::Return>
Waits for queued tool work to finish.
178 179 180 |
# File 'lib/llm/sequel/plugin.rb', line 178 def wait(...) ctx.wait(...) end |