sanjaystarc's picture
Update app.py
7ed1600 verified
import streamlit as st
import google.generativeai as genai
import os
# --- Configuration ---
GEMINI_API_KEY = os.environ.get('GEMINI_API_KEY')
# Check if API key is available
if not GEMINI_API_KEY:
st.error("""
🚨 GEMINI_API_KEY not found!
Please make sure you've:
1. Created an API key at https://aistudio.google.com/
2. Added it to Hugging Face Secrets with the name 'GEMINI_API_KEY'
""")
st.stop()
# Configure Gemini
try:
genai.configure(api_key=GEMINI_API_KEY)
# Use the correct model name from your available list
model = genai.GenerativeModel('models/gemini-2.0-flash-001') # Using a stable model
# Test the API
test_response = model.generate_content("Say 'API test successful'")
st.success(f"👋Welcome - I’m glad you’re here - By Sanjay PS" )
except Exception as e:
st.error(f"❌ API configuration failed: {str(e)}")
st.stop()
# Sample resume data - REPLACE WITH YOUR ACTUAL RESUME TEXT
RESUME_TEXT = """
SANJAY PANNERSELVAM(sanjaystarc or sanjay PS)
AI Specialist
📧 sanjaypannerselvam12@gmail.com
| 📞 +91 63818 96958
📍 Tiruchengode,Namakkal, Tamil Nadu,pincode - 637 209
instagram id : @dale_sanjay_starc
date of birth : 17.01.2005
linkedIn : Sanjay Ps
Objective
To obtain a responsible position that utilizes my skills and provides opportunities for professional growth and career development.
Education
Bachelor’s in Commerce with Computer Applications (B.Com CA) Degree
Sengunthar Arts and Science College
2022 – 2025 | Tiruchengode
Higher Secondary (HSC)
Sri Renga Vidhyalaya Matric Hr. Secondary School
2020 – 2022 | Tiruchengode
Secondary School (SSLC)
New Oxford Matriculation School
2019 – 2020 | Tiruchengode
Skills
Artificial Intelligence & Automation:
Prompt Engineering | Generative AI Tools | Business Process Automation | AI Product Strategy | Responsible AI (Ethical & Safe AI Practices) | Large Language Models (LLMs) – Usage & Integration
Data & Office Tools:
MS Excel | MS Power BI | MS Word | MS PowerPoint
Soft Skills:
Communication | Teamwork | Consistency | Script Writing & Storytelling
Programming Languages:
Python | SQL
Languages Known:
English | Tamil
Projects
1. Intelligent Document Q&A with RAG System
Developed a conversational AI that allows users to ask questions and get instant answers from their own documents (PDFs, Word files). The system uses a Retrieval-Augmented Generation (RAG) architecture to fetch relevant information and generate accurate, source-based responses—minimizing AI hallucinations.
2. Context-Aware Document Analysis Chatbot
Created an AI chatbot that understands the context of uploaded documents. It enables users to interact naturally with their data to extract key points, summarize content, and obtain precise answers—all based solely on the uploaded source material.
Certificates
Python Certificate
Generative AI Certificate
AI & ML Certificate
Courses
Foundations of AI and ML – Microsoft (Coursera)
Successfully completed the Foundations of AI and ML course.
Generative AI for Everyone – DeepLearning.AI (Coursera)
Successfully completed the Generative AI for Everyone course.
Generative AI Applications with Python – Google (GUVI)
Successfully completed the Generative AI Applications course.
Practical Machine Learning – GUVI
Successfully completed the Practical Machine Learning course.
partners and friends :
Aadhithiya,Abishek,
Aniruth,Sameer,
Dhilip kumar,bhuvi MF.
Declaration
I hereby declare that all the details mentioned above are true and correct to the best of my knowledge and belief.
"""
# System Prompt
system_prompt = """
You are a professional AI assistant that answers questions about a candidate based ONLY on the provided resume text.
RULES:
1. Only use information from the resume text below and add extra words to increase his value .
2. Be brief and direct in your answers
3. If information isn't in the resume, say "That information is not available, Please only ask about his professional background ."
4. Only answer professional questions about skills, education, friends and partners, age, projects, and experience
5. Buildup him like he is only who can do it .
6. Add your own extra fittings that match him .
"""
# Main App
st.title("🐦‍🔥 AI Assistant for Sanjay PS")
st.caption("Ask me anything about Sanjay PS professional background!")
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat messages
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Chat input
if prompt := st.chat_input("What would you like to know about sanjay PS in his profession ?"):
# Display user message
st.chat_message("user").markdown(prompt)
st.session_state.messages.append({"role": "user", "content": prompt})
# Prepare prompt for Gemini
full_prompt = f"{system_prompt}\n\nRESUME TEXT:\n{RESUME_TEXT}\n\nQUESTION: {prompt}\n\nANSWER:"
try:
response = model.generate_content(full_prompt)
answer = response.text
# Display assistant response
with st.chat_message("assistant"):
st.markdown(answer)
st.session_state.messages.append({"role": "assistant", "content": answer})
except Exception as e:
error_msg = f"Error generating response: {str(e)}"
st.error(error_msg)