akhaliq HF Staff commited on
Commit
92ee151
Β·
1 Parent(s): 30c30cb
Files changed (2) hide show
  1. backend_docs_manager.py +81 -13
  2. backend_parsers.py +1 -1
backend_docs_manager.py CHANGED
@@ -252,7 +252,10 @@ def build_gradio_system_prompt() -> str:
252
  base_prompt = """🚨 CRITICAL: You are an expert Gradio 6 developer. You MUST use Gradio 6 syntax and API.
253
 
254
  ## Key Gradio 6 Changes (MUST FOLLOW):
255
- - Use `footer_links` parameter instead of removed `show_api` in gr.Blocks()
 
 
 
256
  - Use `api_visibility` instead of `api_name` in event listeners
257
  - Use modern Gradio 6 component syntax (check documentation below)
258
  - Gradio 6 has updated component APIs - always refer to the documentation below
@@ -260,6 +263,58 @@ def build_gradio_system_prompt() -> str:
260
 
261
  Create a complete, working Gradio 6 application based on the user's request. Generate all necessary code to make the application functional and runnable.
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  ## Gradio 6 Example (Your Code Should Follow This Pattern):
264
 
265
  ```python
@@ -268,11 +323,9 @@ import gradio as gr
268
  def process(text):
269
  return f"Processed: {text}"
270
 
271
- # Gradio 6 Blocks with footer_links (NOT show_api)
272
- with gr.Blocks(
273
- title="My App",
274
- footer_links=[{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}]
275
- ) as demo:
276
  with gr.Row():
277
  input_text = gr.Textbox(label="Input")
278
  output_text = gr.Textbox(label="Output")
@@ -287,7 +340,11 @@ with gr.Blocks(
287
  api_visibility="public" # Gradio 6 syntax
288
  )
289
 
290
- demo.launch()
 
 
 
 
291
  ```
292
 
293
  ## Multi-File Application Structure
@@ -350,14 +407,25 @@ YOU MUST USE GRADIO 6 SYNTAX. This is MANDATORY:
350
  1. **ONLY use Gradio 6 API** - Do NOT use Gradio 5 or older syntax
351
  2. **Reference the documentation above** - All function signatures and patterns are from Gradio 6
352
  3. **Use modern Gradio 6 patterns:**
353
- - Use `footer_links` parameter in gr.Blocks() (NOT show_api)
 
354
  - Use `api_visibility` in event listeners (NOT api_name alone)
355
  - Use updated component syntax from Gradio 6 documentation
356
- 4. **Follow Gradio 6 migration guide** if you see any deprecated patterns
357
- 5. **Generate production-ready Gradio 6 code** that follows all best practices
358
- 6. **Always include "Built with anycoder"** as clickable text in the header linking to https://huggingface.co/spaces/akhaliq/anycoder
359
-
360
- REMINDER: You are writing Gradio 6 code. Double-check all syntax against the Gradio 6 documentation provided above.
 
 
 
 
 
 
 
 
 
 
361
 
362
  """
