Spaces:
Runtime error
Runtime error
Upload app_workspace_production_ready.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
import streamlit as st
from utils import generate_rtm, generate_prospecting_message, sanitize_linkedin_url, log_event
from prospect_memory import get_prospect_memory, save_prospect_message, remove_prospect_message
import os
import json
from rtm_memory import get_rtm_memory, save_rtm, remove_rtm
st.set_page_config(page_title="Reason to Meet", layout="wide")
st.markdown("# π Reason to Meet")
st.info("**What is this app?**\n\nReason to Meet helps Enterprise Account Executives create strategic insights and outreach messaging.")
# Attempt to restore workspace from cookie
if "workspace" not in st.session_state: pass
# Try loading from localStorage (browser memory) for soft workspace recall
from streamlit_javascript import st_javascript
workspace_default = st_javascript("window.localStorage.getItem('workspaceName') || ''") or ""st.markdown("### Step 1: Enter Your Workspace Name")workspace = st.text_input("Workspace", value=workspace_default)st.session_state["workspace"] = workspace
if workspace: st_javascript(f"window.localStorage.setItem('workspaceName', '{workspace}')")else: st.stop()from streamlit_javascript import st_javascript
st.markdown("### Step 1: Enter Your Workspace Name")workspace = st.text_input("Workspace", value=workspace_default)st.session_state["workspace"] = workspace
st.session_state["workspace"] = workspace
st.session_state["workspace"] = workspace
# Save back to browser memory for next time
if not workspace:
rtm_store = get_rtm_memory(workspace)
st.markdown("### Step 2: Generate Reason to Meet Report")
with st.form("rtm_form"):
submitted = st.form_submit_button("π Generate Reason to Meet")
if submitted and company and website:
with st.spinner("Generating RTM report..."):
rtm_text = generate_rtm(company, website, workspace=workspace)
st.session_state["rtm_text"] = rtm_text
save_rtm(workspace, company, rtm_text)
log_event(workspace, "generate_rtm")
if rtm_store:
st.markdown("#### π Saved Reason to Meet Reports")
selected_account = st.selectbox("Choose an account", list(rtm_store.keys()), key="account_selector")
col1, col2, col3 = st.columns(3)
with col1:
st.download_button("β¬οΈ Download RTM", rtm_store[selected_account], file_name=f"{selected_account}_rtm.txt")
with col2:
if st.button("π Refresh RTM"):
with st.spinner("Refreshing..."):
refreshed = generate_rtm(selected_account, website="", workspace=workspace)
rtm_store[selected_account] = refreshed
st.session_state["rtm_text"] = refreshed
with open(rtm_memory_file, "w") as f:
json.dump(rtm_store, f)
log_event(workspace, "refresh_rtm")
with col3:
if st.button("ποΈ Remove RTM"):
remove_rtm(workspace, selected_account)
st.experimental_rerun()
st.text_area("Generated Reason to Meet", rtm_store.get(selected_account, ""), height=600)
# Step 3: Generate prospecting message
st.markdown("### Step 3: Generate Prospecting Message")
prospects = get_prospect_memory(workspace)
selected_prospect = st.selectbox("Saved Prospects", list(prospects.keys()) or ["None"])
if selected_prospect != "None" and selected_prospect in prospects:
st.markdown("#### π© Previously Generated Message")
st.text_area("Message", prospects[selected_prospect]["message"], height=300)
colp1, colp2 = st.columns(2)
with colp1:
if st.button("π Regenerate Message"):
prospect_data = prospects[selected_prospect]
enriched = f"{prospect_data['context']}\n\nPersona: {prospect_data['persona']}"
output = generate_prospecting_message(
prospect_data["context"],
prospect_data["persona"],
sanitize_linkedin_url(selected_prospect),
enriched,
st.session_state.get("rtm_text", ""),
workspace=workspace
)
save_prospect_message(workspace, selected_prospect, {
"company": prospect_data["company"],
"persona": prospect_data["persona"],
"context": prospect_data["context"],
"message": output
})
st.experimental_rerun()
with colp2:
if st.button("ποΈ Remove Prospect"):
remove_prospect_message(workspace, selected_prospect)
st.experimental_rerun()
st.divider()
st.markdown("#### π New Prospect Outreach")
persona = st.selectbox("Prospect Persona (optional)", ["", "CTO", "CIO", "VP Engineering", "VP Infrastructure", "SRE Leader", "Platform Lead", "Digital Operations"])
prospect_context = st.text_area("Relevant Info (optional)")
col4, col5 = st.columns(2)
with col4:
if st.button("βοΈ Generate Prospecting Message"):
enriched_context = f"{prospect_context}\n\nPersona: {custom_persona or persona}\n\nContext: This is a first message."
rtm_context = st.session_state.get("rtm_text", "")
output = generate_prospecting_message(
prospect_context,
custom_persona or persona,
sanitize_linkedin_url(linkedin_url),
enriched_context,
rtm_context,
workspace=workspace,
is_followup=False
)
st.session_state["prospect_message"] = output
save_prospect_message(workspace, linkedin_url, {
"company": selected_account,
"persona": custom_persona or persona,
"context": prospect_context,
"message": output
})
log_event(workspace, "generate_prospect")
with col5:
if st.button("π¨ Generate Follow-Up Message"):
enriched_context = f"{prospect_context}\n\nPersona: {custom_persona or persona}\n\nContext: This is a follow-up message."
rtm_context = st.session_state.get("rtm_text", "")
output = generate_prospecting_message(
prospect_context,
custom_persona or persona,
sanitize_linkedin_url(linkedin_url),
enriched_context,
rtm_context,
workspace=workspace,
is_followup=True
)
st.session_state["prospect_message"] = output
save_prospect_message(workspace, linkedin_url, {
"company": selected_account,
"persona": custom_persona or persona,
"context": prospect_context,
"message": output
})
log_event(workspace, "generate_followup")
if "prospect_message" in st.session_state:
st.markdown("### π¨ Prospecting Message Output")
st.text_area("Generated Prospecting Message", st.session_state["prospect_message"], height=400)app_workspace_production_ready.pyAdded+272