Spaces:
Running
Running
update system prompt
Browse files
app.py
CHANGED
@@ -185,7 +185,9 @@ def update_gradio_system_prompts():
|
|
185 |
# Base system prompt
|
186 |
base_prompt = """You are an expert Gradio developer. Write clean, idiomatic, and runnable Gradio applications for the user's request. Use the latest Gradio API 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. Make the app as self-contained as possible. Do NOT add the language name at the top of the code output.
|
187 |
|
188 |
-
π¨
|
|
|
|
|
189 |
|
190 |
## ZeroGPU Integration (MANDATORY)
|
191 |
|
@@ -452,7 +454,9 @@ This reference is automatically synced from https://www.gradio.app/llms.txt to e
|
|
452 |
# Search-enabled prompt
|
453 |
search_prompt = """You are an expert Gradio developer with access to real-time web search. Write clean, idiomatic, and runnable Gradio applications for the user's request. Use the latest Gradio API and best practices. When needed, use web search to find current best practices or verify latest Gradio features. 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. Make the app as self-contained as possible. Do NOT add the language name at the top of the code output.
|
454 |
|
455 |
-
π¨
|
|
|
|
|
456 |
|
457 |
## ZeroGPU Integration (MANDATORY)
|
458 |
|
@@ -5239,6 +5243,10 @@ Generate the exact search/replace blocks needed to make these changes."""
|
|
5239 |
except Exception:
|
5240 |
pass
|
5241 |
|
|
|
|
|
|
|
|
|
5242 |
# Choose system prompt based on context
|
5243 |
if has_existing_content:
|
5244 |
# Use follow-up prompt for modifying existing content
|
|
|
185 |
# Base system prompt
|
186 |
base_prompt = """You are an expert Gradio developer. Write clean, idiomatic, and runnable Gradio applications for the user's request. Use the latest Gradio API 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. Make the app as self-contained as possible. Do NOT add the language name at the top of the code output.
|
187 |
|
188 |
+
π¨ IMPORTANT: If the user is asking to use external APIs (like OpenRouter, OpenAI API, Hugging Face Inference API, etc.), DO NOT use @spaces.GPU decorators or any ZeroGPU features. External APIs handle the model inference remotely, so GPU allocation on the Spaces instance is not needed.
|
189 |
+
|
190 |
+
π¨ CRITICAL REQUIREMENT: If the user provides ANY diffusion model code (FLUX, Stable Diffusion, etc.) that runs locally (not via API), you MUST implement ZeroGPU ahead-of-time (AoT) compilation. This is mandatory and provides 1.3x-1.8x performance improvements. Do not create basic Gradio apps without AoT optimization for diffusion models.
|
191 |
|
192 |
## ZeroGPU Integration (MANDATORY)
|
193 |
|
|
|
454 |
# Search-enabled prompt
|
455 |
search_prompt = """You are an expert Gradio developer with access to real-time web search. Write clean, idiomatic, and runnable Gradio applications for the user's request. Use the latest Gradio API and best practices. When needed, use web search to find current best practices or verify latest Gradio features. 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. Make the app as self-contained as possible. Do NOT add the language name at the top of the code output.
|
456 |
|
457 |
+
π¨ IMPORTANT: If the user is asking to use external APIs (like OpenRouter, OpenAI API, Hugging Face Inference API, etc.), DO NOT use @spaces.GPU decorators or any ZeroGPU features. External APIs handle the model inference remotely, so GPU allocation on the Spaces instance is not needed.
|
458 |
+
|
459 |
+
π¨ CRITICAL REQUIREMENT: If the user provides ANY diffusion model code (FLUX, Stable Diffusion, etc.) that runs locally (not via API), you MUST implement ZeroGPU ahead-of-time (AoT) compilation. This is mandatory and provides 1.3x-1.8x performance improvements. Do not create basic Gradio apps without AoT optimization for diffusion models.
|
460 |
|
461 |
## ZeroGPU Integration (MANDATORY)
|
462 |
|
|
|
5243 |
except Exception:
|
5244 |
pass
|
5245 |
|
5246 |
+
# Update Gradio system prompts if needed
|
5247 |
+
if language == "gradio":
|
5248 |
+
update_gradio_system_prompts()
|
5249 |
+
|
5250 |
# Choose system prompt based on context
|
5251 |
if has_existing_content:
|
5252 |
# Use follow-up prompt for modifying existing content
|