Spaces:
Sleeping
Sleeping
File size: 5,157 Bytes
3d312b2 41395df 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 0cc1db6 3d312b2 516f346 eb55a66 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 a26c578 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 516f346 3d312b2 |
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
import os
import streamlit as st
from crewai import Crew
from crewai_tools import PDFSearchTool, ScrapeWebsiteTool, SerperDevTool
from dotenv import load_dotenv
from PIL import Image
from src.agents import MultiAgents
from src.tasks import MultiTasks
# Load environment variables
load_dotenv()
os.environ["OPENAI_MODEL_NAME"] = "gpt-3.5-turbo"
# Initialize agents and tasks
agents = MultiAgents()
tasks = MultiTasks()
search_tool = SerperDevTool()
scrape_tool = ScrapeWebsiteTool()
# Load icon image
image_icon = Image.open("src/assistente-de-robo.png")
image_icon = image_icon.resize((100, 100))
def save_uploaded_file(uploaded_file):
temp_dir = "tempDir"
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)
temp_file_path = os.path.join(temp_dir, uploaded_file.name)
with open(temp_file_path, "wb") as f:
f.write(uploaded_file.getbuffer())
return temp_file_path
def read_file(file_path):
pdf_search_tool = PDFSearchTool(pdf=file_path)
return pdf_search_tool
def main():
with st.sidebar:
st.title("Hello, I'm Taylor AI!\nYour Career Consultant:")
st.write(
"""I am here to help you highlight your skills and
experiences for the job market.I am currently using the gpt-3.
5-turbo model."""
)
st.session_state.openai_api_key = st.text_input(
"Enter your OpenAI token:", type="password"
)
st.session_state.serper_api_key = st.text_input(
"Enter your SERPER token:", type="password"
)
st.image(image_icon, use_column_width=True)
if st.session_state.openai_api_key:
os.environ["OPENAI_API_KEY"] = st.session_state.openai_api_key
if st.session_state.serper_api_key:
os.environ["SERPER_API_KEY"] = st.session_state.serper_api_key
st.header("Career Consultant")
if "result_done" not in st.session_state:
st.session_state.result_done = False
if "result" not in st.session_state:
st.session_state.result = None
candidate_name = st.text_input("Enter your name:")
job_posting_url = st.text_input("Enter the job posting URL:")
github_url = st.text_input("Enter your GitHub URL:")
uploaded_resume = st.file_uploader(
"Please upload your resume in PDF format",
type=["pdf"],
)
if uploaded_resume:
if uploaded_resume.type == "application/pdf":
temp_file_path = save_uploaded_file(uploaded_resume)
pdf_search_tool = read_file(temp_file_path)
os.remove(temp_file_path)
if st.button("Perform Analysis"):
# Agents
researcher = agents.researcher(search_tool, scrape_tool)
profile_creator = agents.profile_creator(
search_tool, scrape_tool, pdf_search_tool
)
professional_consultant = agents.professional_consultant(
search_tool, scrape_tool, pdf_search_tool
)
interview_preparer = agents.interview_preparer(
search_tool, scrape_tool, pdf_search_tool
)
# Tasks
research_task = tasks.research_task(researcher, job_posting_url)
profile_manager_task = tasks.profile_manager_task(
profile_creator, github_url, candidate_name
)
resume_adaptation_task = tasks.resume_adaptation_task(
candidate_name,
professional_consultant,
profile_manager_task,
profile_manager_task,
)
interview_preparation_task = tasks.interview_preparation_task(
interview_preparer,
research_task,
profile_manager_task,
resume_adaptation_task,
)
crew = Crew(
agents=[
researcher,
profile_creator,
professional_consultant,
interview_preparer,
],
tasks=[
research_task,
profile_manager_task,
resume_adaptation_task,
interview_preparation_task,
],
verbose=True,
)
inputs = {
"candidate_name": candidate_name,
"github_url": github_url,
"job_posting_url": job_posting_url,
"uploaded_resume": uploaded_resume,
}
# Execute the analysis
result = crew.kickoff(inputs=inputs)
st.session_state.result_done = True
st.session_state.result = result
st.session_state.show_success = False
st.write(st.session_state.result)
resume_file_path = os.path.basename(
f"custom_resume_{candidate_name}.md"
)
with open(resume_file_path, "rb") as file:
btn = st.download_button(
label="Download Generated Resume",
data=file,
file_name=os.path.basename(resume_file_path),
mime="text/plain",
)
if btn:
st.success("Download Started!")
st.success(f"Analysis completed! Thank you, {candidate_name}!")
if __name__ == "__main__":
main()
|