Class: OllamaAgent::RuntimeCommandSystem::Session::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime_command_system/session/runtime.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent:) ⇒ Runtime

Returns a new instance of Runtime.



11
12
13
14
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 11

def initialize(agent:)
  @agent  = agent
  @events = Events.new
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



9
10
11
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 9

def agent
  @agent
end

#eventsObject (readonly)

Returns the value of attribute events.



9
10
11
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 9

def events
  @events
end

Instance Method Details

#active_modelObject



16
17
18
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 16

def active_model
  @agent.model
end

#active_providerObject



20
21
22
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 20

def active_provider
  @agent.provider_name
end

#export_stateObject



34
35
36
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 34

def export_state
  state.merge(timestamp: Time.now.iso8601)
end

#stateObject



30
31
32
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 30

def state
  { model: active_model, provider: active_provider }
end

#switch_model!(name, descriptor: nil) ⇒ Object



24
25
26
27
28
# File 'lib/ollama_agent/runtime_command_system/session/runtime.rb', line 24

def switch_model!(name, descriptor: nil)
  @agent.assign_chat_model!(name)
  @events.emit(:model_switched, model: name, descriptor: descriptor)
  name
end