Class: Terret::RoleSummarizer

Inherits:
Hames::Service
  • Object
show all
Defined in:
lib/terret/compactor.rb

Overview

ctx, the no-signup default: one model call through the :compactor role (a config row away on any adapter). Raises KeyError when the role is unconfigured — set the role or mount a provider that doesn't need one (terret-morph).

Constant Summary collapse

PROMPT =
<<~TEXT
  Summarize the conversation so far for your own future context. Preserve
  user goals and constraints, decisions made, tool results that still
  matter, and open questions. Reply with one compact briefing only.
TEXT

Instance Method Summary collapse

Instance Method Details

#reconfigure(_config) ⇒ Object

:role is read per call — already live



109
# File 'lib/terret/compactor.rb', line 109

def reconfigure(_config); end

#start(ctx) ⇒ Object



105
106
107
# File 'lib/terret/compactor.rb', line 105

def start(ctx)
  @ctx = ctx
end

#summarize(history) ⇒ Object



111
112
113
114
# File 'lib/terret/compactor.rb', line 111

def summarize(history)
  request = LLM::Request.new(model: nil, system: PROMPT, messages: history, tools: [])
  @ctx[:llm].stream(@ctx, role: config[:role] || :compactor, request: request) { |_ev| }.text
end