Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
bccdd87
feat: implement Task 9.1 - React application structure and routing
Jul 31, 2025
469e690
feat: implement dataset management frontend components
Jul 31, 2025
d8372f6
feat: implement prompt editor frontend components
Jul 31, 2025
87ad7c2
Implement custom metrics frontend components
Jul 31, 2025
23d7622
Implement optimization workflow frontend components
Jul 31, 2025
a216ac1
Implement AI Rubric Generation Frontend Components
Jul 31, 2025
1b31eef
feat: implement comprehensive results analysis interface
Jul 31, 2025
c8a342a
feat: implement comprehensive testing suite for backend and frontend
Jul 31, 2025
9c4ee10
feat: implement performance optimization and monitoring system
Jul 31, 2025
27c4926
final build
Jul 31, 2025
5027ddc
Add comprehensive codebase analysis and lightweight frontend options
Aug 3, 2025
cfe1fcb
Add lightweight web interface implementation
Aug 3, 2025
b62eb90
Add detailed before/after comparison
Aug 3, 2025
c4677fa
feat: Complete lightweight frontend with dataset viewer, optimization…
Aug 4, 2025
f47905f
working frontend with basic features
Aug 8, 2025
5627d55
working frontend with basic features
Aug 8, 2025
ad4bb49
🔧 Fix baseline evaluation with dataset structure flattening
Aug 13, 2025
a34a938
🎉 MAJOR MILESTONE: Fix baseline evaluation system
Aug 13, 2025
5358d8d
✨ Add optimization cleanup functionality
Aug 14, 2025
c00e1b8
📁 Move temp dataset files to organized data directory
Aug 14, 2025
a2a895a
🧹 Remove unused files and clean up frontend directory
Aug 14, 2025
6495f62
📝 Update README to reflect current implementation
Aug 14, 2025
f8cdc7b
📝 Complete rewrite of FEATURES.md to reflect actual implementation
Aug 14, 2025
dd73fd7
Remove all emojis from README.md and FEATURES.md
Aug 14, 2025
9586e5a
Fix markdown header formatting after emoji removal
Aug 14, 2025
90db75b
Final formatting cleanup
Aug 14, 2025
2bcab5e
Update .gitignore to exclude frontend runtime data
Aug 14, 2025
55fd6e6
Additional gitignore cleanup
Aug 14, 2025
5dddf23
Update notebook changes
Aug 14, 2025
ca89abd
remove uncessary files
Aug 14, 2025
3b24c22
🔧 Add comprehensive installation and validation system
Aug 14, 2025
efacebe
Remove visual builder option from metric creation
Aug 14, 2025
a946b9d
Fix installation script issues
Aug 14, 2025
1762061
Fix package name: fasthtml -> python-fasthtml
Aug 14, 2025
93dbd94
Add missing pydantic_settings dependency
Aug 14, 2025
9ba73c9
Fix rate_limit empty string error in metric inference
Aug 14, 2025
bcdd127
Fix AttributeError: int object has no attribute 'startswith'
Aug 14, 2025
ed2247e
Fix dataset file lookup with pattern matching
Aug 14, 2025
75b9043
Fix metric_id retrieval in optimization lookup
Aug 14, 2025
8efd18c
Fix missing Monitor Progress and View Results buttons
Aug 14, 2025
1029bcd
Always show Monitor Progress and View Results buttons
Aug 14, 2025
f2ebcb9
Show correct button based on job status
Aug 14, 2025
9b1ca10
Add expandable options for metric creation focus areas
Aug 14, 2025
ec8c48e
Fix expandable checkboxes with common sub-items
Aug 14, 2025
e09a470
Add helpful tooltips to focus area checkboxes
Aug 14, 2025
9fe84bb
Fix tooltips and checkbox expansion using shad4fasthtml
Aug 14, 2025
c809bb7
Fix RecursionError in Option function
Aug 14, 2025
d915cae
Fix RecursionError in Select function
Aug 14, 2025
4513443
Fix NameError: TooltipProvider not defined
Aug 14, 2025
123e52e
Revert to simple checkbox layout without tooltips and sub-options
Aug 14, 2025
4425784
Fix missing checkbox labels
Aug 14, 2025
f3522a3
Implement sectioned focus areas with detailed sub-options
Aug 14, 2025
d618281
Update prompt template to handle new granular focus areas
Aug 14, 2025
0129cfb
Add prompt analysis capability to metric inference
Aug 14, 2025
d47819c
Rename tab from 'Infer from Dataset' to 'Infer from Assets'
Aug 14, 2025
1828068
Fix missing checkbox labels by restructuring HTML
Aug 14, 2025
1be9efc
Add padding above Focus Areas section
Aug 14, 2025
4e4cb2e
Fix AttributeError: use existing get_prompt method
Aug 14, 2025
1df1825
Fix spacing issues in focus area sections
Aug 14, 2025
5b6981c
Wrap focus areas in nested cards for better visual hierarchy
Aug 14, 2025
b6ee609
Convert all metric creation buttons to shad4fasthtml black/white styling
Aug 14, 2025
10ffd90
Fix Card component TypeError by wrapping content properly
Aug 14, 2025
6afad43
Fix Card structure and make cards full width
Aug 14, 2025
0dbc0b0
Make main focus areas card 100% width
Aug 14, 2025
fa7fc09
Add CSS to make card-content 100% width
Aug 14, 2025
acfde16
Fix custom metric JSON parsing error
Aug 14, 2025
dff3c4e
Add flexible metric input parser for AI-generated metrics
Aug 14, 2025
1e42943
Add debugging to identify generated metric code issues
Aug 14, 2025
c22fb24
Add data structure mismatch handler for AI-generated metrics
Aug 14, 2025
aaee92d
Fix dataset analysis prompt to match actual data structure
Aug 14, 2025
3579c7b
Enhance prompt analysis to validate against original intent
Aug 14, 2025
b8f7e11
Clean up debug logs and fix View Results button
Aug 14, 2025
d29c302
Add debug info to see actual status values
Aug 14, 2025
18a46c1
Fix None status handling in optimization cards
Aug 14, 2025
917f898
Fix database column mapping for optimizations
Aug 14, 2025
3a1c6e1
Simplify metrics approach - remove focus areas
Aug 14, 2025
2ee1d3d
prompttemplate
Aug 14, 2025
0491234
Add comprehensive Instructor implementation plan
Aug 14, 2025
dab6aec
Add editable intent field to metric selection
Aug 14, 2025
011f2e9
Fix metric selection page styling consistency
Aug 14, 2025
39e1fe4
Fix Textarea syntax error in metric selection
Aug 14, 2025
6eabefc
Fix intent analysis field in LLM response
Aug 14, 2025
815e173
Remove login button from navbar
Aug 14, 2025
7623200
Put action buttons in card container with proper styling
Aug 14, 2025
3b9d86c
Clarify dataset format vs output format in prompt template
Aug 14, 2025
bc420f5
Add debugging for intent analysis field
Aug 14, 2025
f560b47
Adjust button widths to 75%/25% on same row
Aug 14, 2025
0d62542
Fix textarea content display and button widths
Aug 14, 2025
b21d6eb
Fix Textarea syntax error - remove conflicting placeholder
Aug 14, 2025
444d848
Add loading state and fix preview page styling
Aug 14, 2025
3b0f61e
Implement shad4html components and create usage rules
Aug 14, 2025
a7b03a0
Apply proper shadcn button classes directly
Aug 14, 2025
09ec79c
Apply shadcn styling to metrics page button
Aug 14, 2025
e565753
Fix critical buttons with proper shadcn styling
Aug 14, 2025
3cd487d
Continue fixing buttons with shadcn styling - Phase 2
Aug 14, 2025
b619b71
Major button fixes - Phase 3: 18/65 buttons now have shadcn styling
Aug 14, 2025
cb5432d
🎉 ACHIEVEMENT: 100% SHADCN BUTTON COMPLIANCE!
Aug 14, 2025
1cc0031
Update styling rules: PICO CSS + Shad4FastHTML hybrid approach
Aug 14, 2025
cee86c9
Apply styling rules: Replace inline styles with Shad4FastHTML components
Aug 14, 2025
4670448
🎯 COMPLETE MIGRATION: Remove PICO CSS, Pure Shad4FastHTML Setup
Aug 14, 2025
abd4c17
🎨 STYLING FIXES: Pure Shad4FastHTML Implementation
Aug 14, 2025
f00a021
Frontend UI improvements and cleanup
Aug 15, 2025
b8a07ff
shad4fast package to install sript
Aug 15, 2025
613bf3d
Remove fallback JSON parsing logic from metric service
Aug 19, 2025
32e5981
Remove natural language option and hardcoded patterns
Aug 19, 2025
66463dd
Fix syntax error in metrics_page.py
Aug 19, 2025
3388d19
Remove hardcoded fallback from metric generation
Aug 19, 2025
211f742
Fix AI prompt to analyze actual data structure
Aug 19, 2025
aae6960
Add instructions for handling JSON string in answer field
Aug 19, 2025
704ae54
Fix multi-label category logic instructions
Aug 19, 2025
c6cfad4
Add metric validation system for non-developers
Aug 20, 2025
46f3352
Add detailed explanations to metric validation
Aug 20, 2025
764000d
Fix Alert variant error
Aug 20, 2025
1de1d6e
Fix database method call in validation
Aug 20, 2025
0311cfd
Add validation results display to metric preview
Aug 20, 2025
c998d1f
Fix data structure handling in AI prompt
Aug 20, 2025
2d9950a
Remove prompt functionality from metric creation
Aug 20, 2025
cc997bf
Fix f-string syntax errors in prompt template
Aug 20, 2025
6cf65fd
Remove prompt references from dataset analysis template
Aug 20, 2025
1a80e9d
Fix UI text and f-string format errors
Aug 20, 2025
faa51a0
Increase validation report size and sample count
Aug 20, 2025
aff0333
Update AI prompt to generate robust metrics like good example
Aug 20, 2025
212becd
Fix AI prompt to be generic instead of hardcoded
Aug 20, 2025
60041ac
Add output format validation toggle to metric selection
Aug 20, 2025
6753936
Fix format_description variable scope error
Aug 20, 2025
f86a73b
Fix format_fields variable scope issue
Aug 20, 2025
ec19abf
Fix SDK worker to handle Dict returns from metrics
Aug 20, 2025
6d22ede
Fix unrealistic perfect validation scores
Aug 20, 2025
211cf31
Add metric instantiation requirement to prompt template
Aug 20, 2025
dc48076
Fix few-shot examples truncation
Aug 20, 2025
ab533f9
Fix few-shot examples content truncation
Aug 20, 2025
d9fdd7e
Add 'Optimize Further' button to results page
Aug 20, 2025
d7b12a8
Add debugging for optimize_further JSON parsing error
Aug 20, 2025
3830d6d
Fix optimize_further to handle Python dict format
Aug 20, 2025
a3ff0b3
Fix missing dataset_id key error in optimize_further
Aug 20, 2025
c71e5dd
Fix optimize_further to use correct database method signatures
Aug 20, 2025
65ad9df
Fix create_prompt parameters in optimize_further
Aug 20, 2025
537135c
Add debugging for dataset lookup in optimize_further
Aug 20, 2025
abce79f
Fix dataset lookup by name instead of ID in optimize_further
Aug 20, 2025
df2748b
Fix function name in optimize_further
Aug 20, 2025
5e163b2
Fix KeyError for missing 'improvement' field in monitor page
Aug 20, 2025
25f49c2
Fix IndexError in run_optimization_worker for thread calls
Aug 20, 2025
48dcdfa
Include few-shot examples in optimize_further baseline
Aug 20, 2025
29b0da5
Complete AI dataset generation feature plan
Aug 20, 2025
775f131
Implement AI dataset generator frontend
Aug 20, 2025
dc4753f
Fix infinite loop in Optimize Further by properly formatting few-shot…
Aug 20, 2025
3775a19
Show original optimization name in Further Optimization display
Aug 20, 2025
37d4a8c
Fix redirect URL for Optimize Further button
Aug 20, 2025
a09aa49
Fix infinite loop by using base metric for baseline evaluation
Aug 20, 2025
be7788a
Fix delete button for Further Optimization jobs with quotes in names
Aug 20, 2025
88202e0
Fix database connection issue in Optimize Further
Aug 20, 2025
38a5952
Fix remaining infinite loop by using base metric for optimized evalua…
Aug 20, 2025
5089d71
Fix infinite loop by using original metric before wrapping
Aug 21, 2025
1241c23
Add safety limit to GeneratedMetric to prevent infinite loops
Aug 21, 2025
7b564fc
Fix baseline evaluation to include few-shot examples in Further Optim…
Aug 21, 2025
28710bd
Fix rate limit in Optimize Further to use 1000 RPM instead of 60
Aug 21, 2025
45ce9fe
Properly inherit rate limit from original optimization instead of har…
Aug 21, 2025
7164949
Remove safety limit causing all metrics to average 50%
Aug 21, 2025
f96c540
Fix DSPy thread configuration error in Optimize Further
Aug 21, 2025
61fbbd0
Comprehensive README update with deployment guide and feature documen…
Aug 21, 2025
f589514
Fix Generate Dataset button - add missing JavaScript function
Aug 21, 2025
702e67f
Add comprehensive debug logging to AI dataset conversation
Aug 21, 2025
a6d04c8
Fix Bedrock API call format in dataset conversation service
Aug 21, 2025
162c4d6
Fix JSON parsing error in dataset conversation service
Aug 21, 2025
0365af3
Fix Bedrock API calls in sample generator service
Aug 21, 2025
32b6c6a
Add sample display functionality to AI Dataset Generator
Aug 21, 2025
616702f
Add annotation system for AI Dataset Generator Step 5
Aug 21, 2025
21066c0
Add debug logging to sample display functionality
Aug 21, 2025
124d5b1
Fix prompt analysis flow to use extracted information
Aug 21, 2025
3c0ac4c
Add comprehensive debug logging to prompt analysis
Aug 21, 2025
85a5676
Fix prompt analysis to focus on actual user prompt content
Aug 21, 2025
c43631d
Add use_case extraction to skip basic task type question
Aug 21, 2025
2fc0659
Fix JavaScript to let conversation service handle analysis display
Aug 21, 2025
0c02944
Fix prompt analysis to better understand actual prompt content
Aug 21, 2025
bde019c
Fix dashboard View Results link to go to optimization page
Aug 22, 2025
e6d6432
Add global dark mode text color fix
Aug 22, 2025
aef120c
Restructure layout with separate title and navbar rows
Aug 22, 2025
df84cd8
Restore half circle dark mode icon
Aug 22, 2025
20d75b2
Restore dynamic navbar sizing behavior
Aug 22, 2025
14b5582
Remove color box from dark mode toggle icon
Aug 22, 2025
a55dc69
Fix dark mode toggle visibility without hover box
Aug 22, 2025
549c80b
Make dark mode toggle always use hover color
Aug 22, 2025
6afacb2
Fix half circle icon contrast in both themes
Aug 22, 2025
39fa330
Fix dataset generator prompt analysis and conversation flow
Aug 22, 2025
49c05a2
Add Nova model selection for dataset sample generation
Aug 22, 2025
47caeb6
feat: Add simple dataset generator with clean architecture
Aug 22, 2025
3dc79e2
Add flexible dataset generator with format detection
Aug 24, 2025
9239f70
Add test file for sample generation
Aug 24, 2025
3a9914e
Merge branch 'feature/ai-dataset-generator'
Aug 24, 2025
347b037
Improve UI/UX for dataset management and flexible generator
Aug 24, 2025
7cf93e0
Fix AI Dataset Generator: navbar styling and domain-specific generation
Aug 25, 2025
d7316ad
Fix composite metric generation: resolve NoneType errors and implemen…
Aug 29, 2025
c1aaca8
feat: implement Simple Dataset Generator with annotation and regenera…
Sep 3, 2025
c51dfbd
chore: update gitignore for temp files and build artifacts
Sep 3, 2025
9004151
prebackup
Sep 4, 2025
11eb22f
Merge branch 'aws:main' into main
tsanti Sep 11, 2025
d8e5bb2
Update gitignore with additional exclusions
Sep 16, 2025
5be7a15
Remove frontend from main branch
Sep 16, 2025
bcea861
Add virtual environment directories to gitignore
Sep 16, 2025
83cc0af
Pin DSPy version to maintain SDK compatibility
Sep 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions .amazonq/docs/baseline-evaluation-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Baseline Evaluation Fix - Major Milestone

