Module: AsktiveRecord
- Extended by:
- Service::ClassMethods
- Defined in:
- lib/asktive_record.rb,
lib/asktive_record/error.rb,
lib/asktive_record/model.rb,
lib/asktive_record/query.rb,
lib/asktive_record/prompt.rb,
lib/asktive_record/service.rb,
lib/asktive_record/version.rb,
lib/asktive_record/llm_service.rb,
lib/asktive_record/configuration.rb,
lib/generators/asktive_record/setup_generator.rb,
lib/generators/asktive_record/install_generator.rb
Overview
The AsktiveRecord module provides natural language querying capabilities and service/model extensions for ActiveRecord-like classes.
Defined Under Namespace
Modules: Generators, Model, Service Classes: ApiError, Configuration, ConfigurationError, Error, LlmService, Prompt, Query, QueryExecutionError, QueryGenerationError, SanitizationError
Constant Summary collapse
- VERSION =
"0.1.7"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.ask(natural_language_query, options = {}) ⇒ Object
Class method to allow direct querying from AsktiveRecord module.
- .configure {|configuration| ... } ⇒ Object
-
.included(base) ⇒ Object
Main entry point for ApplicationRecord to include AsktiveRecord behavior.
Methods included from Service::ClassMethods
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
15 16 17 |
# File 'lib/asktive_record.rb', line 15 def configuration @configuration end |
Class Method Details
.ask(natural_language_query, options = {}) ⇒ Object
Class method to allow direct querying from AsktiveRecord module
36 37 38 39 |
# File 'lib/asktive_record.rb', line 36 def self.ask(natural_language_query, = {}) # Delegate to the Service module's implementation Service::ClassMethods.instance_method(:ask).bind(self).call(natural_language_query, ) end |
.configure {|configuration| ... } ⇒ Object
18 19 20 21 |
# File 'lib/asktive_record.rb', line 18 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
.included(base) ⇒ Object
Main entry point for ApplicationRecord to include AsktiveRecord behavior
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/asktive_record.rb', line 24 def self.included(base) # If the base class is a service class (inherits from AsktiveRecord directly), # extend it with Service module methods if base.superclass == Object || base.superclass.name == "Object" base.extend(Service::ClassMethods) else # Otherwise, it's likely an ActiveRecord model, so extend with Model module base.extend(Model::ClassMethods) end end |