robertselvam KarthickAdopleAI commited on
Commit
34df91a
1 Parent(s): 35b2f8b

Update app.py (#2)

Browse files

- Update app.py (730c947fbe9084f367a8adbe0b93a8de46f9d09d)


Co-authored-by: M <KarthickAdopleAI@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -3,6 +3,7 @@ import openai
3
  import PyPDF2
4
  import gradio as gr
5
  import docx
 
6
 
7
  class CourseGenarator:
8
  def __init__(self):
@@ -46,23 +47,21 @@ class CourseGenarator:
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
 
 
3
  import PyPDF2
4
  import gradio as gr
5
  import docx
6
+ from openai import OpenAI
7
 
8
  class CourseGenarator:
9
  def __init__(self):
 
47
  resume = self.extract_text_from_file(resume_path)
48
 
49
 
50
+ # Create a conversation for the OpenAI chat API
51
+ conversation = [
52
+ {"role": "system", "content": "You are a Resume Summarizer."},
53
+ {"role": "user", "content": f"""Analyze the Given Resume and Summarize {resume}"""}
54
+ ]
55
 
56
+ # Call OpenAI GPT-3.5-turbo
57
+ chat_completion = self.client.chat.completions.create(
58
+ model = "gpt-3.5-turbo",
59
+ messages = conversation,
60
+ max_tokens=500,
61
+ temperature=0
 
 
62
  )
63
 
64
+ generated_text = chat_completion.choices[0].message.content
 
65
 
66
  return generated_text
67