## Issue Summary
The Nova Prompt Optimizer frontend was failing to generate baseline evaluation scores, consistently returning `None` instead of actual performance metrics. This prevented proper comparison between baseline and optimized prompts.

## Root Cause Analysis

### Primary Issues Identified:

1. **Database Schema Mismatch**
- `create_optimization()` was storing `prompt["name"]` instead of `prompt_id`
- Caused "prompt not found" errors during optimization runs

2. **Dataset Structure Incompatibility**
- Frontend used nested structure: `{'inputs': {'input': '...'}, 'outputs': {'answer': '...'}}`
- SDK expected flat structure: `{'input': '...', 'answer': '...'}`
- SDK's inference engine couldn't process nested data

3. **Missing Metric Aggregation**
- Custom metric classes had empty `batch_apply()` methods (`pass`)
- SDK's `aggregate_score()` relied on `batch_apply()` for final score calculation
- Individual scores calculated correctly, but final aggregation returned `None`

4. **Import Scoping Conflicts**
- Duplicate imports inside functions shadowed global imports
- Caused `UnboundLocalError` for `json` and `JSONDatasetAdapter`

## Technical Details

### Error Symptoms:
```
🔍 DEBUG - Baseline score from SDK Evaluator: None
Parameter validation failed: Invalid type for parameter messages[0].content,
value: , type: <class 'str'>, valid types: <class 'list'>, <class 'tuple'>
```

