devXpert commited on
Commit
421a1ef
·
verified ·
1 Parent(s): 3d26e30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -1,11 +1,33 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- generator = pipeline("text2text-generation", model="google/flan-t5-small")
 
5
 
 
6
  def generate_website_code(prompt):
7
- full_prompt = f"Create a stylish animated HTML, CSS, and JS website using this prompt: {prompt}"
8
- result = generator(full_prompt, max_new_tokens=1024)[0]["generated_text"]
9
- return result
10
 
11
- gr.Interface(fn=generate_website_code, inputs="text", outputs="text", title="Website Generator").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # Load code generation model (switch to GPU if possible in settings)
5
+ generator = pipeline("text-generation", model="deepseek-ai/deepseek-coder-6.7b-instruct")
6
 
7
+ # Function to generate website code from user prompt
8
  def generate_website_code(prompt):
9
+ full_prompt = f"""You are a senior web developer. Based on the following instructions, generate a full HTML5 website including CSS and JavaScript inside <style> and <script> tags.
 
 
10
 
11
+ Instructions:
12
+ {prompt}
13
+
14
+ Return only the complete code inside <html>...</html> tags, ready to save as an .html file.
15
+ """
16
+ output = generator(full_prompt, max_new_tokens=2048, temperature=0.7)[0]["generated_text"]
17
+
18
+ # Extract only the part starting with <html> to avoid model's intro text
19
+ html_start = output.find("<html")
20
+ if html_start != -1:
21
+ return output[html_start:]
22
+ return output
23
+
24
+ # Gradio UI
25
+ iface = gr.Interface(
26
+ fn=generate_website_code,
27
+ inputs=gr.Textbox(lines=8, label="Describe your website (Prompt)"),
28
+ outputs=gr.Code(label="Generated HTML Website Code"),
29
+ title="AI Website Generator",
30
+ description="Enter a prompt describing your website. Example: 'Create a modern cafe website using beige and brown colors. The brand is BrewNest. Include food items, transitions, and animations.'",
31
+ )
32
+
33
+ iface.launch()