Class: Insika::Commands::DeleteLLMProvider
- Inherits:
-
Object
- Object
- Insika::Commands::DeleteLLMProvider
- Defined in:
- lib/insika/commands/delete_llm_provider.rb
Overview
Control command: removes an LLM provider from the
LLMProviderStore. Idempotent (existed: false if there was none). UNDOES the
config in RubyLLM at runtime: when the provider existed, calls
configurator.unapply(api) clearing the global key/base — without a restart. A provider
that RubyLLM does not recognize degrades gracefully (unapply: false, nothing to
undo). -> { existed: bool }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(provider_store:, configurator:, event_stream:) ⇒ DeleteLLMProvider
constructor
A new instance of DeleteLLMProvider.
Constructor Details
#initialize(provider_store:, configurator:, event_stream:) ⇒ DeleteLLMProvider
Returns a new instance of DeleteLLMProvider.
14 15 16 17 18 |
# File 'lib/insika/commands/delete_llm_provider.rb', line 14 def initialize(provider_store:, configurator:, event_stream:) @provider_store = provider_store @configurator = configurator @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/insika/commands/delete_llm_provider.rb', line 20 def call(command) p = AgentPayload.symbolize(command.payload) api = AgentPayload.presence(p[:api]) raise Insika::ValidationError, "api is required" if api.nil? existed = @provider_store.delete(api) @configurator.unapply(api) if existed @event_stream.emit(Insika::Event.new( type: :llm_provider_deleted, data: { api: api, existed: existed }, meta: { at: Time.now.utc.iso8601 } )) { existed: existed } end |