### SDK Workflow Expected:
```
TextPromptAdapter → JSONDatasetAdapter → MetricAdapter → BedrockInferenceAdapter → Evaluator.aggregate_score()
```

## Solution Implementation

### 1. Fixed Database Schema Bug
**File**: `database.py`
```python
# BEFORE (❌ Bug):
conn.execute("""
INSERT INTO optimizations (id, name, prompt, dataset, ...)
VALUES (?, ?, ?, ?, ...)
""", (optimization_id, name, prompt["name"], dataset["name"], ...))

# AFTER (✅ Fixed):
conn.execute("""
INSERT INTO optimizations (id, name, prompt, dataset, ...)
VALUES (?, ?, ?, ?, ...)
""", (optimization_id, name, prompt_id, dataset["name"], ...))
```

### 2. Implemented Dataset Structure Flattening
**File**: `sdk_worker.py`
```python
# Create flattened JSONL file for baseline evaluation
flattened_data = []
for sample in test_dataset.standardized_dataset:
flattened_sample = {
'input': sample['inputs']['input'], # Extract from nested
'answer': sample['outputs']['answer'] # Extract from nested
}
flattened_data.append(flattened_sample)

# Write to temporary file and create new dataset adapter
with tempfile.NamedTemporaryFile(mode='w', suffix='.jsonl', delete=False) as f:
for sample in flattened_data:
f.write(json.dumps(sample) + '\n')
temp_baseline_file = f.name

baseline_dataset_adapter = JSONDatasetAdapter({"input"}, {"answer"})
baseline_dataset_adapter.adapt(data_source=temp_baseline_file)
```

