Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,11 @@ import openai
|
|
3 |
import PyPDF2
|
4 |
import gradio as gr
|
5 |
import docx
|
|
|
6 |
|
7 |
class CourseGenarator:
|
8 |
def __init__(self):
|
9 |
-
|
10 |
|
11 |
def extract_text_from_file(self,file_path):
|
12 |
# Get the file extension
|
@@ -42,38 +43,37 @@ class CourseGenarator:
|
|
42 |
return "Unsupported file type"
|
43 |
|
44 |
def response(self,resume_path):
|
|
|
45 |
resume_path = resume_path.name
|
46 |
resume = self.extract_text_from_file(resume_path)
|
47 |
|
48 |
|
49 |
-
#
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
-
#
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
max_tokens=
|
59 |
-
temperature=0
|
60 |
-
n=1,
|
61 |
-
stop=None,
|
62 |
)
|
63 |
|
64 |
-
|
65 |
-
generated_text = response.choices[0].text.strip()
|
66 |
|
67 |
return generated_text
|
68 |
|
69 |
def gradio_interface(self):
|
70 |
-
with gr.Blocks(css="style.css",theme=
|
|
|
|
|
|
|
|
|
|
|
71 |
with gr.Row(elem_id="col-container"):
|
72 |
-
with gr.Column():
|
73 |
-
gr.HTML("<br>")
|
74 |
-
gr.HTML(
|
75 |
-
"""<h1 style="text-align:center; color:"white">ADOPLE AI Resume Summarizer</h1> """
|
76 |
-
)
|
77 |
with gr.Column():
|
78 |
resume = gr.File(label="Resume",elem_classes="heightfit")
|
79 |
|
|
|
3 |
import PyPDF2
|
4 |
import gradio as gr
|
5 |
import docx
|
6 |
+
from openai import OpenAI
|
7 |
|
8 |
class CourseGenarator:
|
9 |
def __init__(self):
|
10 |
+
pass
|
11 |
|
12 |
def extract_text_from_file(self,file_path):
|
13 |
# Get the file extension
|
|
|
43 |
return "Unsupported file type"
|
44 |
|
45 |
def response(self,resume_path):
|
46 |
+
client = OpenAI()
|
47 |
resume_path = resume_path.name
|
48 |
resume = self.extract_text_from_file(resume_path)
|
49 |
|
50 |
|
51 |
+
# Create a conversation for the OpenAI chat API
|
52 |
+
conversation = [
|
53 |
+
{"role": "system", "content": "You are a Resume Summarizer."},
|
54 |
+
{"role": "user", "content": f"""Analyze the Given Resume and Summarize {resume}"""}
|
55 |
+
]
|
56 |
|
57 |
+
# Call OpenAI GPT-3.5-turbo
|
58 |
+
chat_completion = client.chat.completions.create(
|
59 |
+
model = "gpt-3.5-turbo",
|
60 |
+
messages = conversation,
|
61 |
+
max_tokens=500,
|
62 |
+
temperature=0
|
|
|
|
|
63 |
)
|
64 |
|
65 |
+
generated_text = chat_completion.choices[0].message.content
|
|
|
66 |
|
67 |
return generated_text
|
68 |
|
69 |
def gradio_interface(self):
|
70 |
+
with gr.Blocks(css="style.css",theme='karthikeyan-adople/hudsonhayes-gray') as app:
|
71 |
+
gr.HTML("""<center class="darkblue" style='background-color:rgb(0,1,36); text-align:center;padding:30px;'><center>
|
72 |
+
<img class="leftimage" align="left" src="https://companieslogo.com/img/orig/RAND.AS_BIG-0f1935a4.png?t=1651813778" alt="Image" width="210" height="210">
|
73 |
+
<h1 class ="center" style="color:#fff">ADOPLE AI</h1></center>
|
74 |
+
<br><center><h1 style="color:#fff">Resume Summarizer</h1></center>""")
|
75 |
+
|
76 |
with gr.Row(elem_id="col-container"):
|
|
|
|
|
|
|
|
|
|
|
77 |
with gr.Column():
|
78 |
resume = gr.File(label="Resume",elem_classes="heightfit")
|
79 |
|