Class: Llmemory::Dashboard::ReflectionController

Inherits:
ApplicationController show all
Defined in:
app/controllers/llmemory/dashboard/reflection_controller.rb

Overview

Read-only landing for reflection. Triggers (POST #run) build a Reflector over the configured episodic + semantic memories and run a single pass over the last N episodes.

Instance Method Summary collapse

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/llmemory/dashboard/reflection_controller.rb', line 15

def run
  user_id = params[:user_id]
  window = (params[:window].presence || 10).to_i
  episodic = Llmemory::LongTerm::Episodic::Memory.new(user_id: user_id, storage: episodic_storage)
  semantic = build_semantic_memory(user_id)
  insight_ids = Llmemory::Reflection::Reflector.new(episodic: episodic, semantic: semantic).reflect(window: window)
  redirect_to user_reflection_path(user_id), notice: "Reflection produced #{insight_ids.size} insight(s)."
rescue Llmemory::LLMError => e
  redirect_to user_reflection_path(user_id), alert: "Reflection failed: #{e.message}"
end

#showObject



9
10
11
12
13
# File 'app/controllers/llmemory/dashboard/reflection_controller.rb', line 9

def show
  @user_id = params[:user_id]
  @recent_window = (params[:window].presence || 10).to_i
  @recent_episodes = episodic_storage.list_episodes(@user_id, limit: @recent_window)
end