fixed indexing on feedback
This commit is contained in:
33
AGENTS.md
33
AGENTS.md
@@ -1052,3 +1052,36 @@ The API call sequence has been successfully optimized to:
|
||||
3. Generate new feedback words after user rating
|
||||
4. Refresh all UI elements
|
||||
|
||||
## Feedback Historic Indexing Bug Fix ✓ COMPLETED
|
||||
|
||||
### Problem Identified
|
||||
The `feedback_historic.json` cyclic buffer had duplicate keys (`feedback00` to `feedback05`) repeated throughout the 30-item buffer instead of having unique keys (`feedback00` to `feedback29`).
|
||||
|
||||
### Root Cause
|
||||
The `_generate_and_insert_new_feedback_words()` method in `PromptService` was always generating keys `feedback00` to `feedback05` when inserting new items at position 0, creating duplicate keys in the buffer.
|
||||
|
||||
### Solution Implemented
|
||||
1. **Updated `_generate_and_insert_new_feedback_words()` method**:
|
||||
- Added re-keying logic that assigns unique keys based on position in buffer
|
||||
- After inserting new items, re-keys all items from `feedback00` to `feedback29`
|
||||
- Preserves word and weight data during re-keying
|
||||
|
||||
2. **Updated `update_feedback_words()` method**:
|
||||
- Modified to preserve existing keys when updating weights
|
||||
- Extracts existing key from current item instead of generating new one
|
||||
- Maintains backward compatibility with existing data structure
|
||||
|
||||
### Technical Details
|
||||
- **Before**: Keys `feedback00`-`feedback05` repeated, causing duplicate keys
|
||||
- **After**: Unique sequential keys `feedback00`-`feedback29` (or less if buffer not full)
|
||||
- **Data Structure**: Each item now has format `{"feedbackXX": "word", "weight": N}` with unique XX values
|
||||
- **Buffer Management**: Proper cyclic buffer behavior with 30-item limit maintained
|
||||
|
||||
### Verification
|
||||
- ✅ All 30 items in buffer now have unique keys (`feedback00` to `feedback29`)
|
||||
- ✅ No duplicate keys after feedback rating operations
|
||||
- ✅ Data integrity preserved (words and weights maintained)
|
||||
- ✅ Backward compatibility maintained with existing frontend
|
||||
- ✅ Cyclic buffer functionality preserved (oldest items removed when buffer full)
|
||||
|
||||
The bug has been successfully fixed, ensuring proper cyclic buffer operation with unique keys throughout the feedback history.
|
||||
|
||||
Reference in New Issue
Block a user