Spaces:
Runtime error
Runtime error
fix transforemrs js issue
Browse filesFiles changed (2)
- backend_parsers.py+19-7
- backend_prompts.py+50-10
61 unmodified lines62636465666768656667686970717172737475767377787980818275838485868788899061 unmodified lines # Fallback: support === index.html === format if any file is missing if not (files['index.html'] and files['index.js'] and files['style.css']): # Use regex to extract sections html_fallback = re.search(r'===\s*index\.html\s*===\s*\n([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE) js_fallback = re.search(r'===\s*index\.js\s*===\s*\n([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE) css_fallback = re.search(r'===\s*style\.css\s*===\s*\n([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE) # Use regex to extract sections - match === markers with optional whitespace and newlines html_fallback = re.search(r'===\s*index\.html\s*===\s*[\r\n]+([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE) js_fallback = re.search(r'===\s*index\.js\s*===\s*[\r\n]+([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE) css_fallback = re.search(r'===\s*style\.css\s*===\s*[\r\n]+([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE) if html_fallback: files['index.html'] = html_fallback.group(1).strip() content = html_fallback.group(1).strip() # Remove code block markers if present content = re.sub(r'^```\w*\s*[\r\n]+', '', content) content = re.sub(r'[\r\n]+```\s*$', '', content) files['index.html'] = content.strip() if js_fallback: files['index.js'] = js_fallback.group(1).strip() content = js_fallback.group(1).strip() # Remove code block markers if present content = re.sub(r'^```\w*\s*[\r\n]+', '', content) content = re.sub(r'[\r\n]+```\s*$', '', content) files['index.js'] = content.strip() if css_fallback: files['style.css'] = css_fallback.group(1).strip() content = css_fallback.group(1).strip() # Remove code block markers if present content = re.sub(r'^```\w*\s*[\r\n]+', '', content) content = re.sub(r'[\r\n]+```\s*$', '', content) files['style.css'] = content.strip() # Additional fallback: extract from numbered sections or file headers if not (files['index.html'] and files['index.js'] and files['style.css']):39 unmodified lines404142434344454647484950515253545547565758596061506263646566676869707172737475767778798052538182838485868788899054 unmodified lines14514614711411511611711814814915015115215315415515615715815916016139 unmodified lines=== index.html ===<!DOCTYPE html><html lang="en"><!-- index.html content here --><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Your App Title</title> <link rel="stylesheet" href="style.css"></head><body> <!-- Your complete HTML content here --> <script type="module" src="index.js"></script></body></html>
=== index.js ===// index.js content hereimport { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.0';
// Your complete JavaScript code here// Include all functionality, event listeners, and logic
=== style.css ===/* style.css content here *//* Your complete CSS styles here *//* Include all styling for the application */
**CRITICAL FORMATTING RULES:**1. Start each file IMMEDIATELY after the === marker (on the next line)2. DO NOT use markdown code blocks (```html, ```javascript, ```css) - these will cause parsing errors3. DO NOT leave any file empty - each file MUST contain complete, functional code4. ONLY use the === filename === format shown above5. Make sure there is a blank line between each file section6. Each file must be complete and ready to deploy - no placeholders or comments like "// add code here"
**Example of CORRECT format:**=== index.html ===<!DOCTYPE html><html><head>...</head><body>...</body></html>
DO NOT use markdown code blocks (```html, ```javascript, ```css).ONLY use the === filename === format shown above.=== index.js ===import { pipeline } from '...';// Complete working code
=== style.css ===body { margin: 0; }/* Complete styling */
Requirements:1. Create a modern, responsive web application using transformers.js54 unmodified lines
Consider providing users with options to choose device (CPU/GPU) and quantization level based on their needs.
The index.html should contain the basic HTML structure and link to the CSS and JS files.The index.js should contain all the JavaScript logic including transformers.js integration.The style.css should contain all the styling for the application.
Generate complete, working code files as shown above.**File Content Requirements:**- **index.html**: Complete HTML structure with proper DOCTYPE, meta tags, links to CSS/JS files, and full body content- **index.js**: Complete JavaScript logic with transformers.js imports and ALL functionality implemented- **style.css**: Complete styling for the entire application - NO empty or placeholder styles
**🚨 FINAL REMINDERS:**1. Use the === filename === markers EXACTLY as shown in the examples2. DO NOT use markdown code blocks (```html, ```js, ```css)3. ALL THREE files must be complete and functional - no placeholders or "TODO" comments4. Start each file's content immediately on the line after the === marker5. Ensure each file has actual content - empty files will cause deployment failure
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
backend_parsers.py+19-7
backend_prompts.py+50-10