### 3. Implemented Proper Metric Aggregation
**File**: `sdk_worker.py`
```python
# BEFORE (❌ Empty):
def batch_apply(self, y_preds, y_trues):
pass # Not needed for Nova SDK

# AFTER (✅ Proper aggregation):
def batch_apply(self, y_preds, y_trues):
# Calculate average of individual scores
scores = [self.apply(pred, true) for pred, true in zip(y_preds, y_trues)]
return sum(scores) / len(scores) if scores else 0.0
```

### 4. Fixed Import Scoping
**File**: `sdk_worker.py`
- Removed duplicate `import json` and `import JSONDatasetAdapter` from functions
- Used global imports consistently

## Results

### Before Fix:
```
🔍 DEBUG - Baseline score from SDK Evaluator: None
❌ No baseline comparison possible
❌ Frontend showed "Baseline: 0%"
```

### After Fix:
```
🔍 DEBUG - Baseline score from SDK Evaluator: 0.36206666666666665
✅ Real baseline score calculated
✅ Proper baseline vs optimized comparison
✅ Individual scores: [0.113, 0.44, 1.0, 0.44, 0.113, ...]
✅ Aggregated score: 0.362 (36.2%)
```

## Impact

1. **Functional Baseline Evaluation**: SDK now properly evaluates baseline prompts
2. **Accurate Performance Metrics**: Real scores instead of None/0%
3. **Proper Optimization Comparison**: Can compare baseline vs optimized performance
4. **SDK Compatibility**: Frontend now follows official SDK workflow patterns
5. **Improved Debugging**: Comprehensive logging for troubleshooting

