Spaces:
Runtime error
Runtime error
Create SkipTrace.py
Browse files- pages/SkipTrace.py +62 -0
pages/SkipTrace.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import sys, os, requests
|
| 3 |
+
|
| 4 |
+
# ─── Ensure utils/ is importable ──────────────────────────────
|
| 5 |
+
UTILS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
| 6 |
+
if UTILS_PATH not in sys.path:
|
| 7 |
+
sys.path.append(UTILS_PATH)
|
| 8 |
+
|
| 9 |
+
from utils.backend import run_llm
|
| 10 |
+
|
| 11 |
+
st.title("🕵️ OSINT Skip-Trace AI Chatbot")
|
| 12 |
+
st.write("Search for a person, email, or domain and let AI summarize the OSINT results.")
|
| 13 |
+
|
| 14 |
+
# Init session state
|
| 15 |
+
if "skiptrace_chat" not in st.session_state:
|
| 16 |
+
st.session_state.skiptrace_chat = []
|
| 17 |
+
if "skiptrace_output" not in st.session_state:
|
| 18 |
+
st.session_state.skiptrace_output = []
|
| 19 |
+
|
| 20 |
+
# ─── OSINT Search Helper ──────────────────────────────────────
|
| 21 |
+
def run_osint_query(query: str) -> dict:
|
| 22 |
+
"""Perform lightweight OSINT searches (public endpoints + AI summary)."""
|
| 23 |
+
results = []
|
| 24 |
+
|
| 25 |
+
# Example: DuckDuckGo instant answers API
|
| 26 |
+
try:
|
| 27 |
+
url = f"https://api.duckduckgo.com/?q={query}&format=json&no_redirect=1&no_html=1"
|
| 28 |
+
resp = requests.get(url, timeout=10).json()
|
| 29 |
+
abstract = resp.get("AbstractText") or "No summary found."
|
| 30 |
+
results.append(f"🔎 DuckDuckGo: {abstract}")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
results.append(f"⚠️ DuckDuckGo error: {e}")
|
| 33 |
+
|
| 34 |
+
# AI summarization
|
| 35 |
+
ai_summary = run_llm(f"Provide an OSINT-style skip-trace summary for:\n{query}\n\nResults:\n" + "\n".join(results))
|
| 36 |
+
|
| 37 |
+
return {
|
| 38 |
+
"query": query,
|
| 39 |
+
"raw_results": results,
|
| 40 |
+
"ai_summary": ai_summary
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
# ─── Chatbot UI ───────────────────────────────────────────────
|
| 44 |
+
for msg in st.session_state.skiptrace_chat:
|
| 45 |
+
with st.chat_message(msg["role"]):
|
| 46 |
+
st.markdown(msg["content"])
|
| 47 |
+
|
| 48 |
+
if prompt := st.chat_input("Enter a name, email, or domain to OSINT..."):
|
| 49 |
+
st.session_state.skiptrace_chat.append({"role": "user", "content": prompt})
|
| 50 |
+
with st.chat_message("user"):
|
| 51 |
+
st.markdown(prompt)
|
| 52 |
+
|
| 53 |
+
# Run OSINT + AI
|
| 54 |
+
result = run_osint_query(prompt)
|
| 55 |
+
reply = f"**AI Skip-Trace Summary for '{prompt}':**\n\n{result['ai_summary']}"
|
| 56 |
+
|
| 57 |
+
with st.chat_message("assistant"):
|
| 58 |
+
st.markdown(reply)
|
| 59 |
+
|
| 60 |
+
# Save to state
|
| 61 |
+
st.session_state.skiptrace_chat.append({"role": "assistant", "content": reply})
|
| 62 |
+
st.session_state.skiptrace_output.append(result)
|