363
 
 
252
  base_prompt = """🚨 CRITICAL: You are an expert Gradio 6 developer. You MUST use Gradio 6 syntax and API.
253
 
254
  ## Key Gradio 6 Changes (MUST FOLLOW):
255
+ - 🚨 **BREAKING CHANGE**: `theme`, `css`, `js`, `head` parameters moved from `gr.Blocks()` to `demo.launch()`
256
+ - 🚨 **gr.Blocks() has NO parameters** - use `with gr.Blocks() as demo:` (no args!)
257
+ - 🚨 **ALL app-level params go in demo.launch()**: `theme=`, `css=`, `footer_links=`, etc.
258
+ - Use `footer_links` parameter in `demo.launch()` (NOT show_api)
259
  - Use `api_visibility` instead of `api_name` in event listeners
260
  - Use modern Gradio 6 component syntax (check documentation below)
261
  - Gradio 6 has updated component APIs - always refer to the documentation below
 
263
 
264
  Create a complete, working Gradio 6 application based on the user's request. Generate all necessary code to make the application functional and runnable.
265
 
266
+ ## Gradio 6 Themes (Modern UI Design):
267
+
268
+ Gradio 6 provides powerful theming capabilities. Use themes to create beautiful, professional interfaces:
269
+
270
+ **Built-in Themes:**
271
+ ```python
272
+ import gradio as gr
273
+
274
+ # Use predefined themes in launch() - Gradio 6 syntax
275
+ with gr.Blocks() as demo:
276
+ gr.Textbox(label="Input")
277
+
278
+ demo.launch(theme=gr.themes.Soft()) # Soft, rounded design
279
+ # demo.launch(theme=gr.themes.Glass()) # Modern glass morphism
280
+ # demo.launch(theme=gr.themes.Monochrome()) # Clean monochrome
281
+ # demo.launch(theme=gr.themes.Base()) # Default base theme
282
+ ```
283
+
284
+ **Custom Themes:**
285
+ ```python
286
+ import gradio as gr
287
+
288
+ # Create custom theme
289
+ custom_theme = gr.themes.Soft(
290
+ primary_hue="blue",
291
+ secondary_hue="indigo",
292
+ neutral_hue="slate",
293
+ font=gr.themes.GoogleFont("Inter"),
294
+ text_size="lg",
295
+ spacing_size="lg",
296
+ radius_size="md"
297
+ ).set(
298
+ button_primary_background_fill="*primary_600",
299
+ button_primary_background_fill_hover="*primary_700",
300
+ block_title_text_weight="600",
301
+ )
302
+
303
+ with gr.Blocks() as demo:
304
+ gr.Textbox(label="Input")
305
+
306
+ demo.launch(theme=custom_theme) # Apply theme in launch() - Gradio 6!
307
+ ```
308
+
309
+ **Best Practices:**
310
+ - 🚨 **CRITICAL**: In Gradio 6, `theme` goes in `demo.launch()`, NOT in `gr.Blocks()`
311
+ - Use `gr.themes.Soft()` for modern, friendly apps
312
+ - Use `gr.themes.Glass()` for sleek, contemporary designs
313
+ - Customize colors with `primary_hue`, `secondary_hue`, `neutral_hue`
314
+ - Use Google Fonts: `font=gr.themes.GoogleFont("Roboto")`
315
+ - Adjust sizing: `text_size`, `spacing_size`, `radius_size` (sm/md/lg)
316
+ - Fine-tune with `.set()` for specific CSS variables
317
+
318
  ## Gradio 6 Example (Your Code Should Follow This Pattern):
319
 
320
  ```python
 
323
  def process(text):
324
  return f"Processed: {text}"
325
 
326
+ # Gradio 6 - NO parameters in gr.Blocks() constructor!
327
+ with gr.Blocks() as demo:
328
+ gr.Markdown("# My App")
 
 
329
  with gr.Row():
330
  input_text = gr.Textbox(label="Input")
331
  output_text = gr.Textbox(label="Output")
 
340
  api_visibility="public" # Gradio 6 syntax
341
  )
342
 
343
+ # Gradio 6 - ALL app parameters go in launch()!
344
+ demo.launch(
345
+ theme=gr.themes.Soft(primary_hue="blue"),
346
+ footer_links=[{"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}]
347
+ )
348
  ```
349
 
350
  ## Multi-File Application Structure
 
407
  1. **ONLY use Gradio 6 API** - Do NOT use Gradio 5 or older syntax
408
  2. **Reference the documentation above** - All function signatures and patterns are from Gradio 6
409
  3. **Use modern Gradio 6 patterns:**
410
+ - 🚨 **CRITICAL**: `theme`, `css`, `js`, `head` go in `demo.launch()`, NOT in `gr.Blocks()`
411
+ - Use `footer_links` parameter in `demo.launch()` (NOT show_api in Blocks)
412
  - Use `api_visibility` in event listeners (NOT api_name alone)
413
  - Use updated component syntax from Gradio 6 documentation
414
+ - **Use themes for professional UI design** (gr.themes.Soft(), gr.themes.Glass(), etc.)
415
+ 4. **Always use themes** - Modern Gradio 6 apps should use `theme=gr.themes.Soft()` in `demo.launch()`
416
+ 5. **Follow Gradio 6 migration guide** if you see any deprecated patterns
417
+ 6. **Generate production-ready Gradio 6 code** that follows all best practices
418
+ 7. **Always include "Built with anycoder"** as clickable text in the header linking to https://huggingface.co/spaces/akhaliq/anycoder
419
+
420
+ **Gradio 6 Structure Checklist:**
421
+ βœ… `with gr.Blocks() as demo:` - NO parameters here!
422
+ βœ… `demo.launch(theme=..., css=..., footer_links=...)` - ALL app parameters here!
423
+ βœ… Use `theme=` parameter in `demo.launch()` (NOT in gr.Blocks())
424
+ βœ… Choose appropriate theme: Soft (friendly), Glass (modern), Monochrome (minimal)
425
+ βœ… Customize with primary_hue, font, text_size, spacing_size
426
+ βœ… Use `.set()` for advanced customization
427
+
428
+ REMINDER: You are writing Gradio 6 code with modern themes. In Gradio 6, `gr.Blocks()` has NO parameters - everything goes in `demo.launch()`. Double-check all syntax against the Gradio 6 documentation provided above.
429
 
430
  """
431
 
backend_parsers.py CHANGED
@@ -328,7 +328,7 @@ Instructions:
328
  - Examples of comprehensive dependencies:
329
  * diffusers often needs: git+https://github.com/huggingface/transformers, sentencepiece, accelerate, torch, tokenizers
330
  * transformers often needs: accelerate, torch, tokenizers, datasets
331
- * gradio often needs: requests, Pillow for image handling
332
  * pandas often needs: numpy, openpyxl for Excel files
333
  * matplotlib often needs: numpy, pillow for image saving
334
  * sklearn often needs: numpy, scipy, joblib
 
328
  - Examples of comprehensive dependencies:
329
  * diffusers often needs: git+https://github.com/huggingface/transformers, sentencepiece, accelerate, torch, tokenizers
330
  * transformers often needs: accelerate, torch, tokenizers, datasets
331
+ * gradio often needs: gradio>=6.0, requests, Pillow for image handling (ALWAYS use gradio>=6.0)
332
  * pandas often needs: numpy, openpyxl for Excel files
333
  * matplotlib often needs: numpy, pillow for image saving
334
  * sklearn often needs: numpy, scipy, joblib