Class: AsktiveRecord::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#adapterObject

Returns the value of attribute adapter.



8
9
10
# File 'lib/asktive_record/configuration.rb', line 8

def adapter
  @adapter
end

#cache_enabledObject

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_pathObject

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_keyObject

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_nameObject

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_providerObject

Returns the value of attribute llm_provider.



8
9
10
# File 'lib/asktive_record/configuration.rb', line 8

def llm_provider
  @llm_provider
end

#loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/asktive_record/configuration.rb', line 8

def logger
  @logger
end

#max_tokensObject

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_onlyObject

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_schemaObject

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

#temperatureObject

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_adapterAsktiveRecord::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.

Returns:



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