## Key Learnings

1. **SDK Integration**: Always follow official SDK patterns rather than custom implementations
2. **Data Structure Compatibility**: Ensure data formats match SDK expectations exactly
3. **Metric Implementation**: Both `apply()` and `batch_apply()` methods are required
4. **Import Management**: Avoid duplicate imports that can cause scoping issues
5. **Debugging Strategy**: Layer-by-layer debugging revealed multiple interconnected issues

## Files Modified

- `database.py` - Fixed prompt ID storage in optimizations
- `sdk_worker.py` - Dataset flattening, metric aggregation, import fixes
- `app.py` - JSON parsing fix for prompt retrieval

## Testing

Verified with multiple optimization runs:
- ✅ Baseline evaluation returns real scores (0.362, 0.445, etc.)
- ✅ No more "Parameter validation failed" in baseline evaluation
- ✅ Proper dataset structure handling
- ✅ Successful metric aggregation

## Future Considerations

1. **Performance**: Temporary file creation adds overhead - consider in-memory flattening
2. **Error Handling**: Add more robust error handling for edge cases
3. **Validation**: Add dataset structure validation before processing
4. **Monitoring**: Add metrics to track baseline evaluation success rates

---

**Status**: ✅ **RESOLVED** - Baseline evaluation now fully functional
**Date**: 2025-08-13
**Impact**: High - Core functionality restored
Loading