AI-Resume / app.py
sarim's picture
improve promtp
1f39c58
raw
history blame
2.95 kB
import asyncio
import re
from pydantic_ai.result import ResultData, RunResult
import streamlit as st
from pydantic_ai import Agent,RunContext, Tool
from pydantic_ai.models.groq import GroqModel
import nest_asyncio
from pydantic_ai.messages import ModelMessage
import pdfplumber
import os
from streamlit_pdf_viewer import pdf_viewer
from dataclasses import dataclass
#api_key
#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
api_key = os.getenv("api_key")
data = []
user_input = ""
model = GroqModel("llama3-groq-70b-8192-tool-use-preview", api_key = api_key)
async def resume_AI(data):
agent = Agent(model=model,
deps_type=str,
system_prompt=(
"You are an expert in making resume",
"Review this resume and identify areas for improvement in structure, content, and formatting. Suggest specific changes to make it more professional and effective.",
"Rewrite the following bullet points to make them more impactful, concise, and result-oriented. Use action verbs and quantify achievements wherever possible.",
"Review this resume for grammar, clarity, and conciseness. Suggest edits to improve readability and professionalism.",
"Optimize this resume with keywords and phrases relevant to specific job description from 'getJobDetail' to improve its chances of passing through Applicant Tracking Systems (ATS)",
"Revise this resume to align with the requirements of [specific job role] from 'getJobDetail' in [industry] from 'getJobDetail' . Highlight relevant skills, experiences, and achievements that match the job description.",
"Rewrite this resume to focus on transferable skills and experiences that would be relevant for transitioning to [new industry or role]."
"Your answer should be a new and improve resume in markdown formate",
)
)
@agent.tool
async def getJobDetail(ctx: RunContext) -> str:
"""
This method return job description
that resume needs to be update to
"""
return ctx.deps
result = agent.run_sync(user_prompt=f"Improve this resume: {data}",deps=user_input)
st.markdown(result.data)
def extract_data(feed):
with pdfplumber.open(feed) as pdf:
pages = pdf.pages
for p in pages:
data.append(p.extract_text())
return None
def ai_resume(data):
asyncio.run(resume_AI(data=data))
def main():
uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf")
user_input = st.text_input(label="Enter job detail")
if uploaded_file is not None:
extract_data(uploaded_file)
binary_data = uploaded_file.getvalue()
pdf_viewer(input=binary_data,
width=700)
if st.button("Improve Resume"):
ai_resume(data)
if __name__ == '__main__':
import asyncio
nest_asyncio.apply()
main()