naveenvenkatesh commited on
Commit
af9baee
·
verified ·
1 Parent(s): 139c05c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
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
- openai.api_key = os.getenv("OPENAI_API_KEY")
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
- # Define the prompt or input for the model
50
- prompt = f"""Analyze the resume to write the summary for following resume delimitted by triple backticks.
51
- ```{resume}```
52
- """
 
53
 
54
- # Generate a response from the GPT-3 model
55
- response = openai.Completion.create(
56
- engine='text-davinci-003',
57
- prompt=prompt,
58
- max_tokens=200,
59
- temperature=0,
60
- n=1,
61
- stop=None,
62
  )
63
 
64
- # Extract the generated text from the API response
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=gr.themes.Soft()) as app:
 
 
 
 
 
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