akhaliq HF Staff commited on
Commit
d4559fb
·
1 Parent(s): efbd299

update json

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -1226,6 +1226,24 @@ GRADIO_SYSTEM_PROMPT_WITH_SEARCH = ""
1226
 
1227
  # All Gradio API documentation is now dynamically loaded from https://www.gradio.app/llms.txt
1228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1229
  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. Generate complete, working code that can be run immediately. 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.
1230
 
1231
  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"""
@@ -6123,6 +6141,8 @@ Generate the exact search/replace blocks needed to make these changes."""
6123
  system_prompt = SVELTE_SYSTEM_PROMPT_WITH_SEARCH if enable_search else SVELTE_SYSTEM_PROMPT
6124
  elif language == "gradio":
6125
  system_prompt = GRADIO_SYSTEM_PROMPT_WITH_SEARCH if enable_search else GRADIO_SYSTEM_PROMPT
 
 
6126
  else:
6127
  system_prompt = GENERIC_SYSTEM_PROMPT_WITH_SEARCH.format(language=language) if enable_search else GENERIC_SYSTEM_PROMPT.format(language=language)
6128
 
@@ -8711,6 +8731,8 @@ with gr.Blocks(
8711
  return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your code using the download button above.</div>"
8712
  if language == "svelte":
8713
  return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code and deploy it to see the result.</div>"
 
 
8714
  return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML.</div>"
8715
 
8716
  # Direct preview updates from multi-file editor changes
 
1226
 
1227
  # All Gradio API documentation is now dynamically loaded from https://www.gradio.app/llms.txt
1228
 
1229
+ JSON_SYSTEM_PROMPT = """You are an expert JSON developer. Generate clean, valid JSON data based on the user's request. Follow JSON syntax rules strictly:
1230
+ - Use double quotes for strings
1231
+ - No trailing commas
1232
+ - Proper nesting and structure
1233
+ - Valid data types (string, number, boolean, null, object, array)
1234
+
1235
+ Generate ONLY the JSON data requested - no HTML, no applications, no explanations outside the JSON. The output should be pure, valid JSON that can be parsed directly."""
1236
+
1237
+ JSON_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert JSON developer. You have access to real-time web search. When needed, use web search to find the latest information or data structures for your JSON generation.
1238
+
1239
+ Generate clean, valid JSON data based on the user's request. Follow JSON syntax rules strictly:
1240
+ - Use double quotes for strings
1241
+ - No trailing commas
1242
+ - Proper nesting and structure
1243
+ - Valid data types (string, number, boolean, null, object, array)
1244
+
1245
+ Generate ONLY the JSON data requested - no HTML, no applications, no explanations outside the JSON. The output should be pure, valid JSON that can be parsed directly."""
1246
+
1247
  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. Generate complete, working code that can be run immediately. 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.
1248
 
1249
  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"""
 
6141
  system_prompt = SVELTE_SYSTEM_PROMPT_WITH_SEARCH if enable_search else SVELTE_SYSTEM_PROMPT
6142
  elif language == "gradio":
6143
  system_prompt = GRADIO_SYSTEM_PROMPT_WITH_SEARCH if enable_search else GRADIO_SYSTEM_PROMPT
6144
+ elif language == "json":
6145
+ system_prompt = JSON_SYSTEM_PROMPT_WITH_SEARCH if enable_search else JSON_SYSTEM_PROMPT
6146
  else:
6147
  system_prompt = GENERIC_SYSTEM_PROMPT_WITH_SEARCH.format(language=language) if enable_search else GENERIC_SYSTEM_PROMPT.format(language=language)
6148
 
 
8731
  return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your code using the download button above.</div>"
8732
  if language == "svelte":
8733
  return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code and deploy it to see the result.</div>"
8734
+ if language == "json":
8735
+ return "<div style='padding:1em;color:#888;text-align:center;'>JSON data generated successfully. Use the download button to save your JSON file.</div>"
8736
  return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML.</div>"
8737
 
8738
  # Direct preview updates from multi-file editor changes