Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import openai # or use HuggingFace's transformers or your own LLM
|
| 3 |
+
|
| 4 |
+
# Set your OpenAI API key
|
| 5 |
+
openai.api_key = st.secrets.get("OPENAI_API_KEY") # Use Hugging Face secrets
|
| 6 |
+
|
| 7 |
+
# Helper function to call LLM
|
| 8 |
+
def generate_document(prompt):
|
| 9 |
+
response = openai.ChatCompletion.create(
|
| 10 |
+
model="gpt-4", # Or gpt-3.5-turbo
|
| 11 |
+
messages=[
|
| 12 |
+
{"role": "system", "content": "You are an expert product manager and software architect."},
|
| 13 |
+
{"role": "user", "content": prompt}
|
| 14 |
+
],
|
| 15 |
+
temperature=0.7,
|
| 16 |
+
max_tokens=1500
|
| 17 |
+
)
|
| 18 |
+
return response['choices'][0]['message']['content']
|
| 19 |
+
|
| 20 |
+
# UI
|
| 21 |
+
st.title("π Product Idea to Documentation Generator")
|
| 22 |
+
st.write("Enter a product idea and get a PRD, frontend/backend architecture, and user flow.")
|
| 23 |
+
|
| 24 |
+
product_idea = st.text_area("π‘ Your Product Idea", height=200)
|
| 25 |
+
|
| 26 |
+
if st.button("Generate Documents"):
|
| 27 |
+
if not product_idea.strip():
|
| 28 |
+
st.warning("Please enter a product idea.")
|
| 29 |
+
else:
|
| 30 |
+
with st.spinner("Generating PRD..."):
|
| 31 |
+
prd = generate_document(f"Write a detailed PRD for this product idea:\n{product_idea}")
|
| 32 |
+
|
| 33 |
+
with st.spinner("Generating Frontend Architecture..."):
|
| 34 |
+
frontend = generate_document(f"Describe the frontend tech stack and architecture for this product:\n{product_idea}")
|
| 35 |
+
|
| 36 |
+
with st.spinner("Generating Backend Architecture..."):
|
| 37 |
+
backend = generate_document(f"Describe the backend system design for this product:\n{product_idea}")
|
| 38 |
+
|
| 39 |
+
with st.spinner("Generating User Flow..."):
|
| 40 |
+
user_flow = generate_document(f"Create a simple user flow description for this product:\n{product_idea}")
|
| 41 |
+
|
| 42 |
+
# Show results
|
| 43 |
+
st.subheader("π Product Requirements Document (PRD)")
|
| 44 |
+
st.markdown(prd)
|
| 45 |
+
|
| 46 |
+
st.subheader("π§± Frontend Architecture")
|
| 47 |
+
st.markdown(frontend)
|
| 48 |
+
|
| 49 |
+
st.subheader("π Backend Architecture")
|
| 50 |
+
st.markdown(backend)
|
| 51 |
+
|
| 52 |
+
st.subheader("π§ User Flow")
|
| 53 |
+
st.markdown(user_flow)
|
| 54 |
+
|
| 55 |
+
# Download options
|
| 56 |
+
all_text = f"# PRD\n\n{prd}\n\n# Frontend\n\n{frontend}\n\n# Backend\n\n{backend}\n\n# User Flow\n\n{user_flow}"
|
| 57 |
+
st.download_button("π₯ Download as .txt", all_text, file_name="product_docs.txt")
|