Module: Brute::Compaction
- Defined in:
- lib/brute/compaction.rb,
lib/brute/compaction/summarize.rb,
lib/brute/compaction/transcript.rb,
lib/brute/compaction/middleware/strategy.rb,
lib/brute/compaction/middleware/tool_results.rb,
lib/brute/compaction/middleware/sliding_window.rb
Overview
Compactors that end a Brute::Turn::CompactionPipeline: the strategy of last resort, reached only when the layers above could not get the conversation under target on their own.
Defined Under Namespace
Modules: Middleware, Transcript Classes: Summarize
Class Method Summary collapse
-
.counter(env) ⇒ Object
Whatever the turn decided to weigh with, remembered on the env so the trigger and every strategy below it answer the same question the same way.
-
.over_target?(env) ⇒ Boolean
Is the conversation still bigger than it is allowed to be?.
- .tokens(env, messages = env[:conversation]) ⇒ Object
Class Method Details
.counter(env) ⇒ Object
Whatever the turn decided to weigh with, remembered on the env so the trigger and every strategy below it answer the same question the same way. Brute::TokenCounter::Approximate when nobody said otherwise.
23 |
# File 'lib/brute/compaction.rb', line 23 def self.counter(env) = env[:token_counter] ||= TokenCounter.default |
.over_target?(env) ⇒ Boolean
Is the conversation still bigger than it is allowed to be?
28 |
# File 'lib/brute/compaction.rb', line 28 def self.over_target?(env) = tokens(env) > env[:target] |
.tokens(env, messages = env[:conversation]) ⇒ Object
25 |
# File 'lib/brute/compaction.rb', line 25 def self.tokens(env, = env[:conversation]) = counter(env).count() |