Module: Rails::Nl2sql

Defined in:
lib/rails/nl2sql.rb,
lib/rails/nl2sql/cli.rb,
lib/rails/nl2sql/railtie.rb,
lib/rails/nl2sql/version.rb,
lib/rails/nl2sql/prompt_builder.rb,
lib/rails/nl2sql/providers/base.rb,
lib/rails/nl2sql/schema_builder.rb,
lib/rails/nl2sql/query_generator.rb,
lib/rails/nl2sql/query_validator.rb,
lib/rails/nl2sql/active_record_extension.rb,
lib/rails/nl2sql/providers/llama_provider.rb,
lib/rails/nl2sql/providers/gemini_provider.rb,
lib/rails/nl2sql/providers/openai_provider.rb,
lib/rails/nl2sql/providers/anthropic_provider.rb

Defined Under Namespace

Modules: ActiveRecordExtension, Providers Classes: CLI, Error, InstallGenerator, Processor, PromptBuilder, QueryGenerator, QueryValidator, Railtie, SchemaBuilder

Constant Summary collapse

VERSION =
"0.2.10"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



20
21
22
# File 'lib/rails/nl2sql.rb', line 20

def api_key
  @api_key
end

.debugObject

Returns the value of attribute debug.



24
25
26
# File 'lib/rails/nl2sql.rb', line 24

def debug
  @debug
end

.max_schema_linesObject

Returns the value of attribute max_schema_lines.



23
24
25
# File 'lib/rails/nl2sql.rb', line 23

def max_schema_lines
  @max_schema_lines
end

.modelObject

Returns the value of attribute model.



21
22
23
# File 'lib/rails/nl2sql.rb', line 21

def model
  @model
end

.providerObject

Returns the value of attribute provider.



22
23
24
# File 'lib/rails/nl2sql.rb', line 22

def provider
  @provider
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Rails::Nl2sql)

    the object that the method was called on



40
41
42
# File 'lib/rails/nl2sql.rb', line 40

def self.configure
  yield self
end

.prompt_templateObject



44
45
46
47
48
# File 'lib/rails/nl2sql.rb', line 44

def self.prompt_template
  # Load the YAML template without evaluating ERB so we can
  # interpolate variables later when building prompts.
  @prompt_template ||= YAML.safe_load(File.read(prompt_template_path))
end

.prompt_template_pathObject



31
32
33
# File 'lib/rails/nl2sql.rb', line 31

def prompt_template_path
  @prompt_template_path || File.expand_path('nl2sql/prompts/default.yml.erb', __dir__)
end

.prompt_template_path=(path) ⇒ Object



26
27
28
29
# File 'lib/rails/nl2sql.rb', line 26

def prompt_template_path=(path)
  @prompt_template = nil
  @prompt_template_path = path
end