Delete app.py
Browse files
app.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import requests
|
| 3 |
-
import os
|
| 4 |
-
import streamlit as st
|
| 5 |
-
st.title("β
App Loaded Successfully!")
|
| 6 |
-
# Set page
|
| 7 |
-
st.set_page_config(page_title="Product Comparison LLM", layout="wide")
|
| 8 |
-
st.title("π§ Competitive Product Analyser")
|
| 9 |
-
|
| 10 |
-
# Hugging Face API setup
|
| 11 |
-
API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-large"
|
| 12 |
-
HF_TOKEN = os.getenv("HF_TOKEN") # <-- Secure way if you set secret key
|
| 13 |
-
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
| 14 |
-
|
| 15 |
-
# Text input boxes
|
| 16 |
-
product1 = st.text_area("π¦ Product/Service 1", height=200)
|
| 17 |
-
product2 = st.text_area("π¦ Product/Service 2", height=200)
|
| 18 |
-
|
| 19 |
-
# Button
|
| 20 |
-
if st.button("π Analyze"):
|
| 21 |
-
with st.spinner("Contacting model..."):
|
| 22 |
-
prompt = f"""
|
| 23 |
-
Compare the following two products or services:
|
| 24 |
-
|
| 25 |
-
Product/Service 1:
|
| 26 |
-
{product1}
|
| 27 |
-
|
| 28 |
-
Product/Service 2:
|
| 29 |
-
{product2}
|
| 30 |
-
|
| 31 |
-
Your task:
|
| 32 |
-
- Provide a detailed feature-by-feature comparison.
|
| 33 |
-
- Perform a SWOT analysis (Strengths, Weaknesses, Opportunities, Threats) for each.
|
| 34 |
-
- Highlight key differentiators and insights in a business-focused summary.
|
| 35 |
-
- Use markdown formatting for readability.
|
| 36 |
-
"""
|
| 37 |
-
response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
| 38 |
-
|
| 39 |
-
st.subheader("π‘ API Response Debug")
|
| 40 |
-
st.write("Status Code:", response.status_code)
|
| 41 |
-
st.write("Raw:", response.text)
|
| 42 |
-
|
| 43 |
-
try:
|
| 44 |
-
result = response.json()
|
| 45 |
-
output = result[0]["generated_text"] if isinstance(result, list) else str(result)
|
| 46 |
-
st.markdown("### π Result:")
|
| 47 |
-
st.markdown(output)
|
| 48 |
-
except Exception as e:
|
| 49 |
-
st.error(f"β Failed to parse response: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|