Class: SqlGenius::Core::Ai::Config

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

Instance Method Summary collapse

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_keyObject

Returns the value of attribute api_key

Returns:

  • (Object)

    the current value of api_key



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def api_key
  @api_key
end

#auth_styleObject

Returns the value of attribute auth_style

Returns:

  • (Object)

    the current value of auth_style



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def auth_style
  @auth_style
end

#clientObject

Returns the value of attribute client

Returns:

  • (Object)

    the current value of client



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def client
  @client
end

#domain_contextObject

Returns the value of attribute domain_context

Returns:

  • (Object)

    the current value of domain_context



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def domain_context
  @domain_context
end

#endpointObject

Returns the value of attribute endpoint

Returns:

  • (Object)

    the current value of endpoint



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def endpoint
  @endpoint
end

#max_tokensObject

Returns the value of attribute max_tokens

Returns:

  • (Object)

    the current value of max_tokens



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def max_tokens
  @max_tokens
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



21
22
23
# File 'lib/sql_genius/core/ai/config.rb', line 21

def model
  @model
end

#system_contextObject

Returns the value of attribute system_context

Returns:

  • (Object)

    the current value of 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

Returns:

  • (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