Class: Terret::OpenRouter::Plugin
- Inherits:
-
Hames::Service
- Object
- Hames::Service
- Terret::OpenRouter::Plugin
- Defined in:
- lib/terret/openrouter.rb
Overview
Config-row form: mounts the adapter into ctx.llm under the "openrouter"
provider name. Roles then point at it: { main: "openrouter/
Instance Method Summary collapse
Instance Method Details
#start(ctx) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/terret/openrouter.rb', line 38 def start(ctx) # A resolver evaluated at REQUEST time, not now: it checks for the # credentials service at call time, so the row need not inject it (the # gem stays usable without terret-core's credentials mounted) and mount # order between the two rows never matters. resolve(:openrouter) is # ENV-first, so ENV-direct keeps working; when it resolves anything, the # value is registered as a scrub pattern (plan §6.9). credentials = -> { ctx[:credentials].resolve(:openrouter) if ctx.service?(:credentials) } adapter = Adapter.new(**config, credentials: credentials) ctx.effect { ctx[:llm].register_adapter("openrouter", adapter) } end |