Module: LLM::ActiveRecord::ActsAsLLM::InstanceMethods
- Defined in:
- lib/llm/active_record/acts_as_llm.rb
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!)
- #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.
98 99 100 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 98 def call(...) ctx.call(...) end |
#context_window ⇒ Integer
148 149 150 151 152 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 148 def context_window ctx.context_window rescue LLM::NoSuchModelError, LLM::NoSuchRegistryError 0 end |
#cost ⇒ LLM::Cost
141 142 143 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 141 def cost ctx.cost end |
#functions ⇒ Array<LLM::Function>
127 128 129 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 127 def functions ctx.functions end |
#image_url ⇒ LLM::Object
184 185 186 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 184 def image_url(...) ctx.image_url(...) end |
#interrupt! ⇒ nil Also known as: cancel!
168 169 170 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 168 def interrupt! ctx.interrupt! end |
#local_file ⇒ LLM::Object
191 192 193 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 191 def local_file(...) ctx.local_file(...) end |
#messages ⇒ Array<LLM::Message>
112 113 114 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 112 def ctx. end |
#mode ⇒ Symbol
105 106 107 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 105 def mode ctx.mode end |
#model! ⇒ String
Note:
The bang keeps the ActiveRecord and Sequel wrappers aligned.
120 121 122 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 120 def model! ctx.model end |
#prompt ⇒ LLM::Prompt Also known as: build_prompt
176 177 178 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 176 def prompt(&) ctx.prompt(&) end |
#remote_file ⇒ LLM::Object
198 199 200 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 198 def remote_file(...) ctx.remote_file(...) end |
#respond ⇒ LLM::Response
Continues the stored context through the Responses API and flushes it.
82 83 84 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 82 def respond(...) ctx.respond(...).tap { flush } end |
#returns ⇒ Array<LLM::Function::Return>
134 135 136 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 134 def returns ctx.returns end |
#talk ⇒ LLM::Response
Continues the stored context with new input and flushes it.
74 75 76 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 74 def talk(...) ctx.talk(...).tap { flush } end |
#tracer ⇒ LLM::Tracer
205 206 207 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 205 def tracer ctx.tracer end |
#usage ⇒ LLM::Object
Returns usage from the mapped usage columns.
157 158 159 160 161 162 163 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 157 def usage 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.
90 91 92 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 90 def wait(...) ctx.wait(...) end |