Class: Insika::Commands::UpsertLLMProvider
- Inherits:
-
Object
- Object
- Insika::Commands::UpsertLLMProvider
- Defined in:
- lib/insika/commands/upsert_llm_provider.rb
Overview
Control command: creates/edits an LLM provider
(api/base_url/auth_header/api_key/models) in the LLMProviderStore and RECONFIGURES
RubyLLM at runtime (LLMConfigurator) — swaps key/base without a restart.
The api_key is sentinel-aware (OCULTO preserves; "" clears; a new string
replaces). Returns the MASKED record (the key never comes back in plaintext).
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(provider_store:, configurator:, event_stream:) ⇒ UpsertLLMProvider
constructor
A new instance of UpsertLLMProvider.
Constructor Details
#initialize(provider_store:, configurator:, event_stream:) ⇒ UpsertLLMProvider
Returns a new instance of UpsertLLMProvider.
13 14 15 16 17 |
# File 'lib/insika/commands/upsert_llm_provider.rb', line 13 def initialize(provider_store:, configurator:, event_stream:) @provider_store = provider_store @configurator = configurator @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/insika/commands/upsert_llm_provider.rb', line 19 def call(command) p = AgentPayload.symbolize(command.payload) masked = @provider_store.upsert(p) # validates `api`; returns masked # Reconfigures only THIS provider (with the real key from the store, already reconciled). result = @configurator.apply([@provider_store.get_raw(masked["api"])]) @event_stream.emit(Insika::Event.new( type: :llm_provider_upserted, data: { api: masked["api"], applied: result[:applied], skipped: result[:skipped] }, meta: { at: Time.now.utc.iso8601 } )) masked end |