Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
# Connect to your Hugging Face LLM
|
| 5 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 6 |
+
|
| 7 |
+
# Vibe Coding Tools suggestions
|
| 8 |
+
VIBE_TOOLS = [
|
| 9 |
+
("Lovable", "https://lovable.so", "Browser-based AI + no-code prototyping for apps"),
|
| 10 |
+
("Rocket.new", "https://www.rocket.new/", "Quick web app MVP generator"),
|
| 11 |
+
("Bolt", "https://bolt.com", "Rapid prototyping + automation, great for MVPs"),
|
| 12 |
+
("V0", "https://v0.dev", "Serverless backend + front-end scaffolding"),
|
| 13 |
+
("Replit", "https://replit.com", "Full online dev environment, collaborative coding"),
|
| 14 |
+
("Glide", "https://www.glideapps.com", "AI + no-code, spreadsheet-based apps"),
|
| 15 |
+
("Softr", "https://www.softr.io", "Web apps on Airtable/Google Sheets"),
|
| 16 |
+
("Builder.io", "https://www.builder.io", "Figma-to-code web apps"),
|
| 17 |
+
("TeleportHQ", "https://teleporthq.io", "AI-assisted web front-end builder"),
|
| 18 |
+
("Plasmic", "https://www.plasmic.app", "Frontend builder for marketing + product hybrid"),
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
# Core function to generate rich prompt
|
| 22 |
+
def generate_rich_prompt(app_name, description, personas, features, tone="professional"):
|
| 23 |
+
system_message = "You are an expert hackathon product designer and AI prompt engineer."
|
| 24 |
+
user_message = f"""
|
| 25 |
+
Generate a rich hackathon-ready prompt for Vibe Coding Tools (Lovable, Rocket.new, Bolt, etc.)
|
| 26 |
+
Include everything needed to deliver a polished MVP & PoC.
|
| 27 |
+
|
| 28 |
+
Use the following info to create a full prompt (like the X-EdTech example):
|
| 29 |
+
|
| 30 |
+
Project name: {app_name}
|
| 31 |
+
Summary: {description}
|
| 32 |
+
Personas / Roles: {personas}
|
| 33 |
+
Features: {features}
|
| 34 |
+
Tone: {tone}
|
| 35 |
+
|
| 36 |
+
Output structure:
|
| 37 |
+
|
| 38 |
+
1. Project summary (short)
|
| 39 |
+
2. Priority outcome for hackathon (clickable prototype + MVP)
|
| 40 |
+
3. Opinion on tech stack & approach
|
| 41 |
+
4. Deliverables expected
|
| 42 |
+
5. Core modules & features with [MVP]/[PoC] markings
|
| 43 |
+
6. Demo accounts with role-specific landing cards
|
| 44 |
+
7. Sample data model & seed dataset
|
| 45 |
+
8. Charts & dashboard details
|
| 46 |
+
9. Design system & Liquid Glassmorphism rules
|
| 47 |
+
10. Dark / Light toggle specifics
|
| 48 |
+
11. Prototype screens to produce (minimum)
|
| 49 |
+
12. AI features to simulate
|
| 50 |
+
13. APIs & mock endpoints
|
| 51 |
+
14. Acceptance criteria
|
| 52 |
+
15. Polish / wow factors
|
| 53 |
+
16. Acceptance copy / microcopy examples
|
| 54 |
+
17. Constraints / nonfunctional
|
| 55 |
+
18. Hackathon priorities
|
| 56 |
+
19. One-slide pitch summary
|
| 57 |
+
|
| 58 |
+
List 10 Vibe Coding Tools, link, purpose, and recommended techniques. Ensure the output is clear, structured, and ready-to-use by a developer or designer in a hackathon.
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
messages = [
|
| 62 |
+
{"role": "system", "content": system_message},
|
| 63 |
+
{"role": "user", "content": user_message}
|
| 64 |
+
]
|
| 65 |
+
|
| 66 |
+
response = ""
|
| 67 |
+
for message in client.chat_completion(messages, max_tokens=2048, stream=True, temperature=0.7):
|
| 68 |
+
token = message.choices[0].delta.content
|
| 69 |
+
response += token
|
| 70 |
+
yield response
|
| 71 |
+
|
| 72 |
+
# Build Gradio interface
|
| 73 |
+
with gr.Blocks(title="X-Build: Rich Hackathon Prompt Generator") as demo:
|
| 74 |
+
|
| 75 |
+
gr.Markdown("<h2 style='text-align:center'>X-Build: Hackathon-Ready Prompt Generator</h2>")
|
| 76 |
+
|
| 77 |
+
with gr.Row():
|
| 78 |
+
with gr.Column(scale=1):
|
| 79 |
+
app_name = gr.Textbox(label="App Name", placeholder="Enter your app name")
|
| 80 |
+
description = gr.Textbox(label="App Description", placeholder="Describe your app")
|
| 81 |
+
personas = gr.Textbox(label="Personas / Roles", placeholder="Teacher, Student, Admin...")
|
| 82 |
+
features = gr.Textbox(label="Features", placeholder="Forms, Quizzes, Analytics...")
|
| 83 |
+
tone = gr.Dropdown(label="Prompt Tone", choices=["professional", "casual", "friendly"], value="professional")
|
| 84 |
+
generate_btn = gr.Button("Generate Rich Prompt")
|
| 85 |
+
|
| 86 |
+
with gr.Column(scale=1):
|
| 87 |
+
output = gr.Textbox(label="Generated Rich Prompt", lines=30, interactive=False)
|
| 88 |
+
|
| 89 |
+
generate_btn.click(
|
| 90 |
+
fn=generate_rich_prompt,
|
| 91 |
+
inputs=[app_name, description, personas, features, tone],
|
| 92 |
+
outputs=output
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
# Basic Dark/Light toggle
|
| 96 |
+
theme_toggle = gr.Checkbox(label="Dark Mode", info="Toggle dark/light theme")
|
| 97 |
+
|
| 98 |
+
def toggle_theme(dark_mode):
|
| 99 |
+
if dark_mode:
|
| 100 |
+
return gr.update(elem_classes="dark-theme")
|
| 101 |
+
else:
|
| 102 |
+
return gr.update(elem_classes="")
|
| 103 |
+
theme_toggle.change(fn=toggle_theme, inputs=theme_toggle, outputs=[])
|
| 104 |
+
|
| 105 |
+
# Launch
|
| 106 |
+
if __name__ == "__main__":
|
| 107 |
+
demo.launch()
|