Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,13 +31,24 @@ def generate_gradio_app(image):
|
|
| 31 |
img_str = base64.b64encode(buffered.getvalue()).decode()
|
| 32 |
|
| 33 |
# Prepare the messages for the API call
|
| 34 |
-
system_message = "You are an AI assistant that can analyze wireframe images and generate Gradio code based on their content."
|
|
|
|
| 35 |
user_message = f"""
|
| 36 |
<image>
|
| 37 |
data:image/png;base64,{img_str}
|
| 38 |
</image>
|
| 39 |
|
| 40 |
-
Analyze this wireframe image and generate Python code using Gradio that
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
"""
|
| 42 |
|
| 43 |
messages = [
|
|
@@ -85,7 +96,7 @@ with gr.Blocks() as demo:
|
|
| 85 |
|
| 86 |
generate_button = gr.Button("Generate Gradio app", variant="primary")
|
| 87 |
|
| 88 |
-
code_output = gr.Code(language="python", label="Generated Gradio Code", lines=
|
| 89 |
|
| 90 |
generate_button.click(
|
| 91 |
fn=generate_gradio_app,
|
|
|
|
| 31 |
img_str = base64.b64encode(buffered.getvalue()).decode()
|
| 32 |
|
| 33 |
# Prepare the messages for the API call
|
| 34 |
+
system_message = """You are an AI assistant that can analyze wireframe images and generate detailed Gradio code based on their content. Your task is to provide a complete, runnable Gradio application that recreates the UI elements seen in the wireframe."""
|
| 35 |
+
|
| 36 |
user_message = f"""
|
| 37 |
<image>
|
| 38 |
data:image/png;base64,{img_str}
|
| 39 |
</image>
|
| 40 |
|
| 41 |
+
Analyze this wireframe image and generate a complete Python code using Gradio that recreates all the main elements seen in the image. Follow these guidelines:
|
| 42 |
+
1. Use appropriate Gradio components that best represent each UI element in the wireframe.
|
| 43 |
+
2. Include all necessary imports at the beginning of the code.
|
| 44 |
+
3. Implement placeholder functions for any interactive elements (buttons, inputs, etc.).
|
| 45 |
+
4. Use gr.Blocks() to create a layout that matches the wireframe as closely as possible.
|
| 46 |
+
5. Add appropriate labels and descriptions for all components.
|
| 47 |
+
6. Include the gr.Blocks().launch() call at the end of the code.
|
| 48 |
+
7. Provide a complete, runnable Gradio application that can be executed as-is.
|
| 49 |
+
8. Add comments explaining the purpose of each major section or component.
|
| 50 |
+
|
| 51 |
+
Please generate the entire code, including all necessary parts to make it a fully functional Gradio application.
|
| 52 |
"""
|
| 53 |
|
| 54 |
messages = [
|
|
|
|
| 96 |
|
| 97 |
generate_button = gr.Button("Generate Gradio app", variant="primary")
|
| 98 |
|
| 99 |
+
code_output = gr.Code(language="python", label="Generated Gradio Code", lines=30)
|
| 100 |
|
| 101 |
generate_button.click(
|
| 102 |
fn=generate_gradio_app,
|