Files
lead-engine-mvp/app.py
2026-01-30 11:00:44 +00:00

56 lines
1.8 KiB
Python

import streamlit as st
import pandas as pd
from db import get_leads, init_db
import json
st.set_page_config(page_title="TradingTwins Lead Engine", layout="wide")
st.title("🚀 Lead Engine: TradingTwins")
# Metrics
leads = get_leads()
df = pd.DataFrame(leads)
if not df.empty:
col1, col2, col3 = st.columns(3)
col1.metric("Total Leads", len(df))
col2.metric("New Today", len(df[df['status'] == 'new']))
col3.metric("Action Required", len(df[df['status'] == 'enriched']))
st.subheader("Latest Inquiries")
for index, row in df.iterrows():
with st.expander(f"{row['company_name']} - {row['status']}"):
c1, c2 = st.columns(2)
c1.write(f"**Contact:** {row['contact_name']}")
c1.write(f"**Email:** {row['email']}")
enrichment = json.loads(row['enrichment_data']) if row['enrichment_data'] else {}
if enrichment:
c2.success(f"Score: {enrichment.get('score')}")
c2.write(f"**Vertical:** {enrichment.get('vertical')}")
c2.info(f"💡 {enrichment.get('recommendation')}")
if st.button(f"Generate Response for {row['id']}"):
st.write("Generating draft... (Simulated)")
# Here we would call the LLM
draft = f"Hallo {row['contact_name']},\n\ndanke für Ihre Anfrage..."
st.text_area("Draft", draft, height=200)
else:
st.info("No leads found. Waiting for ingest...")
if st.sidebar.button("Run Ingest (Mock)"):
from ingest import ingest_mock_leads
init_db()
count = ingest_mock_leads()
st.sidebar.success(f"Ingested {count} leads.")
st.rerun()
if st.sidebar.button("Run Enrichment"):
from enrich import run_enrichment
run_enrichment()
st.sidebar.success("Enrichment complete.")
st.rerun()