Class: AsktiveRecord::Configuration
- Inherits:
-
Object
- Object
- AsktiveRecord::Configuration
- Defined in:
- lib/asktive_record/configuration.rb
Overview
Configuration class for AsktiveRecord This class holds the configuration settings for the LLM provider, API key, model name, database schema path, logging preferences, and adapter settings.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#cache_enabled ⇒ Object
Returns the value of attribute cache_enabled.
-
#db_schema_path ⇒ Object
Returns the value of attribute db_schema_path.
-
#llm_api_key ⇒ Object
Returns the value of attribute llm_api_key.
-
#llm_model_name ⇒ Object
Returns the value of attribute llm_model_name.
-
#llm_provider ⇒ Object
Returns the value of attribute llm_provider.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
-
#read_only ⇒ Object
Returns the value of attribute read_only.
-
#skip_dump_schema ⇒ Object
Returns the value of attribute skip_dump_schema.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#resolved_adapter ⇒ AsktiveRecord::Adapters::Base
Builds and returns the appropriate adapter based on configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/asktive_record/configuration.rb', line 12 def initialize @llm_provider = :openai # Default LLM provider @llm_api_key = nil @llm_model_name = "gpt-4o-mini" # Default model for OpenAI (gpt-3.5-turbo is deprecated) @db_schema_path = "db/schema.rb" # Default path for Rails schema file @skip_dump_schema = false # Default is to not skip schema dump @logger = nil # Will use AsktiveRecord::Log default if nil @read_only = true # Default to read-only mode (SELECT only) @adapter = nil # Will be built from llm_provider if nil @temperature = 0.2 # Default temperature for LLM @max_tokens = 250 # Default max tokens for LLM response @cache_enabled = false # Disabled by default end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def adapter @adapter end |
#cache_enabled ⇒ Object
Returns the value of attribute cache_enabled.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def cache_enabled @cache_enabled end |
#db_schema_path ⇒ Object
Returns the value of attribute db_schema_path.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def db_schema_path @db_schema_path end |
#llm_api_key ⇒ Object
Returns the value of attribute llm_api_key.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def llm_api_key @llm_api_key end |
#llm_model_name ⇒ Object
Returns the value of attribute llm_model_name.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def llm_model_name @llm_model_name end |
#llm_provider ⇒ Object
Returns the value of attribute llm_provider.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def llm_provider @llm_provider end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def logger @logger end |
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def max_tokens @max_tokens end |
#read_only ⇒ Object
Returns the value of attribute read_only.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def read_only @read_only end |
#skip_dump_schema ⇒ Object
Returns the value of attribute skip_dump_schema.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def skip_dump_schema @skip_dump_schema end |
#temperature ⇒ Object
Returns the value of attribute temperature.
8 9 10 |
# File 'lib/asktive_record/configuration.rb', line 8 def temperature @temperature end |
Instance Method Details
#resolved_adapter ⇒ AsktiveRecord::Adapters::Base
Builds and returns the appropriate adapter based on configuration. If a custom adapter is set, returns it directly. Otherwise, builds one from llm_provider setting.
31 32 33 34 35 |
# File 'lib/asktive_record/configuration.rb', line 31 def resolved_adapter return @adapter if @adapter build_adapter_from_provider end |