improve data
Browse files
app.py
CHANGED
|
@@ -8,6 +8,58 @@ import nest_asyncio
|
|
| 8 |
from pydantic_ai.messages import ModelMessage
|
| 9 |
import pdfplumber
|
| 10 |
import os
|
|
|
|
| 11 |
from dataclasses import dataclass
|
| 12 |
|
|
|
|
| 13 |
#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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from pydantic_ai.messages import ModelMessage
|
| 9 |
import pdfplumber
|
| 10 |
import os
|
| 11 |
+
from streamlit_pdf_viewer import pdf_viewer
|
| 12 |
from dataclasses import dataclass
|
| 13 |
|
| 14 |
+
#api_key
|
| 15 |
#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
|
| 16 |
+
|
| 17 |
+
api_key = os.getenv("api_key")
|
| 18 |
+
|
| 19 |
+
data = []
|
| 20 |
+
|
| 21 |
+
model = GroqModel("llama3-groq-70b-8192-tool-use-preview", api_key = api_key)
|
| 22 |
+
|
| 23 |
+
async def resume_AI(data):
|
| 24 |
+
agent = Agent(model=model,
|
| 25 |
+
|
| 26 |
+
system_prompt=(
|
| 27 |
+
"You are an expert in making resume",
|
| 28 |
+
"You have access to the resume text",
|
| 29 |
+
"Also return data in markdown formate"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
result = agent.run_sync(user_prompt="Improve the resume")
|
| 35 |
+
print(result.data)
|
| 36 |
+
|
| 37 |
+
def extract_data(feed):
|
| 38 |
+
|
| 39 |
+
with pdfplumber.open(feed) as pdf:
|
| 40 |
+
pages = pdf.pages
|
| 41 |
+
for p in pages:
|
| 42 |
+
data.append(p.extract_text())
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
return None
|
| 46 |
+
|
| 47 |
+
def ai_resume(data):
|
| 48 |
+
asyncio.run(resume_AI(data=data))
|
| 49 |
+
|
| 50 |
+
def main():
|
| 51 |
+
uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf")
|
| 52 |
+
if uploaded_file is not None:
|
| 53 |
+
extract_data(uploaded_file)
|
| 54 |
+
binary_data = uploaded_file.getvalue()
|
| 55 |
+
pdf_viewer(input=binary_data,
|
| 56 |
+
width=700)
|
| 57 |
+
if st.button("Improve Resume"):
|
| 58 |
+
ai_resume(data)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
if __name__ == '__main__':
|
| 63 |
+
import asyncio
|
| 64 |
+
nest_asyncio.apply()
|
| 65 |
+
main()
|