Use full system prompts with Gradio dependencies
Browse filesNow that Gradio dependencies are installed in requirements.txt,
we can directly import and use the full expert-level prompts from
anycoder_app without fallbacks.
Changes:
- Remove all try/except fallback logic
- Directly import prompts from anycoder_app.prompts
- Initialize Gradio and ComfyUI prompts with update_gradio_system_prompts()
- Load full API documentation into prompts at startup
- Clean, simple imports with detailed startup logging
The backend now uses the complete, expert-level system prompts:
✅ HTML_SYSTEM_PROMPT - Full HTML/CSS/JS guidelines
✅ GRADIO_SYSTEM_PROMPT - Complete Gradio API docs from gradio.app/llms.txt
✅ STREAMLIT_SYSTEM_PROMPT - Streamlit with Docker requirements
✅ REACT_SYSTEM_PROMPT - Next.js with Tailwind guidelines
✅ TRANSFORMERS_JS_SYSTEM_PROMPT - Transformers.js patterns
✅ JSON_SYSTEM_PROMPT - ComfyUI API docs from docs.comfy.org/llms.txt
✅ All prompts include 'Built with anycoder' attribution rules
18 unmodified lines19202122232425262728293031323334353637383940414243444546474849505152535455565758596061622223242526272829303132333435363738394041424318 unmodified linesfrom huggingface_hub import InferenceClientimport httpx
# Import system prompts for code generation - use fallback if imports failtry: from anycoder_app.prompts import ( HTML_SYSTEM_PROMPT, TRANSFORMERS_JS_SYSTEM_PROMPT, STREAMLIT_SYSTEM_PROMPT, REACT_SYSTEM_PROMPT, GENERIC_SYSTEM_PROMPT ) # Try to import and initialize dynamic prompts (Gradio, ComfyUI) try: from anycoder_app.docs_manager import update_gradio_system_prompts, update_json_system_prompts from anycoder_app.prompts import GRADIO_SYSTEM_PROMPT, JSON_SYSTEM_PROMPT print("[Startup] Initializing Gradio and ComfyUI system prompts...") update_gradio_system_prompts() update_json_system_prompts() # Re-import to get updated prompts from anycoder_app.prompts import GRADIO_SYSTEM_PROMPT as GRADIO_PROMPT_UPDATED from anycoder_app.prompts import JSON_SYSTEM_PROMPT as JSON_PROMPT_UPDATED GRADIO_SYSTEM_PROMPT = GRADIO_PROMPT_UPDATED JSON_SYSTEM_PROMPT = JSON_PROMPT_UPDATED print("[Startup] System prompts initialized successfully") except Exception as e: print(f"[Startup] Warning: Could not initialize dynamic prompts: {e}") # Use fallback prompts GRADIO_SYSTEM_PROMPT = "You are an expert Gradio developer. Create complete, working Gradio applications." JSON_SYSTEM_PROMPT = "You are an expert at generating JSON configurations. Create valid, well-structured JSON." print("[Startup] System prompts loaded successfully") except Exception as e: print(f"[Startup] ERROR: Could not import prompts from anycoder_app: {e}") print("[Startup] Using basic fallback prompts") # Define minimal fallback prompts HTML_SYSTEM_PROMPT = "You are an expert web developer. Create complete HTML applications with CSS and JavaScript." TRANSFORMERS_JS_SYSTEM_PROMPT = "You are an expert at creating transformers.js applications. Generate complete working code." STREAMLIT_SYSTEM_PROMPT = "You are an expert Streamlit developer. Create complete Streamlit applications." REACT_SYSTEM_PROMPT = "You are an expert React developer. Create complete React applications with Next.js." GRADIO_SYSTEM_PROMPT = "You are an expert Gradio developer. Create complete, working Gradio applications." JSON_SYSTEM_PROMPT = "You are an expert at generating JSON configurations. Create valid, well-structured JSON." GENERIC_SYSTEM_PROMPT = "You are an expert {language} developer. Create complete, working {language} applications."# Import system prompts for code generation# These come from anycoder_app which has all the detailed promptsfrom anycoder_app.prompts import ( HTML_SYSTEM_PROMPT, TRANSFORMERS_JS_SYSTEM_PROMPT, STREAMLIT_SYSTEM_PROMPT, REACT_SYSTEM_PROMPT, GENERIC_SYSTEM_PROMPT)
# Initialize dynamic Gradio and ComfyUI system prompts with full API docsfrom anycoder_app.docs_manager import update_gradio_system_prompts, update_json_system_promptsprint("[Startup] Initializing Gradio and ComfyUI system prompts with API documentation...")update_gradio_system_prompts()update_json_system_prompts()
# Import the now-populated promptsfrom anycoder_app.prompts import GRADIO_SYSTEM_PROMPT, JSON_SYSTEM_PROMPTprint("[Startup] ✅ All system prompts loaded successfully with full API documentation")
# Define models and languages here to avoid importing Gradio UIAVAILABLE_MODELS = [