Spaces:
Sleeping
Sleeping
Create app.py
Browse files12345678910111213141516171819202122232425262728import gradio as grfrom transformers import AutoTokenizer, AutoModelForCausalLMimport torch
# Load Starcoder model (code generation)model_name = "bigcode/starcoder"tokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained(model_name)
def generate_html(prompt): input_text = f"Generate only HTML/CSS/JS code for this website idea:\n{prompt}" inputs = tokenizer.encode(input_text, return_tensors="pt", truncation=True, max_length=1024) outputs = model.generate(inputs, max_length=1500, temperature=0.7, do_sample=True) code = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Keep only the HTML part from the output first_html_index = code.find('<') if first_html_index != -1: return code[first_html_index:] return code
gr.Interface( fn=generate_html, inputs=gr.Textbox(lines=6, label="Describe your website idea (English or Hindi)"), outputs=gr.Code(label="Generated HTML/CSS/JS"), title="SKORD AI Website Generator", description="Get only HTML/CSS/JS code from your idea using AI. Works in English and Hindi.").launch()app.pyAdded+28