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 lines192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646518 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_promptsfrom anycoder_app.prompts import GRADIO_SYSTEM_PROMPT, JSON_SYSTEM_PROMPTprint("[Startup] Initializing Gradio and ComfyUI system prompts...")update_gradio_system_prompts()update_json_system_prompts()# Re-import to get updated promptsfrom anycoder_app.prompts import GRADIO_SYSTEM_PROMPT as GRADIO_PROMPT_UPDATEDfrom anycoder_app.prompts import JSON_SYSTEM_PROMPT as JSON_PROMPT_UPDATEDGRADIO_SYSTEM_PROMPT = GRADIO_PROMPT_UPDATEDJSON_SYSTEM_PROMPT = JSON_PROMPT_UPDATEDprint("[Startup] System prompts initialized successfully")except Exception as e:print(f"[Startup] Warning: Could not initialize dynamic prompts: {e}")# Use fallback promptsGRADIO_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 promptsHTML_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."# Define models and languages here to avoid importing Gradio UIAVAILABLE_MODELS = [18 unmodified lines1920212223242526272829303132333435363738394041424318 unmodified linesfrom huggingface_hub import InferenceClientimport httpx# 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 = [