Class: OllamaAgent::RuntimeCommandSystem::Dispatch::Handlers::ModelHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime_command_system/dispatch/handlers/model_handler.rb

Instance Method Summary collapse

Instance Method Details

#call(ast:, session:) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
# File 'lib/ollama_agent/runtime_command_system/dispatch/handlers/model_handler.rb', line 8

def call(ast:, session:)
  name = ast.arguments.first&.value.to_s.strip
  raise ArgumentError, "Missing model name — usage: /model <name>" if name.empty?

  descriptor = Providers::ModelRegistry.find(name, agent: session.agent)
  session.switch_model!(name, descriptor: descriptor)
  { model: name, descriptor: descriptor }
end