update
Browse filesFiles changed (2)
519 unmodified lines520521522523523524525525526527528529526530531532533534535536537538539540541542543544545546547548549550551552553527528529519 unmodified lines try: original_code = code # Special handling for transformers.js - extract only the === sections # Special handling for transformers.js - don't clean, pass through as-is # The parser will handle extracting the files from === markers if language == "transformers.js": # Find the first === marker first_marker = code.find('===') if first_marker == -1: # No markers found, return as-is return code return code # Find the last code section end (after the last ===) # Look for the last === marker last_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 newlines code_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 code cleaned_code = code[first_marker:code_end].strip() return cleaned_code # Special handling for ComfyUI JSON if language == "comfyui":17 unmodified lines1819202122232425262721222317 unmodified lines print(f"[Parser] Received code length: {len(code)} characters") print(f"[Parser] First 200 chars: {code[:200]}") # Check if code has === markers code_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")backend_api.py+3-30
backend_parsers.py-7