Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
generator = pipeline("text-generation", model="your-selected-llm")
|
| 5 |
+
|
| 6 |
+
def generate_ui(platform, framework, prompt):
|
| 7 |
+
instruction = f"Generate {framework} UI code for {platform}. Layout: {prompt}"
|
| 8 |
+
code = generator(instruction, max_length=512)[0]["generated_text"]
|
| 9 |
+
return code
|
| 10 |
+
|
| 11 |
+
interface = gr.Interface(
|
| 12 |
+
fn=generate_ui,
|
| 13 |
+
inputs=[
|
| 14 |
+
gr.Dropdown(["Android","iOS"], label="Platform"),
|
| 15 |
+
gr.Dropdown(["Flutter","Kotlin XML","SwiftUI","ReactNative"], label="Framework"),
|
| 16 |
+
gr.Textbox(lines=4, placeholder="Describe the UI you want…")
|
| 17 |
+
],
|
| 18 |
+
outputs=gr.Code(label="Generated UI Code")
|
| 19 |
+
)
|
| 20 |
+
interface.launch()
|