Module: LLM::ActiveRecord::ActsAsLLM
- Defined in:
- lib/llm/active_record/acts_as_llm.rb
Overview
ActiveRecord integration for persisting LLM::Context state.
This wrapper maps model columns onto provider selection, model selection, usage accounting, and serialized context data while leaving application- specific concerns such as credentials, associations, and UI shaping to the host app.
Context state can be stored as a JSON string (format: :string, the
default) or as a structured object (format: :json / :jsonb) for
databases such as PostgreSQL that can persist JSON natively.
:json and :jsonb expect a real JSON column type with ActiveRecord
handling JSON typecasting for the model. provider:, context:, and
tracer: can also be configured as symbols that are called on the model.
Defined Under Namespace
Modules: Hooks, InstanceMethods
Instance Method Summary collapse
-
#acts_as_llm(options = EMPTY_HASH) ⇒ void
Installs the
acts_as_llmwrapper on an ActiveRecord model.
Instance Method Details
#acts_as_llm(options = EMPTY_HASH) ⇒ void
This method returns an undefined value.
Installs the acts_as_llm wrapper on an ActiveRecord model.
44 45 46 47 48 49 |
# File 'lib/llm/active_record/acts_as_llm.rb', line 44 def acts_as_llm( = EMPTY_HASH) = DEFAULTS.merge() class_attribute :llm_plugin_options, instance_accessor: false, default: DEFAULTS unless respond_to?(:llm_plugin_options) self. = .freeze extend Hooks end |