Spaces:
Runtime error
Runtime error
import streamlit as st | |
import requests | |
import time | |
import os | |
def chat_with_ai(message): | |
api_url = os.getenv("CHAT_API_URL") # Vortex 3b models API | |
payload = {"message": message} | |
try: | |
response = requests.post(api_url, json=payload) | |
if response.status_code == 200: | |
return response.json().get('response') # Access 'response' key | |
else: | |
return {"error": "Failed to get a response from the AI API."} | |
except requests.RequestException as e: | |
return {"error": f"Error: {e}"} | |
# Streamlit app | |
def main(): | |
st.title("AI Resume Reviewer π") | |
st.sidebar.image("logo.png", use_column_width=True) # Display a logo in the sidebar | |
st.sidebar.markdown("## Resume Review") | |
st.sidebar.markdown("Please paste your resume content below.") | |
# User inputs for resume content | |
user_input = st.sidebar.text_area('Paste your resume content here (max 2048 characters):', "", max_chars=2048) | |
# Generate review when prompted | |
if st.sidebar.button('Review Resume'): | |
if user_input.lower() in ['quit', 'exit', 'bye']: | |
st.success("Goodbye! Have a great day!") | |
else: | |
with st.spinner("Requesting HelpingAI..."): | |
time.sleep(2) # Wait for 2 seconds | |
with st.spinner("Generating resume review. Please wait..."): | |
# Detailed and descriptive prompt | |
prompt = f"Please provide a comprehensive review of the following resume and suggest improvements. The goal is to enhance its effectiveness in conveying the candidate's skills and experiences. Here's the resume content: {user_input}" | |
response = chat_with_ai(prompt) | |
# Display generated review | |
st.subheader("Your Resume Review") | |
st.markdown(response) | |
# Save the review in the session state | |
if 'history' not in st.session_state: | |
st.session_state['history'] = [] | |
st.session_state['history'].append({"resume": user_input, "review": response}) | |
# Display history of reviewed resumes | |
if 'history' in st.session_state and st.session_state['history']: | |
st.markdown("---") | |
st.subheader("History of Reviewed Resumes") | |
for i, item in enumerate(st.session_state['history'], start=1): | |
st.markdown(f"**Resume {i}:**") | |
st.markdown(f"Resume Content:\n{item['resume']}") | |
st.markdown(f"Review:\n{item['review']}") | |
# About section | |
st.sidebar.markdown("## About") | |
st.sidebar.markdown("This application uses AI to review resumes based on the content you provide. It's designed to help you improve your resume. The application is made by Abhay Koul, also known as OEvortex, and it uses the API of HelpingAI, a company by OEvortex. You can learn more about OEvortex on YouTube.") | |
# Footer | |
st.sidebar.markdown("---") | |
st.sidebar.markdown("Β© 2023 AI Resume Reviewer by OEvortex, HelpingAI") | |
# Main area | |
st.markdown("---") | |
st.markdown("## Welcome to the AI Resume Reviewer! π") | |
st.markdown("To get started, please paste your resume content in the sidebar and click 'Review Resume'.") | |
st.markdown("The AI will review your resume and display the review here. You can then use these suggestions to improve your resume. Happy editing! π") | |
if __name__ == "__main__": | |
main() | |