Spaces:
Runtime error
Runtime error
Update app.py
Browse files1 unmodified line2345678910111213141510 unmodified lines262728293031323334353637381 unmodified linefrom transformers import pipeline# Модель для генерации кода (лёгкая, шустрая)generator = pipeline("text-generation", model="microsoft/CodeT5-small", max_new_tokens=600, temperature=0.3)def generate_html(prompt):full_prompt = f"Generate full HTML code for: {prompt}. Include <!DOCTYPE html>, <html>, <head> with <style> and <script>, <body>. Make it responsive, beautiful, modern with CSS animations. Pure code only, no explanations."result = generator(full_prompt, max_new_tokens=800)[0]['generated_text']# Очистка кодаcode = result.replace(full_prompt, '').strip()if not code.startswith('<!DOCTYPE'):code = f"""<!DOCTYPE html><html lang="ru">10 unmodified linesreturn codewith gr.Blocks(title="My AI HTML Gen") as demo:gr.Markdown("# 🎨 Мой AI Генератор HTML (Бесплатно!)")prompt = gr.Textbox(label="Промпт", placeholder="Создай красивую кнопку с анимацией", lines=2)btn = gr.Button("Генерировать! 🚀")output = gr.Code(label="Готовый HTML", language="html", lines=20, show_copy_button=True)gr.Examples(examples=[["landing page с hero"], ["кнопка с hover"], ["форма логина"], ["карточка товара"]], inputs=prompt)btn.click(generate_html, prompt, output)demo.launch()1 unmodified line2345678910111213141510 unmodified lines262728293031323334351 unmodified linefrom transformers import pipeline# Модель для генерации кода (лёгкая, шустрая)generator = pipeline("text2text-generation", model="microsoft/CodeT5-small")def generate_html(prompt):full_prompt = f"Generate full HTML code for: {prompt}. Include <!DOCTYPE html>, <html>, <head> with <style> and <script>, <body>. Make it responsive, beautiful, modern with CSS animations. Pure code only, no explanations."result = generator(full_prompt, max_length=800, num_return_sequences=1, temperature=0.3)# Очистка кодаcode = result[0]['generated_text'].strip()if not code.startswith('<!DOCTYPE'):code = f"""<!DOCTYPE html><html lang="ru">10 unmodified linesreturn codewith gr.Blocks(title="My AI HTML Gen") as demo:gr.Markdown("# 🎨 Твой AI HTML Генератор (Тест)")prompt = gr.Textbox(label="Промпт", placeholder="Landing page", lines=2)btn = gr.Button("Генерировать! 🚀")output = gr.Code(label="HTML", language="html", lines=15, show_copy_button=True)btn.click(generate_html, prompt, output)demo.launch()
app.py+6-9