Spaces:
network01
/
Runtime error

akhaliq HF Staff commited on
Commit
9de4a40
·
1 Parent(s): 7523755

Fix backend crash: Make prompt imports optional with fallbacks

Browse files

Issue: Backend (port 8000) was crashing on startup, causing ECONNREFUSED errors
Root cause: New imports from anycoder_app.prompts and docs_manager were failing
due to Gradio dependencies that aren't available in backend-only mode

Fix:
- Wrap all anycoder_app imports in try/except blocks
- Provide fallback prompts if imports fail
- Backend will start successfully even if prompt imports fail
- Nested try/except: outer for basic prompts, inner for dynamic Gradio/ComfyUI prompts
- Add startup logging to track which prompts are loaded
- Backend now resilient to missing dependencies

This ensures:
✅ Backend always starts on port 8000
✅ Frontend can fetch /api/languages and /api/models
✅ Language and model dropdowns populate correctly
✅ System uses best available prompts (full or fallback)
✅ No more ECONNREFUSED errors

1 file changed +39 -21
backend_api.py+39-21