Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Using a lightweight model to stay within free tier limits
|
| 5 |
+
generator = pipeline("text-generation", model="Salesforce/codegen2-1B", max_new_tokens=1024)
|
| 6 |
+
|
| 7 |
+
def generate_website_code(prompt):
|
| 8 |
+
system_prompt = (
|
| 9 |
+
f"Create a fully responsive website with HTML, CSS, and JavaScript. "
|
| 10 |
+
f"Use these requirements: {prompt}.\n\n"
|
| 11 |
+
f"Return full code with all parts embedded."
|
| 12 |
+
)
|
| 13 |
+
result = generator(system_prompt)[0]["generated_text"]
|
| 14 |
+
return result
|
| 15 |
+
|
| 16 |
+
gr.Interface(
|
| 17 |
+
fn=generate_website_code,
|
| 18 |
+
inputs=gr.Textbox(lines=5, label="Describe the website you want (theme, brand, images, colors)"),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="AI Website Generator"
|
| 21 |
+
).launch()
|