fix index issue
Browse files- backend_parsers.py +8 -1
backend_parsers.py
CHANGED
|
@@ -15,8 +15,15 @@ def parse_transformers_js_output(code: str) -> Dict[str, str]:
|
|
| 15 |
Uses comprehensive parsing patterns to handle various LLM output formats.
|
| 16 |
Updated to use transformers.js v3.8.0 CDN.
|
| 17 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# Check if code starts with HTML instead of markers (common LLM mistake)
|
| 19 |
-
if
|
| 20 |
print("[Parser] WARNING: Code starts with HTML instead of === index.html === marker")
|
| 21 |
print("[Parser] Attempting to extract files from malformed output...")
|
| 22 |
|
|
|
|
| 15 |
Uses comprehensive parsing patterns to handle various LLM output formats.
|
| 16 |
Updated to use transformers.js v3.8.0 CDN.
|
| 17 |
"""
|
| 18 |
+
# Auto-fix: If code doesn't start with === index.html ===, add it
|
| 19 |
+
code_stripped = code.strip()
|
| 20 |
+
if not code_stripped.startswith('==='):
|
| 21 |
+
print("[Parser] Auto-fixing: Adding missing === index.html === marker")
|
| 22 |
+
code = '=== index.html ===\n' + code
|
| 23 |
+
code_stripped = code.strip()
|
| 24 |
+
|
| 25 |
# Check if code starts with HTML instead of markers (common LLM mistake)
|
| 26 |
+
if code_stripped.startswith('<!DOCTYPE') or code_stripped.startswith('<html'):
|
| 27 |
print("[Parser] WARNING: Code starts with HTML instead of === index.html === marker")
|
| 28 |
print("[Parser] Attempting to extract files from malformed output...")
|
| 29 |
|