Module: RubynCode::Learning::Injector
- Defined in:
- lib/rubyn_code/learning/injector.rb
Overview
Injects relevant learned instincts into the system prompt so the agent can leverage past experience for the current project and context.
Constant Summary collapse
- MIN_CONFIDENCE =
Minimum confidence score for an instinct to be included.
0.3- DEFAULT_MAX_INSTINCTS =
Default maximum number of instincts to inject.
10- INSTINCTS_TABLE =
'instincts'
Class Method Summary collapse
- .build_and_filter(rows, context_tags, max_instincts) ⇒ Object
-
.call(db:, project_path:, context_tags: [], max_instincts: DEFAULT_MAX_INSTINCTS) ⇒ String
Queries and formats relevant instincts for system prompt injection.
Class Method Details
.build_and_filter(rows, context_tags, max_instincts) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubyn_code/learning/injector.rb', line 37 def build_and_filter(rows, , max_instincts) now = Time.now instincts = rows .map { |row| InstinctMethods.apply_decay(row_to_instinct(row), now) } .select { |inst| inst.confidence >= MIN_CONFIDENCE } instincts = (instincts, ) unless .empty? instincts.sort_by { |inst| -inst.confidence }.first(max_instincts) end |
.call(db:, project_path:, context_tags: [], max_instincts: DEFAULT_MAX_INSTINCTS) ⇒ String
Queries and formats relevant instincts for system prompt injection.
27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyn_code/learning/injector.rb', line 27 def call(db:, project_path:, context_tags: [], max_instincts: DEFAULT_MAX_INSTINCTS) rows = fetch_instincts(db, project_path) return '' if rows.empty? instincts = build_and_filter(rows, , max_instincts) return '' if instincts.empty? format_instincts(instincts) end |