File size: 2,933 Bytes
8f82834
 
 
 
 
 
 
 
 
 
425c047
8f82834
 
425c047
8f82834
425c047
 
 
 
1587db6
425c047
7376b4e
425c047
 
 
 
 
868a4a1
29a9356
1afc6fc
9d96c6c
 
868a4a1
 
 
9d96c6c
3260a4b
0f2463d
9d96c6c
3260a4b
425c047
 
 
1afc6fc
 
 
 
425c047
9d9a236
edec77b
e21f174
425c047
 
 
 
 
 
1afc6fc
 
425c047
 
 
 
 
 
 
 
 
 
b0755cc
425c047
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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,
        system_prompt=(
            "Act as a professional resume editor and career consultant. Analyze the provided resume and improve it",
            "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.",
            "Rewrite my resume to be more concise and impactful",
            "Use strong action verbs and quantify my accomplishments whenever possible.",
            "Correct any grammar, spelling, or punctuation errors.",
            "Improve sentence structure for clarity and professionalism.",
            "Incorporate industry-specific keywords and phrases to make the resume ATS-friendly.",
            "Create a compelling summary/profile section that reflects my career goals.",
           # "Incorporate keywords relevant to the target industry and roles",
            #"Optimize the resume for Applicant Tracking Systems (ATS)."
            "Your answer should be a new and improve resume in markdown formate",
            #"Answer should be in markdown formate"
        )
        
    )
    # @agent.tool
    # def jobDescription(ctx: RunContext)-> str:
    #     """ Return Job Description to which you have to update and imropve resume based on  """
    #     return user_input

    print(data)
    result = agent.run_sync(user_prompt=f"Improve this resume: {data}")
    st.markdown(result.data)

def extract_data(feed):
    
    with pdfplumber.open(feed) as pdf:
        pages = pdf.pages
        for p in pages:
            print(p.extract_words())
            print(p.extract_text_lines())
            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_area(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()