Class: SqlChatbot::Configuration
- Inherits:
-
Object
- Object
- SqlChatbot::Configuration
- Defined in:
- lib/sql_chatbot/configuration.rb
Constant Summary collapse
- PROVIDER_PRESETS =
{ "openai" => { base_url: "https://api.openai.com/v1", model: "gpt-4o-mini" }, "groq" => { base_url: "https://api.groq.com/openai/v1", model: "llama-3.3-70b-versatile" }, "ollama" => { base_url: "http://localhost:11434/v1", model: "llama3.1:8b" }, }.freeze
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#allowed_origins ⇒ Object
Returns the value of attribute allowed_origins.
-
#code_paths ⇒ Object
Returns the value of attribute code_paths.
-
#custom_context ⇒ Object
Returns the value of attribute custom_context.
-
#default_filters ⇒ Object
Returns the value of attribute default_filters.
-
#grammar_confidence_threshold ⇒ Object
Returns the value of attribute grammar_confidence_threshold.
-
#grammar_enabled ⇒ Object
Returns the value of attribute grammar_enabled.
-
#grammar_miss_log_path ⇒ Object
Returns the value of attribute grammar_miss_log_path.
-
#llm_api_key ⇒ Object
Returns the value of attribute llm_api_key.
-
#llm_base_url ⇒ Object
Returns the value of attribute llm_base_url.
-
#llm_model ⇒ Object
Returns the value of attribute llm_model.
-
#llm_provider ⇒ Object
Returns the value of attribute llm_provider.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#token_lifetime ⇒ Object
Returns the value of attribute token_lifetime.
-
#token_secret ⇒ Object
Returns the value of attribute token_secret.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Hash — custom user-word -> entity-name mappings overriding auto-detection.
- #resolved_api_key ⇒ Object
- #resolved_base_url ⇒ Object
- #resolved_model ⇒ Object
- #resolved_token_secret ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Hash — custom user-word -> entity-name mappings overriding auto-detection.
Example: { "customer" => "account_user" } when Saleor's "customers"
live in account_user. Always wins over auto-detected aliases on conflict.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sql_chatbot/configuration.rb', line 26 def initialize @llm_provider = "openai" @code_paths = ["./app"] @token_lifetime = 900 @_resolved_token_secret = nil @grammar_enabled = true @grammar_confidence_threshold = 0.7 @grammar_miss_log_path = nil @default_filters = {} @aliases = {} end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def aliases @aliases end |
#allowed_origins ⇒ Object
Returns the value of attribute allowed_origins.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def allowed_origins @allowed_origins end |
#code_paths ⇒ Object
Returns the value of attribute code_paths.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def code_paths @code_paths end |
#custom_context ⇒ Object
Returns the value of attribute custom_context.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def custom_context @custom_context end |
#default_filters ⇒ Object
Returns the value of attribute default_filters.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def default_filters @default_filters end |
#grammar_confidence_threshold ⇒ Object
Returns the value of attribute grammar_confidence_threshold.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def grammar_confidence_threshold @grammar_confidence_threshold end |
#grammar_enabled ⇒ Object
Returns the value of attribute grammar_enabled.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def grammar_enabled @grammar_enabled end |
#grammar_miss_log_path ⇒ Object
Returns the value of attribute grammar_miss_log_path.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def grammar_miss_log_path @grammar_miss_log_path end |
#llm_api_key ⇒ Object
Returns the value of attribute llm_api_key.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def llm_api_key @llm_api_key end |
#llm_base_url ⇒ Object
Returns the value of attribute llm_base_url.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def llm_base_url @llm_base_url end |
#llm_model ⇒ Object
Returns the value of attribute llm_model.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def llm_model @llm_model end |
#llm_provider ⇒ Object
Returns the value of attribute llm_provider.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def llm_provider @llm_provider end |
#secret ⇒ Object
Returns the value of attribute secret.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def secret @secret end |
#token_lifetime ⇒ Object
Returns the value of attribute token_lifetime.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def token_lifetime @token_lifetime end |
#token_secret ⇒ Object
Returns the value of attribute token_secret.
11 12 13 |
# File 'lib/sql_chatbot/configuration.rb', line 11 def token_secret @token_secret end |
Instance Method Details
#resolved_api_key ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/sql_chatbot/configuration.rb', line 50 def resolved_api_key llm_api_key || ENV["LLM_API_KEY"] || ENV["OPENAI_API_KEY"] || ENV["GROQ_API_KEY"] || (llm_provider == "ollama" ? "ollama" : nil) end |
#resolved_base_url ⇒ Object
42 43 44 |
# File 'lib/sql_chatbot/configuration.rb', line 42 def resolved_base_url llm_base_url || PROVIDER_PRESETS.dig(llm_provider, :base_url) || PROVIDER_PRESETS["openai"][:base_url] end |
#resolved_model ⇒ Object
46 47 48 |
# File 'lib/sql_chatbot/configuration.rb', line 46 def resolved_model llm_model || PROVIDER_PRESETS.dig(llm_provider, :model) || PROVIDER_PRESETS["openai"][:model] end |
#resolved_token_secret ⇒ Object
38 39 40 |
# File 'lib/sql_chatbot/configuration.rb', line 38 def resolved_token_secret @_resolved_token_secret ||= (@token_secret || ENV["CHATBOT_TOKEN_SECRET"] || SecureRandom.hex(32)) end |