Package com.tnsai.learning
Class AdaptivePromptEnricher
java.lang.Object
com.tnsai.learning.AdaptivePromptEnricher
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 Summary
ConstructorsConstructorDescriptionAdaptivePromptEnricher(FeedbackLearner feedbackLearner, FeedbackStore feedbackStore) Creates an enricher with the given feedback learner and store. -
Method Summary
Modifier and TypeMethodDescriptionEnriches the base system prompt with learned rules and preferences.Returns the current learned preferences.Returns the current learned rules (prompt adjustments).voidrefresh()Forces a re-learning cycle, bypassing the feedback count cache.
-
Constructor Details
-
AdaptivePromptEnricher
Creates an enricher with the given feedback learner and store.- Parameters:
feedbackLearner- the learner that extracts rules from feedbackfeedbackStore- the store that holds recorded feedback
-
-
Method Details
-
enrich
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
Returns the current learned rules (prompt adjustments).- Returns:
- list of learned rules, never null
-
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.
-