update
Browse filesFiles changed (2)
519 unmodified lines520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556519 unmodified linestry:original_code = code# Special handling for transformers.js - extract only the === sectionsif language == "transformers.js":# Find the first === markerfirst_marker = code.find('===')if first_marker == -1:# No markers found, return as-isreturn code# Find the last code section end (after the last ===)# Look for the last === markerlast_marker_start = code.rfind('===')if last_marker_start == -1:return code# Find the end of the last code section# This is typically followed by explanatory text starting with --- or multiple newlinescode_after_last_marker = code[last_marker_start:]# Find where the actual code section ends (look for --- or excessive explanatory text)end_markers = ['---', '\n\n\nThis ', '\n\n\n✨', '\n\n\n🎨', '\n\n\n🚀']code_end = len(code)for end_marker in end_markers:pos = code.find(end_marker, last_marker_start)if pos != -1 and pos < code_end:code_end = pos# Extract from first === to end of codecleaned_code = code[first_marker:code_end].strip()return cleaned_code# Special handling for ComfyUI JSONif language == "comfyui":519 unmodified lines520521522523524525526527528529519 unmodified linestry:original_code = code# Special handling for transformers.js - don't clean, pass through as-is# The parser will handle extracting the files from === markersif language == "transformers.js":return code# Special handling for ComfyUI JSONif language == "comfyui":
17 unmodified lines1819202122232425262728293017 unmodified linesprint(f"[Parser] Received code length: {len(code)} characters")print(f"[Parser] First 200 chars: {code[:200]}")# Check if code has === markerscode_stripped = code.strip()if '===' in code_stripped:print("[Parser] Code contains === markers, proceeding with parsing")else:print("[Parser] WARNING: No === markers found in code")# Check if code starts with HTML instead of markers (common LLM mistake)if code_stripped.startswith('<!DOCTYPE') or code_stripped.startswith('<html'):print("[Parser] WARNING: Code starts with HTML instead of === index.html === marker")17 unmodified lines18192021222317 unmodified linesprint(f"[Parser] Received code length: {len(code)} characters")print(f"[Parser] First 200 chars: {code[:200]}")# Check if code starts with HTML instead of markers (common LLM mistake)if code_stripped.startswith('<!DOCTYPE') or code_stripped.startswith('<html'):print("[Parser] WARNING: Code starts with HTML instead of === index.html === marker")
backend_api.py+3-30
backend_parsers.py-7