feedback history and prompt work better

This commit is contained in:
2026-01-03 03:19:39 -07:00
parent 18f2f6f461
commit 6879a75f09
8 changed files with 427 additions and 90 deletions

View File

@@ -98,3 +98,66 @@ Successfully implemented a new menu item and functionality for generating theme
The implementation maintains backward compatibility while adding valuable feedback functionality to improve prompt generation quality over time.
Too many tests, so I moved all of them into the tests directory.
---
# Task: Implement feedback_historic.json cyclic buffer system (30 items)
## Changes Made
### 1. Added Feedback Historic System
- Created `feedback_historic.json` file to store previous feedback words (without weights)
- Implemented a cyclic buffer system with 30-item capacity (feedback00-feedback29)
- When new feedback is generated (6 words), they become feedback00-feedback05
- All existing items shift down by 6 positions
- Items beyond feedback29 are discarded
### 2. Updated Class Initialization
- Added `feedback_historic` attribute to `JournalPromptGenerator` class
- Updated `__init__` method to load `feedback_historic.json`
- Added `_load_feedback_historic()` method to load historic feedback words
- Added `_save_feedback_historic()` method to save historic feedback words (keeping only first 30)
### 3. Enhanced Feedback Words Management
- Updated `add_feedback_words_to_history()` method to:
- Extract just the words from current feedback words (no weights)
- Add 6 new words to the historic buffer
- Shift all existing words down by 6 positions
- Maintain 30-item limit by discarding oldest items
- Updated `update_feedback_words()` to automatically call `add_feedback_words_to_history()`
### 4. Improved AI Prompt Generation
- Updated `generate_theme_feedback_words()` method to include historic feedback words in API call
- The prompt now includes three sections:
1. Previous prompts (historic prompts)
2. Current feedback themes (with weights)
3. Historic feedback themes (just words, no weights)
- This helps the AI avoid repeating previously used theme words
### 5. Data Structure Design
- Historic feedback words are stored as a list of dictionaries with keys (feedback00, feedback01, etc.)
- Each dictionary contains only the word (no weight field)
- Structure mirrors `prompts_historic.json` but for feedback words
- 30-item limit provides sufficient history while preventing excessive repetition
## Testing
- Created comprehensive test to verify cyclic buffer functionality
- Tested that new items are added at the beginning (feedback00-feedback05)
- Verified that existing items shift down correctly
- Confirmed 30-item limit is enforced (oldest items are dropped)
- Tested that historic feedback words are included in AI prompts
- Verified that weights are not stored in historic buffer (only words)
## Result
Successfully implemented a feedback historic cyclic buffer system that:
1. Stores previous feedback words in `feedback_historic.json` (30-item limit)
2. Automatically adds new feedback words to history when they are updated
3. Includes historic feedback words in AI prompts to avoid repetition
4. Maintains consistent data structure with the rest of the system
5. Provides a memory of previous theme words to improve AI suggestions over time
The system now has a complete feedback loop where:
- Historic prompts and feedback words inform new theme word generation
- New theme words are rated by users and become current feedback words
- Current feedback words are added to the historic buffer
- Historic feedback words help avoid repetition in future theme word generation