Module: LLM::ActiveRecord::ActsAsAgent::InstanceMethods

Defined in:
lib/llm/active_record/acts_as_agent.rb

Instance Method Summary collapse

Instance Method Details

#llmLLM::Provider

Returns the resolved provider instance for this record.

Returns:



93
94
95
96
97
98
99
100
101
102
# File 'lib/llm/active_record/acts_as_agent.rb', line 93

def llm
  options = self.class.llm_plugin_options
  columns = Utils.columns(options)
  provider = self[columns[:provider_column]]
  kwargs = Utils.resolve_options(self, options[:provider], ActsAsAgent::EMPTY_HASH)
  return @llm if @llm
  @llm = LLM.method(provider).call(**kwargs)
  @llm.tracer = Utils.resolve_option(self, options[:tracer]) if options[:tracer]
  @llm
end