Class: LittleGhost::DefaultModelRegistry
- Inherits:
-
ModelRegistry
- Object
- ModelRegistry
- LittleGhost::DefaultModelRegistry
- Defined in:
- lib/little_ghost/default_model_registry.rb
Overview
Supplies LittleGhost's ready-to-use model selection. The registry maps the
default role to GPT-5.6 Terra on OpenRouter or OpenAI and keeps the selected
provider stable for its runtime.
Prefixed credentials take precedence over conventional provider variables:
LITTLEGHOST_OPENROUTER_API_KEYLITTLEGHOST_OPENAI_API_KEYOPENROUTER_API_KEYOPENAI_API_KEY
Blank values are ignored. Resolving the default role requires one supported
key and raises ConfigurationError with the available choices otherwise. The
environment is read when the registry is created, so build a new Runtime
after changing credentials. Configure a ModelRegistry explicitly when the
application needs another provider, model, or logical role.
Warning: Setting any supported key authorizes LittleGhost to send model inputs, including prompts, conversation history, tool data, and attachments, to the selected external provider. When more than one key is present, the precedence above determines that destination. Applications with provider or data-residency requirements should configure a ModelRegistry explicitly.
Constant Summary collapse
- CREDENTIALS =
[ ["LITTLEGHOST_OPENROUTER_API_KEY", :openrouter], ["LITTLEGHOST_OPENAI_API_KEY", :openai], ["OPENROUTER_API_KEY", :openrouter], ["OPENAI_API_KEY", :openai] ].freeze
- MODELS =
:nodoc:
{ openrouter: "openai/gpt-5.6-terra", openai: "gpt-5.6-terra" }.freeze
- PROVIDERS =
:nodoc:
{ openrouter: Providers::OpenRouter, openai: Providers::OpenAI }.freeze
- MISSING_CREDENTIAL_MESSAGE =
:nodoc:
"No API key is configured for the default model. Set " \ "LITTLEGHOST_OPENROUTER_API_KEY, LITTLEGHOST_OPENAI_API_KEY, " \ "OPENROUTER_API_KEY, or OPENAI_API_KEY, or configure a custom " \ "model registry with LittleGhost.configure."
Instance Method Summary collapse
-
#initialize ⇒ DefaultModelRegistry
constructor
Selects one provider from the current environment and registers the
defaultprofile.
Methods inherited from ModelRegistry
Constructor Details
#initialize ⇒ DefaultModelRegistry
Selects one provider from the current environment and registers the
default profile. The selection remains fixed for this registry instance.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/little_ghost/default_model_registry.rb', line 49 def initialize super variable, provider_name = CREDENTIALS.find { |name, _provider| !ENV[name].to_s.strip.empty? } if variable api_key = ENV.fetch(variable) provider_class = PROVIDERS.fetch(provider_name) provider(provider_name) do |model:, **| provider_class.new(api_key:, model:) end profile("default", provider: provider_name, model: MODELS.fetch(provider_name)) else configure_missing_credential end end |