Class: AIRecordFinder::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_record_finder/configuration.rb

Overview

Runtime configuration for AIRecordFinder.

Constant Summary collapse

DEFAULT_PROVIDER =
:openai
DEFAULT_MAX_LIMIT =
100
DEFAULT_TIMEOUT =
15
DEFAULT_MAX_TOKENS =
1024
DEFAULT_ANTHROPIC_VERSION =
"2023-06-01"
PROVIDER_DEFAULTS =

Per-provider defaults for endpoint and model. Used only when the corresponding setting is not explicitly assigned.

{
  openai: {
    api_base_url: "https://api.openai.com/v1",
    model_name: "gpt-4o-mini"
  },
  anthropic: {
    api_base_url: "https://api.anthropic.com/v1",
    model_name: "claude-sonnet-4-6"
  }
}.freeze
DEFAULT_MODEL_NAME =

Backwards-compatible constants (OpenAI defaults).

PROVIDER_DEFAULTS[:openai][:model_name]
DEFAULT_API_BASE_URL =
PROVIDER_DEFAULTS[:openai][:api_base_url]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ai_record_finder/configuration.rb', line 36

def initialize
  @api_key = @model_name = @api_base_url = nil
  @provider = DEFAULT_PROVIDER
  @max_limit = DEFAULT_MAX_LIMIT
  @allowed_models = []
  @request_timeout = DEFAULT_TIMEOUT
  @temperature = 0.0
  @allowed_associations = {}
  @max_tokens = DEFAULT_MAX_TOKENS
  @anthropic_version = DEFAULT_ANTHROPIC_VERSION
end

Instance Attribute Details

#allowed_associationsObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def allowed_associations
  @allowed_associations
end

#allowed_modelsObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def allowed_models
  @allowed_models
end

#anthropic_versionObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def anthropic_version
  @anthropic_version
end

#api_base_urlObject

Explicit base URL, or the provider default when unset.



59
60
61
# File 'lib/ai_record_finder/configuration.rb', line 59

def api_base_url
  @api_base_url || provider_default(:api_base_url)
end

#api_keyObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def api_key
  @api_key
end

#max_limitObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def max_limit
  @max_limit
end

#max_tokensObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def max_tokens
  @max_tokens
end

#model_nameObject

Explicit model name, or the provider default when unset.



54
55
56
# File 'lib/ai_record_finder/configuration.rb', line 54

def model_name
  @model_name || provider_default(:model_name)
end

#providerObject

Normalized provider symbol (e.g. :openai, :anthropic).



49
50
51
# File 'lib/ai_record_finder/configuration.rb', line 49

def provider
  @provider.to_s.strip.downcase.to_sym
end

#request_timeoutObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def request_timeout
  @request_timeout
end

#temperatureObject

‘max_tokens` and `anthropic_version` are consumed only by the Anthropic adapter; the OpenAI adapter ignores them.



31
32
33
# File 'lib/ai_record_finder/configuration.rb', line 31

def temperature
  @temperature
end