Class: ClaudeMemory::Hook::DistillationRunner
- Inherits:
-
Object
- Object
- ClaudeMemory::Hook::DistillationRunner
- Defined in:
- lib/claude_memory/hook/distillation_runner.rb
Constant Summary collapse
- MIN_TEXT_LENGTH =
200
Instance Method Summary collapse
- #distill_batch(project_path:, limit: 5) ⇒ Object
- #distill_item(content_id, project_path:, scope: "project") ⇒ Object
-
#initialize(store, distiller: Distill::NullDistiller.new) ⇒ DistillationRunner
constructor
A new instance of DistillationRunner.
Constructor Details
#initialize(store, distiller: Distill::NullDistiller.new) ⇒ DistillationRunner
Returns a new instance of DistillationRunner.
8 9 10 11 |
# File 'lib/claude_memory/hook/distillation_runner.rb', line 8 def initialize(store, distiller: Distill::NullDistiller.new) @store = store @distiller = distiller end |
Instance Method Details
#distill_batch(project_path:, limit: 5) ⇒ Object
39 40 41 42 43 |
# File 'lib/claude_memory/hook/distillation_runner.rb', line 39 def distill_batch(project_path:, limit: 5) items = @store.undistilled_content_items(limit: limit, min_length: MIN_TEXT_LENGTH) items.each { |item| distill_item(item[:id], project_path: project_path) } items.size end |
#distill_item(content_id, project_path:, scope: "project") ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/claude_memory/hook/distillation_runner.rb', line 13 def distill_item(content_id, project_path:, scope: "project") item = @store.get_content_item(content_id) return unless item raw_text = item[:raw_text] return unless raw_text && raw_text.length >= MIN_TEXT_LENGTH extraction = @distiller.distill(raw_text, content_item_id: content_id) return if extraction.empty? resolver = Resolve::Resolver.new(@store) @store.db.transaction do resolve_result = resolver.apply( extraction, content_item_id: content_id, project_path: project_path, scope: scope ) @store.record_ingestion_metrics( content_item_id: content_id, input_tokens: 0, output_tokens: 0, facts_extracted: resolve_result[:facts_created] ) end rescue => e ClaudeMemory.logger.warn("DistillationRunner#distill_item(#{content_id}) failed: #{e.class} - #{e.}") ClaudeMemory.logger.warn(e.backtrace.first(5).join("\n")) end |