Spaces:
Running
Running
update system prompt
Browse files
app.py
CHANGED
|
@@ -725,8 +725,8 @@ This reference is automatically synced from https://www.gradio.app/llms.txt to e
|
|
| 725 |
"""
|
| 726 |
|
| 727 |
# Update the prompts
|
| 728 |
-
GRADIO_SYSTEM_PROMPT = base_prompt + docs_content + "\n\nAlways use the exact function signatures from this API reference and follow modern Gradio patterns."
|
| 729 |
-
GRADIO_SYSTEM_PROMPT_WITH_SEARCH = search_prompt + docs_content + "\n\nAlways use the exact function signatures from this API reference and follow modern Gradio patterns."
|
| 730 |
|
| 731 |
# Initialize Gradio documentation on startup
|
| 732 |
def initialize_gradio_docs():
|
|
@@ -758,7 +758,9 @@ If an image is provided, analyze it and use the visual information to better und
|
|
| 758 |
|
| 759 |
Always respond with code that can be executed or rendered directly.
|
| 760 |
|
| 761 |
-
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text. Do NOT add the language name at the top of the code output.
|
|
|
|
|
|
|
| 762 |
|
| 763 |
def validate_video_html(video_html: str) -> bool:
|
| 764 |
"""Validate that the video HTML is well-formed and safe to insert."""
|
|
@@ -870,6 +872,8 @@ Structural requirements:
|
|
| 870 |
- Keep everything in ONE file; inline CSS/JS as needed
|
| 871 |
|
| 872 |
Return ONLY the code inside a single ```html ... ``` code block. No additional text before or after.
|
|
|
|
|
|
|
| 873 |
"""
|
| 874 |
|
| 875 |
# ---------------------------------------------------------------------------
|
|
@@ -1025,7 +1029,9 @@ The index.html should contain the basic HTML structure and link to the CSS and J
|
|
| 1025 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 1026 |
The style.css should contain all the styling for the application.
|
| 1027 |
|
| 1028 |
-
Always output only the three code blocks as shown above, and do not include any explanations or extra text.
|
|
|
|
|
|
|
| 1029 |
|
| 1030 |
SVELTE_SYSTEM_PROMPT = """You are an expert Svelte developer creating a modern Svelte application.
|
| 1031 |
|
|
@@ -1073,6 +1079,8 @@ Requirements:
|
|
| 1073 |
7. Follow accessibility best practices
|
| 1074 |
8. Use Svelte's reactive features effectively
|
| 1075 |
9. Include proper component structure and organization (only what's needed)
|
|
|
|
|
|
|
| 1076 |
"""
|
| 1077 |
|
| 1078 |
SVELTE_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert Svelte developer. You have access to real-time web search.
|
|
@@ -1121,6 +1129,8 @@ Requirements:
|
|
| 1121 |
7. Accessibility best practices
|
| 1122 |
8. Use search to apply current best practices
|
| 1123 |
9. Keep component structure organized and minimal
|
|
|
|
|
|
|
| 1124 |
"""
|
| 1125 |
|
| 1126 |
TRANSFORMERS_JS_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert web developer creating a transformers.js application. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for transformers.js.
|
|
@@ -1166,7 +1176,9 @@ The index.html should contain the basic HTML structure and link to the CSS and J
|
|
| 1166 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 1167 |
The style.css should contain all the styling for the application.
|
| 1168 |
|
| 1169 |
-
Always output only the three code blocks as shown above, and do not include any explanations or extra text.
|
|
|
|
|
|
|
| 1170 |
|
| 1171 |
# Gradio system prompts will be dynamically populated by update_gradio_system_prompts()
|
| 1172 |
GRADIO_SYSTEM_PROMPT = ""
|
|
@@ -1176,7 +1188,9 @@ GRADIO_SYSTEM_PROMPT_WITH_SEARCH = ""
|
|
| 1176 |
|
| 1177 |
# All Gradio API documentation is now dynamically loaded from https://www.gradio.app/llms.txt
|
| 1178 |
|
| 1179 |
-
GENERIC_SYSTEM_PROMPT = """You are an expert {language} developer. Write clean, idiomatic, and runnable {language} code for the user's request. If possible, include comments and best practices. Output ONLY the code inside a ``` code block, and do not include any explanations or extra text. If the user provides a file or other context, use it as a reference. If the code is for a script or app, make it as self-contained as possible. Do NOT add the language name at the top of the code output.
|
|
|
|
|
|
|
| 1180 |
|
| 1181 |
# System prompt with search capability
|
| 1182 |
HTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.
|
|
@@ -1206,7 +1220,9 @@ If an image is provided, analyze it and use the visual information to better und
|
|
| 1206 |
|
| 1207 |
Always respond with code that can be executed or rendered directly.
|
| 1208 |
|
| 1209 |
-
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text. Do NOT add the language name at the top of the code output.
|
|
|
|
|
|
|
| 1210 |
|
| 1211 |
# Multi-page static HTML project prompt (generic, production-style structure)
|
| 1212 |
MULTIPAGE_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.
|
|
@@ -1243,6 +1259,8 @@ General requirements:
|
|
| 1243 |
- Include basic SEO meta tags in <head>
|
| 1244 |
- Include a footer on all pages
|
| 1245 |
- Avoid external CSS/JS frameworks (optional: CDN fonts/icons allowed)
|
|
|
|
|
|
|
| 1246 |
"""
|
| 1247 |
|
| 1248 |
# Multi-page with search augmentation
|
|
@@ -1254,6 +1272,8 @@ Follow the same file output format and project structure as specified:
|
|
| 1254 |
=== filename === blocks for each file (no Markdown fences)
|
| 1255 |
|
| 1256 |
Use search results to apply current best practices in accessibility, semantics, responsive meta tags, and performance (preconnect, responsive images).
|
|
|
|
|
|
|
| 1257 |
"""
|
| 1258 |
|
| 1259 |
# Dynamic multi-page (model decides files) prompts
|
|
@@ -1284,6 +1304,8 @@ General requirements:
|
|
| 1284 |
- Include basic SEO meta tags in <head> for the entrypoint
|
| 1285 |
- Include a footer on all major pages when multiple pages are present
|
| 1286 |
- Avoid external CSS/JS frameworks (optional: CDN fonts/icons allowed)
|
|
|
|
|
|
|
| 1287 |
"""
|
| 1288 |
|
| 1289 |
DYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.
|
|
@@ -1293,11 +1315,15 @@ Create a production-ready website using ONLY HTML, CSS, and vanilla JavaScript.
|
|
| 1293 |
Follow the same output format and file selection policy as above (=== filename === blocks; model decides which files to create; ensure index.html unless explicitly not needed).
|
| 1294 |
|
| 1295 |
Use search results to apply current best practices in accessibility, semantics, responsive meta tags, and performance (preconnect, responsive images).
|
|
|
|
|
|
|
| 1296 |
"""
|
| 1297 |
|
| 1298 |
GENERIC_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert {language} developer. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for {language}.
|
| 1299 |
|
| 1300 |
-
Write clean, idiomatic, and runnable {language} code for the user's request. If possible, include comments and best practices. Output ONLY the code inside a ``` code block, and do not include any explanations or extra text. If the user provides a file or other context, use it as a reference. If the code is for a script or app, make it as self-contained as possible. Do NOT add the language name at the top of the code output.
|
|
|
|
|
|
|
| 1301 |
|
| 1302 |
# Follow-up system prompt for modifying existing HTML files
|
| 1303 |
FollowUpSystemPrompt = f"""You are an expert web developer modifying an existing project.
|
|
@@ -1369,7 +1395,9 @@ Removing the paragraph...
|
|
| 1369 |
<p>This paragraph will be deleted.</p>
|
| 1370 |
{DIVIDER}
|
| 1371 |
{REPLACE_END}
|
| 1372 |
-
```
|
|
|
|
|
|
|
| 1373 |
|
| 1374 |
# Follow-up system prompt for modifying existing transformers.js applications
|
| 1375 |
TransformersJSFollowUpSystemPrompt = f"""You are an expert web developer modifying an existing transformers.js application.
|
|
@@ -1447,7 +1475,9 @@ Fixing transformers.js CDN loading error...
|
|
| 1447 |
{DIVIDER}
|
| 1448 |
<script type="module" src="https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2"></script>
|
| 1449 |
{REPLACE_END}
|
| 1450 |
-
```
|
|
|
|
|
|
|
| 1451 |
|
| 1452 |
# Available models
|
| 1453 |
AVAILABLE_MODELS = [
|
|
|
|
| 725 |
"""
|
| 726 |
|
| 727 |
# Update the prompts
|
| 728 |
+
GRADIO_SYSTEM_PROMPT = base_prompt + docs_content + "\n\nAlways use the exact function signatures from this API reference and follow modern Gradio patterns.\n\nIMPORTANT: Always include \"Built with anycoder\" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"
|
| 729 |
+
GRADIO_SYSTEM_PROMPT_WITH_SEARCH = search_prompt + docs_content + "\n\nAlways use the exact function signatures from this API reference and follow modern Gradio patterns.\n\nIMPORTANT: Always include \"Built with anycoder\" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"
|
| 730 |
|
| 731 |
# Initialize Gradio documentation on startup
|
| 732 |
def initialize_gradio_docs():
|
|
|
|
| 758 |
|
| 759 |
Always respond with code that can be executed or rendered directly.
|
| 760 |
|
| 761 |
+
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text. Do NOT add the language name at the top of the code output.
|
| 762 |
+
|
| 763 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 764 |
|
| 765 |
def validate_video_html(video_html: str) -> bool:
|
| 766 |
"""Validate that the video HTML is well-formed and safe to insert."""
|
|
|
|
| 872 |
- Keep everything in ONE file; inline CSS/JS as needed
|
| 873 |
|
| 874 |
Return ONLY the code inside a single ```html ... ``` code block. No additional text before or after.
|
| 875 |
+
|
| 876 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 877 |
"""
|
| 878 |
|
| 879 |
# ---------------------------------------------------------------------------
|
|
|
|
| 1029 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 1030 |
The style.css should contain all the styling for the application.
|
| 1031 |
|
| 1032 |
+
Always output only the three code blocks as shown above, and do not include any explanations or extra text.
|
| 1033 |
+
|
| 1034 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1035 |
|
| 1036 |
SVELTE_SYSTEM_PROMPT = """You are an expert Svelte developer creating a modern Svelte application.
|
| 1037 |
|
|
|
|
| 1079 |
7. Follow accessibility best practices
|
| 1080 |
8. Use Svelte's reactive features effectively
|
| 1081 |
9. Include proper component structure and organization (only what's needed)
|
| 1082 |
+
|
| 1083 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 1084 |
"""
|
| 1085 |
|
| 1086 |
SVELTE_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert Svelte developer. You have access to real-time web search.
|
|
|
|
| 1129 |
7. Accessibility best practices
|
| 1130 |
8. Use search to apply current best practices
|
| 1131 |
9. Keep component structure organized and minimal
|
| 1132 |
+
|
| 1133 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 1134 |
"""
|
| 1135 |
|
| 1136 |
TRANSFORMERS_JS_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert web developer creating a transformers.js application. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for transformers.js.
|
|
|
|
| 1176 |
The index.js should contain all the JavaScript logic including transformers.js integration.
|
| 1177 |
The style.css should contain all the styling for the application.
|
| 1178 |
|
| 1179 |
+
Always output only the three code blocks as shown above, and do not include any explanations or extra text.
|
| 1180 |
+
|
| 1181 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1182 |
|
| 1183 |
# Gradio system prompts will be dynamically populated by update_gradio_system_prompts()
|
| 1184 |
GRADIO_SYSTEM_PROMPT = ""
|
|
|
|
| 1188 |
|
| 1189 |
# All Gradio API documentation is now dynamically loaded from https://www.gradio.app/llms.txt
|
| 1190 |
|
| 1191 |
+
GENERIC_SYSTEM_PROMPT = """You are an expert {language} developer. Write clean, idiomatic, and runnable {language} code for the user's request. If possible, include comments and best practices. Output ONLY the code inside a ``` code block, and do not include any explanations or extra text. If the user provides a file or other context, use it as a reference. If the code is for a script or app, make it as self-contained as possible. Do NOT add the language name at the top of the code output.
|
| 1192 |
+
|
| 1193 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1194 |
|
| 1195 |
# System prompt with search capability
|
| 1196 |
HTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.
|
|
|
|
| 1220 |
|
| 1221 |
Always respond with code that can be executed or rendered directly.
|
| 1222 |
|
| 1223 |
+
Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text. Do NOT add the language name at the top of the code output.
|
| 1224 |
+
|
| 1225 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1226 |
|
| 1227 |
# Multi-page static HTML project prompt (generic, production-style structure)
|
| 1228 |
MULTIPAGE_HTML_SYSTEM_PROMPT = """You are an expert front-end developer.
|
|
|
|
| 1259 |
- Include basic SEO meta tags in <head>
|
| 1260 |
- Include a footer on all pages
|
| 1261 |
- Avoid external CSS/JS frameworks (optional: CDN fonts/icons allowed)
|
| 1262 |
+
|
| 1263 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 1264 |
"""
|
| 1265 |
|
| 1266 |
# Multi-page with search augmentation
|
|
|
|
| 1272 |
=== filename === blocks for each file (no Markdown fences)
|
| 1273 |
|
| 1274 |
Use search results to apply current best practices in accessibility, semantics, responsive meta tags, and performance (preconnect, responsive images).
|
| 1275 |
+
|
| 1276 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 1277 |
"""
|
| 1278 |
|
| 1279 |
# Dynamic multi-page (model decides files) prompts
|
|
|
|
| 1304 |
- Include basic SEO meta tags in <head> for the entrypoint
|
| 1305 |
- Include a footer on all major pages when multiple pages are present
|
| 1306 |
- Avoid external CSS/JS frameworks (optional: CDN fonts/icons allowed)
|
| 1307 |
+
|
| 1308 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 1309 |
"""
|
| 1310 |
|
| 1311 |
DYNAMIC_MULTIPAGE_HTML_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert front-end developer. You have access to real-time web search.
|
|
|
|
| 1315 |
Follow the same output format and file selection policy as above (=== filename === blocks; model decides which files to create; ensure index.html unless explicitly not needed).
|
| 1316 |
|
| 1317 |
Use search results to apply current best practices in accessibility, semantics, responsive meta tags, and performance (preconnect, responsive images).
|
| 1318 |
+
|
| 1319 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder
|
| 1320 |
"""
|
| 1321 |
|
| 1322 |
GENERIC_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert {language} developer. You have access to real-time web search. When needed, use web search to find the latest information, best practices, or specific technologies for {language}.
|
| 1323 |
|
| 1324 |
+
Write clean, idiomatic, and runnable {language} code for the user's request. If possible, include comments and best practices. Output ONLY the code inside a ``` code block, and do not include any explanations or extra text. If the user provides a file or other context, use it as a reference. If the code is for a script or app, make it as self-contained as possible. Do NOT add the language name at the top of the code output.
|
| 1325 |
+
|
| 1326 |
+
IMPORTANT: Always include "Built with anycoder" as clickable text in the header/top section of your application that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1327 |
|
| 1328 |
# Follow-up system prompt for modifying existing HTML files
|
| 1329 |
FollowUpSystemPrompt = f"""You are an expert web developer modifying an existing project.
|
|
|
|
| 1395 |
<p>This paragraph will be deleted.</p>
|
| 1396 |
{DIVIDER}
|
| 1397 |
{REPLACE_END}
|
| 1398 |
+
```
|
| 1399 |
+
|
| 1400 |
+
IMPORTANT: When modifying applications, preserve any existing "Built with anycoder" attribution in the header or add it if missing as clickable text that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1401 |
|
| 1402 |
# Follow-up system prompt for modifying existing transformers.js applications
|
| 1403 |
TransformersJSFollowUpSystemPrompt = f"""You are an expert web developer modifying an existing transformers.js application.
|
|
|
|
| 1475 |
{DIVIDER}
|
| 1476 |
<script type="module" src="https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2"></script>
|
| 1477 |
{REPLACE_END}
|
| 1478 |
+
```
|
| 1479 |
+
|
| 1480 |
+
IMPORTANT: When modifying transformers.js applications, preserve any existing "Built with anycoder" attribution in the header or add it if missing as clickable text that links to https://huggingface.co/spaces/akhaliq/anycoder"""
|
| 1481 |
|
| 1482 |
# Available models
|
| 1483 |
AVAILABLE_MODELS = [
|