File size: 2,321 Bytes
e5788d1 2ce9f0d e5788d1 e53ba29 05760ad e5788d1 c8bc4dd 230c7c9 1c8fd1c 230c7c9 1c8fd1c c8bc4dd 1c8fd1c c8bc4dd 1c8fd1c c8bc4dd e5788d1 8c93ede 2ce9f0d 8c93ede 1c8fd1c e5788d1 c8bc4dd 5290447 a7f3c27 c8bc4dd a7f3c27 05760ad a7f3c27 8c93ede 2ce9f0d dc254e4 2ce9f0d dc254e4 2ce9f0d dc254e4 c8bc4dd 230c7c9 8c93ede | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | import streamlit as st
from langchain_community.llms import HuggingFaceHub
import os
from fpdf import FPDF
from io import BytesIO
import textwrap
import re
# Page setup + dark theme
st.set_page_config(page_title="Pro Competitive Analysis", layout="centered")
st.markdown("""
<style>
body {
background-color: #111 !important;
color: #e0e0e0;
font-family: 'Segoe UI', sans-serif;
}
h1, h2, h3 {
color: #ffffff;
}
textarea, input, button, .stTextInput>div>div>input {
background-color: #1c1c1c !important;
color: #f1f1f1 !important;
border: 1px solid #444 !important;
}
button:hover {
background-color: #444 !important;
}
.stDownloadButton>button {
background-color: #222 !important;
color: white;
}
.stDownloadButton>button:hover {
background-color: #444 !important;
}
</style>
""", unsafe_allow_html=True)
# Header
st.title("💼 Competitive Analysis Pro")
st.markdown("Get an expert-level markdown analysis between two products or services, including SWOT, features, and recommendations.")
# Set Hugging Face token
os.environ["HUGGINGFACEHUB_API_TOKEN"] = st.secrets["HF_TOKEN"]
# Load Zephyr LLM (Free model)
llm = HuggingFaceHub(
repo_id="HuggingFaceH4/zephyr-7b-alpha",
model_kwargs={"temperature": 0.7, "max_new_tokens": 1024}
)
# Inputs
product1 = st.text_area("🧩 Product/Service 1", height=200, placeholder="e.g., iPhone 13")
product2 = st.text_area("🧩 Product/Service 2", height=200, placeholder="e.g., iPhone 14")
# Compare
if st.button("🔍 Run Competitive Analysis", use_container_width=True):
if not product1 or not product2:
st.warning("Please enter both product descriptions.")
else:
with st.spinner("🧠 Generating insights with Zephyr..."):
prompt = f"""
Compare the following two products or services:
Product 1:
{product1}
Product 2:
{product2}
Return a professional analysis in markdown format that includes:
- Feature-by-feature comparison
- SWOT analysis for each product
- Business use cases and recommendations
- Key differentiators and which product suits which audience
Do NOT include or mention these instructions.
Only return the clean markdown report.
"""
result = llm(prompt)
# Display output
st.markdown("### 📊 Expert Comparison")
st.markdown(result) |