7.1 KiB
7.1 KiB
Task: Combine pool and history stats into a single function and single menu item
Changes Made
1. Created New Combined Stats Function
- Added
show_combined_stats()method toJournalPromptGeneratorclass - Combines both pool statistics and history statistics into a single function
- Displays two tables: "Prompt Pool Statistics" and "Prompt History Statistics"
2. Updated Interactive Menu
- Changed menu from 5 options to 4 options:
-
- Draw prompts from pool (no API call)
-
- Fill prompt pool using API
-
- View combined statistics (replaces separate pool and history stats)
-
- Exit
-
- Updated menu handling logic to use the new combined stats function
3. Updated Command-Line Arguments
- Removed
--pool-statsargument - Updated
--statsargument description to "Show combined statistics (pool and history)" - Updated main function logic to use
show_combined_stats()instead of separate functions
4. Removed Old Stats Functions
- Removed
show_pool_stats()method - Removed
show_history_stats()method - All functionality consolidated into
show_combined_stats()
5. Code Cleanup
- Removed unused imports and references to old stats functions
- Ensured all menu options work correctly with the new combined stats
Testing
- Verified
--statscommand-line argument works correctly - Tested interactive mode shows updated menu
- Confirmed combined stats display both pool and history information
- Tested default mode (draw from pool) still works
- Verified fill-pool option starts correctly
Result
Successfully combined pool and history statistics into a single function and single menu item, simplifying the user interface while maintaining all functionality.
Task: Implement theme feedback words functionality with new menu item
Changes Made
1. Added New Theme Feedback Words API Call
- Created
generate_theme_feedback_words()method that:- Loads
ds_feedback.txtprompt template - Sends historic prompts to AI API for analysis
- INCLUDES current feedback words from
feedback_words.jsonin the API payload - Receives 6 theme words as JSON response
- Parses and validates the response
- Loads
2. Added User Rating System
- Created
collect_feedback_ratings()method that:- Presents each of the 6 theme words to the user
- Collects ratings from 0-6 for each word
- Creates structured feedback items with keys (feedback00-feedback05)
- Includes weight values based on user ratings
3. Added Feedback Words Update System
- Created
update_feedback_words()method that:- Replaces existing feedback words with new ratings
- Saves updated feedback words to
feedback_words.json - Maintains the required JSON structure
4. Updated Interactive Menu
- Expanded menu from 4 options to 5 options:
-
- Draw prompts from pool (no API call)
-
- Fill prompt pool using API
-
- View combined statistics
-
- Generate and rate theme feedback words (NEW)
-
- Exit
-
- Added complete implementation for option 4
5. Enhanced Data Handling
- Added
_save_feedback_words()method for saving feedback data - Updated
_load_feedback_words()to handle JSON structure properly - Ensured feedback words are included in AI prompts when generating new prompts
Testing
- Verified all new methods exist and have correct signatures
- Confirmed
ds_feedback.txtfile exists and is readable - Tested feedback words JSON structure validation
- Verified interactive menu displays new option correctly
- Confirmed existing functionality remains intact
Result
Successfully implemented a new menu item and functionality for generating theme feedback words. The system now:
- Makes an API call with historic prompts and
ds_feedback.txttemplate - Receives 6 theme words from the AI
- Collects user ratings (0-6) for each word
- Updates
feedback_words.jsonwith the new ratings - Integrates the feedback into future prompt generation
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.jsonfile 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_historicattribute toJournalPromptGeneratorclass - Updated
__init__method to loadfeedback_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 calladd_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:
- Previous prompts (historic prompts)
- Current feedback themes (with weights)
- 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.jsonbut 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:
- Stores previous feedback words in
feedback_historic.json(30-item limit) - Automatically adds new feedback words to history when they are updated
- Includes historic feedback words in AI prompts to avoid repetition
- Maintains consistent data structure with the rest of the system
- 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