Spaces:
network01
/
Runtime error

akhaliq HF Staff commited on
Commit
7523755
·
1 Parent(s): 0fb9638

Fix streaming and use proper system prompts

Browse files

Issues fixed:
1. Streaming not working properly - code only appeared at the end
2. Not using language-specific prompts from prompts.py

Backend changes (backend_api.py):
- Import system prompts from anycoder_app/prompts.py
- Initialize Gradio and ComfyUI prompts on startup via docs_manager
- Use language-specific prompts (HTML, Gradio, Streamlit, React, etc.)
- Add proper system prompt selection based on language parameter
- Improve streaming with smaller sleep intervals (0.01s) for immediate flush
- Add chunk counting and logging for debugging
- Add detailed logging for prompt selection

Frontend changes (page.tsx, api.ts):
- Add console logging to track chunk reception
- Log SSE events for debugging
- Log buffer sizes and chunk lengths
- Track generation completion with total code length

This ensures:
✅ Proper language-specific prompts are used (HTML, Gradio, Streamlit, etc.)
✅ Streaming works immediately with chunks appearing in real-time
✅ Better debugging with console logs
✅ Backend properly flushes chunks to frontend

3 files changed +48 -3
Files changed (3)
backend_api.py+43-3
frontend/src/app/page.tsx+2
frontend/src/lib/api.ts+3