Class: SqlGenius::Core::Ai::Config
- Inherits:
-
Struct
- Object
- Struct
- SqlGenius::Core::Ai::Config
- Defined in:
- lib/sql_genius/core/ai/config.rb
Overview
Keyword-init value object holding all the AI settings a Client needs. Passed explicitly to every AI service constructor — no module-level globals.
Fields:
client - optional callable; when set, bypasses HTTP.
Signature: #call(messages:, temperature:) -> Hash
endpoint - HTTPS URL of the chat completions endpoint
api_key - API key (used as Bearer or api-key header)
model - model name passed in the request body
auth_style - :bearer or :api_key
system_context - optional domain context string that services
append to their system prompts
domain_context - optional host-app context string interpolated into
AI system prompts (e.g. "Rails app, no FKs")
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#auth_style ⇒ Object
Returns the value of attribute auth_style.
-
#client ⇒ Object
Returns the value of attribute client.
-
#domain_context ⇒ Object
Returns the value of attribute domain_context.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
-
#model ⇒ Object
Returns the value of attribute model.
-
#system_context ⇒ Object
Returns the value of attribute system_context.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(**kwargs) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(**kwargs) ⇒ Config
Returns a new instance of Config.
32 33 34 35 |
# File 'lib/sql_genius/core/ai/config.rb', line 32 def initialize(**kwargs) super(domain_context: "", max_tokens: 4096, **kwargs) freeze end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def api_key @api_key end |
#auth_style ⇒ Object
Returns the value of attribute auth_style
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def auth_style @auth_style end |
#client ⇒ Object
Returns the value of attribute client
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def client @client end |
#domain_context ⇒ Object
Returns the value of attribute domain_context
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def domain_context @domain_context end |
#endpoint ⇒ Object
Returns the value of attribute endpoint
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def endpoint @endpoint end |
#max_tokens ⇒ Object
Returns the value of attribute max_tokens
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def max_tokens @max_tokens end |
#model ⇒ Object
Returns the value of attribute model
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def model @model end |
#system_context ⇒ Object
Returns the value of attribute system_context
21 22 23 |
# File 'lib/sql_genius/core/ai/config.rb', line 21 def system_context @system_context end |
Instance Method Details
#enabled? ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/sql_genius/core/ai/config.rb', line 37 def enabled? return true if client return false if endpoint.nil? || endpoint.to_s.empty? return false if api_key.nil? || api_key.to_s.empty? true end |