Class AdaptivePromptEnricher

java.lang.Object
com.tnsai.learning.AdaptivePromptEnricher

public final class AdaptivePromptEnricher extends Object
Enriches system prompts with learned rules from FeedbackLearner.

Closes the feedback-to-behavior loop: feedback recorded by users is analyzed by FeedbackLearner to extract actionable rules, which this class appends to the agent's system prompt before each LLM call.

Thread-safe. The enricher caches learning results and only re-learns when new feedback has been recorded since the last learning cycle.

Usage


 AdaptivePromptEnricher enricher = new AdaptivePromptEnricher(feedbackLearner, feedbackStore);
 String enrichedPrompt = enricher.enrich(basePrompt);
 
Since:
0.1.0
  • Constructor Details

    • AdaptivePromptEnricher

      public AdaptivePromptEnricher(FeedbackLearner feedbackLearner, FeedbackStore feedbackStore)
      Creates an enricher with the given feedback learner and store.
      Parameters:
      feedbackLearner - the learner that extracts rules from feedback
      feedbackStore - the store that holds recorded feedback
  • Method Details

    • enrich

      public String enrich(String basePrompt)
      Enriches the base system prompt with learned rules and preferences.

      If no rules have been learned (insufficient feedback or learner returned empty), returns the base prompt unchanged.

      Parameters:
      basePrompt - the original system prompt
      Returns:
      enriched prompt with learned behavior section appended, or the original prompt if no learnings are available
    • getLearnedRules

      public List<String> getLearnedRules()
      Returns the current learned rules (prompt adjustments).
      Returns:
      list of learned rules, never null
    • getLearnedPreferences

      public List<String> getLearnedPreferences()
      Returns the current learned preferences.
      Returns:
      list of learned preferences, never null
    • refresh

      public void refresh()
      Forces a re-learning cycle, bypassing the feedback count cache.