Spaces:
Running
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
- backend_api.py +19 -41
|
@@ -19,47 +19,25 @@ import os
|
|
| 19 |
from huggingface_hub import InferenceClient
|
| 20 |
import httpx
|
| 21 |
|
| 22 |
-
# Import system prompts for code generation
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
GRADIO_SYSTEM_PROMPT = GRADIO_PROMPT_UPDATED
|
| 42 |
-
JSON_SYSTEM_PROMPT = JSON_PROMPT_UPDATED
|
| 43 |
-
print("[Startup] System prompts initialized successfully")
|
| 44 |
-
except Exception as e:
|
| 45 |
-
print(f"[Startup] Warning: Could not initialize dynamic prompts: {e}")
|
| 46 |
-
# Use fallback prompts
|
| 47 |
-
GRADIO_SYSTEM_PROMPT = "You are an expert Gradio developer. Create complete, working Gradio applications."
|
| 48 |
-
JSON_SYSTEM_PROMPT = "You are an expert at generating JSON configurations. Create valid, well-structured JSON."
|
| 49 |
-
|
| 50 |
-
print("[Startup] System prompts loaded successfully")
|
| 51 |
-
|
| 52 |
-
except Exception as e:
|
| 53 |
-
print(f"[Startup] ERROR: Could not import prompts from anycoder_app: {e}")
|
| 54 |
-
print("[Startup] Using basic fallback prompts")
|
| 55 |
-
# Define minimal fallback prompts
|
| 56 |
-
HTML_SYSTEM_PROMPT = "You are an expert web developer. Create complete HTML applications with CSS and JavaScript."
|
| 57 |
-
TRANSFORMERS_JS_SYSTEM_PROMPT = "You are an expert at creating transformers.js applications. Generate complete working code."
|
| 58 |
-
STREAMLIT_SYSTEM_PROMPT = "You are an expert Streamlit developer. Create complete Streamlit applications."
|
| 59 |
-
REACT_SYSTEM_PROMPT = "You are an expert React developer. Create complete React applications with Next.js."
|
| 60 |
-
GRADIO_SYSTEM_PROMPT = "You are an expert Gradio developer. Create complete, working Gradio applications."
|
| 61 |
-
JSON_SYSTEM_PROMPT = "You are an expert at generating JSON configurations. Create valid, well-structured JSON."
|
| 62 |
-
GENERIC_SYSTEM_PROMPT = "You are an expert {language} developer. Create complete, working {language} applications."
|
| 63 |
|
| 64 |
# Define models and languages here to avoid importing Gradio UI
|
| 65 |
AVAILABLE_MODELS = [
|
|
|
|
| 19 |
from huggingface_hub import InferenceClient
|
| 20 |
import httpx
|
| 21 |
|
| 22 |
+
# Import system prompts for code generation
|
| 23 |
+
# These come from anycoder_app which has all the detailed prompts
|
| 24 |
+
from anycoder_app.prompts import (
|
| 25 |
+
HTML_SYSTEM_PROMPT,
|
| 26 |
+
TRANSFORMERS_JS_SYSTEM_PROMPT,
|
| 27 |
+
STREAMLIT_SYSTEM_PROMPT,
|
| 28 |
+
REACT_SYSTEM_PROMPT,
|
| 29 |
+
GENERIC_SYSTEM_PROMPT
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# Initialize dynamic Gradio and ComfyUI system prompts with full API docs
|
| 33 |
+
from anycoder_app.docs_manager import update_gradio_system_prompts, update_json_system_prompts
|
| 34 |
+
print("[Startup] Initializing Gradio and ComfyUI system prompts with API documentation...")
|
| 35 |
+
update_gradio_system_prompts()
|
| 36 |
+
update_json_system_prompts()
|
| 37 |
+
|
| 38 |
+
# Import the now-populated prompts
|
| 39 |
+
from anycoder_app.prompts import GRADIO_SYSTEM_PROMPT, JSON_SYSTEM_PROMPT
|
| 40 |
+
print("[Startup] β
All system prompts loaded successfully with full API documentation")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
# Define models and languages here to avoid importing Gradio UI
|
| 43 |
AVAILABLE_MODELS = [
|