akhaliq HF Staff commited on
Commit
722a65e
·
1 Parent(s): e8d64af
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -58,7 +58,7 @@ Always respond with code that can be executed or rendered directly.
58
 
59
  Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text."""
60
 
61
- 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 ```{language} ... ``` 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."""
62
 
63
  # System prompt with search capability
64
  HTML_SYSTEM_PROMPT_WITH_SEARCH = """ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. MAKE IT RESPONSIVE USING MODERN CSS. Use as much as you can modern CSS for the styling, if you can't do something with modern CSS, then use custom CSS. Also, try to elaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE
@@ -85,7 +85,7 @@ Always output only the HTML code inside a ```html ... ``` code block, and do not
85
 
86
  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}.
87
 
88
- 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 ```{language} ... ``` 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."""
89
 
90
  # Follow-up system prompt for modifying existing HTML files
91
  FollowUpSystemPrompt = f"""You are an expert web developer modifying an existing HTML file.
@@ -316,6 +316,9 @@ def remove_code_block(text):
316
  # If no code block is found, check if the entire text is HTML
317
  if text.strip().startswith('<!DOCTYPE html>') or text.strip().startswith('<html') or text.strip().startswith('<'):
318
  return text.strip()
 
 
 
319
  return text.strip()
320
 
321
  def history_render(history: History):
@@ -1174,7 +1177,7 @@ with gr.Blocks(
1174
  ]
1175
  sdk_dropdown = gr.Dropdown(
1176
  choices=[x[0] for x in sdk_choices],
1177
- value="Gradio (Python)",
1178
  label="App SDK",
1179
  visible=True
1180
  )
 
58
 
59
  Always output only the HTML code inside a ```html ... ``` code block, and do not include any explanations or extra text."""
60
 
61
+ 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."""
62
 
63
  # System prompt with search capability
64
  HTML_SYSTEM_PROMPT_WITH_SEARCH = """ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. MAKE IT RESPONSIVE USING MODERN CSS. Use as much as you can modern CSS for the styling, if you can't do something with modern CSS, then use custom CSS. Also, try to elaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE
 
85
 
86
  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}.
87
 
88
+ 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."""
89
 
90
  # Follow-up system prompt for modifying existing HTML files
91
  FollowUpSystemPrompt = f"""You are an expert web developer modifying an existing HTML file.
 
316
  # If no code block is found, check if the entire text is HTML
317
  if text.strip().startswith('<!DOCTYPE html>') or text.strip().startswith('<html') or text.strip().startswith('<'):
318
  return text.strip()
319
+ # Special handling for python: remove python marker
320
+ if text.strip().startswith('```python'):
321
+ return text.strip()[9:-3].strip()
322
  return text.strip()
323
 
324
  def history_render(history: History):
 
1177
  ]
1178
  sdk_dropdown = gr.Dropdown(
1179
  choices=[x[0] for x in sdk_choices],
1180
+ value="Static (HTML)",
1181
  label="App SDK",
1182
  visible=True
1183
  )