Spaces:
Configuration error
Configuration error
File size: 2,145 Bytes
351e529 5db4327 351e529 5db4327 351e529 5db4327 351e529 5db4327 351e529 5db4327 351e529 5db4327 351e529 5db4327 351e529 5db4327 e04c843 5db4327 e04c843 5db4327 c4a09f0 5db4327 351e529 5db4327 | 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 | import streamlit as st
import os
from dotenv import load_dotenv
from sidebar import generate_ai_summary,show_profile
from brain import setup_vector_db, get_llm, get_rag_chain
from recruiter_view import show_recruiter_form
from admin_view import show_admin_dashboard
#from admin_view import show_admin_dashboard
# Load Env & Config
load_dotenv()
st.set_page_config(page_title="Ahan Bose - AI Twin", layout="wide")
hf_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
# Initialize Backend
if not hf_token:
st.error("Hugging Face Token missing! Check your .env or Streamlit Secrets.")
st.stop()
# Build the brain
retriever = setup_vector_db()
llm = get_llm(hf_token)
rag_chain = get_rag_chain(retriever, llm)
# 1. Sidebar
#generate_ai_summary(llm)
show_profile()
# 2. Main UI Navigation
st.title("π€ Ahan Bose: AI Digital Twin")
tabs = st.tabs(["π¬ Chat with Me", "πΌ Recruiter Portal", "π Admin"])
with tabs[0]:
# Chat Logic
# 1. Sidebar
st.subheader("π€ AI Summary")
# Check if summary already exists in memory
if "ai_summary" in st.session_state:
st.info(st.session_state.ai_summary)
if st.button("π Regenerate"):
del st.session_state.ai_summary
st.rerun()
else:
st.caption("Click to generate a summary of Ahan's profile using AI.")
if st.button("β¨ Generate Summary"):
with st.spinner("Analyzing profile..."):
try:
summary = generate_ai_summary(llm)
st.session_state.ai_summary = summary
st.write(summary)
st.success("Summary generated! Scroll up to view.")
except Exception as e:
st.error(f"Error generating summary: {e}")
query = st.text_input("Ask me about my experience, skills, or projects:")
if st.button("Submit") and query:
with st.spinner("Thinking..."):
response = rag_chain.invoke(query)
st.markdown("### Answer:")
st.write(response)
with tabs[1]:
show_recruiter_form()
with tabs[2]:
show_admin_dashboard() |