-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
π Problem Description
LLM outputs are generating inconsistent JSON formats, causing frontend display issues:
Current Problematic Formats
// Format 1: recommendations wrapper (current issue)
{"recommendations": [{"type": "deepen", "title": "...", "description": "..."}]}
// Format 2: options wrapper
{"type": "deepen", "options": [{"title": "...", "description": "..."}]}
// Format 3: direct array
[{"type": "deepen", "title": "...", "description": "..."}]Expected Format
{"type": "deepen", "content": "...", "describe": "..."}
{"type": "next", "content": "...", "describe": "..."}π Root Cause Analysis
Technical Analysis Confirms:
- β Parsing logic works correctly (tested with all formats)
- β
Data flow from
splitContentAndOptionsβmergeOptionsβsetOptionsis functional - β Root Issue: Inconsistent LLM output formats requiring continuous technical fixes
π Proposed Solution: Prompt Engineering Standardization
Strategy: Fix at the Source
Rather than maintaining complex parsing logic for every possible format variation, standardize the LLM output through improved prompt engineering.
Implementation Plan
1. Update nextStepJsonl.system.zh.j2
- Add strict format constraints
- Remove ambiguous instructions
- Provide clear positive/negative examples
- Enforce field name consistency
2. Enhanced Validation
- Add prompt validation examples
- Test with multiple LLM models
- Ensure consistent output quality
3. Gradual Rollout
- Test new prompt extensively
- Maintain backward compatibility during transition
- Monitor success rates
β Expected Benefits
- Stability: Eliminate format inconsistency at source
- Maintainability: Reduce technical debt from format-specific parsing
- Performance: Simpler parsing logic = faster processing
- Reliability: Predictable output format = fewer edge cases
π§ Technical Implementation
Files to Update
src/prompt/nextStepJsonl.system.zh.j2- Primary prompt templatesrc/prompt/nextStepJsonl.system.en.j2- English equivalent- Add validation examples and test cases
Validation Criteria
- β LLM outputs exactly 6 lines of valid JSONL
- β Each line is a complete JSON object with correct fields
- β No wrapper objects or arrays
- β Consistent field names (content/describe, not title/description)
π― Success Metrics
- Zero format parsing failures after implementation
- Consistent 6 options output per generation
- No need for format-specific technical patches
π Timeline
- Phase 1: Update prompt templates (2-3 hours)
- Phase 2: Extensive testing with multiple models (1 day)
- Phase 3: Production deployment and monitoring (1 day)
π Related Issues
This addresses the recurring pattern of LLM format inconsistencies and provides a sustainable long-term solution.
Priority: High
Type: Enhancement/Bug Fix
Component: Prompt Engineering, LLM Integration
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels