srijaydeshpande commited on
Commit
a01bfa9
·
verified ·
1 Parent(s): d27e3ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -71,13 +71,13 @@ def txt_to_html(text):
71
  html_content += "</body></html>"
72
  return html_content
73
 
74
- # def craft_cv(llm, prompt, maxtokens, temperature, top_probability):
75
- def craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability):
76
  instruction = "Given input CV and job description. Please revise the CV according to the given job description and output the revised CV."
77
  output = llm.create_chat_completion(
78
  messages=[
79
- {"from": "user", "value": instruction + ' Input CV: ' + cv_text + ' , Job Description: ' + job_description},
80
- # {"from": "user", "value": prompt},
81
  ],
82
  max_tokens=maxtokens,
83
  temperature=temperature
@@ -150,13 +150,13 @@ def convert_to_json(llm, cv_text, maxtokens, temperature, top_probability):
150
  output = output['choices'][0]['message']['content']
151
  return output
152
 
153
- # def pdf_to_text(prompt, maxtokens=2048, temperature=0, top_probability=0.95):
154
  @spaces.GPU(duration=40)
155
- def pdf_to_text(cv_file, job_description, llm_type='Fine tuned Llama3', maxtokens=2048, temperature=0, top_probability=0.95):
 
156
 
157
- converter = DocumentConverter()
158
- result = converter.convert(cv_file)
159
- cv_text = result.document.export_to_markdown()
160
 
161
  # if(llm_type=='Fine tuned Llama3'):
162
  llm = Llama(
@@ -166,11 +166,11 @@ def pdf_to_text(cv_file, job_description, llm_type='Fine tuned Llama3', maxtoken
166
  n_batch=1024,
167
  n_ctx=8192,
168
  )
169
- cv_text, crafted_cv = craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability)
170
- print('CRAFTED CV IS ',crafted_cv)
171
- # cv_text, crafted_cv = craft_cv(llm, prompt, maxtokens, temperature, top_probability)
172
  crafted_cv = convert_to_json(llm, crafted_cv, maxtokens, temperature, top_probability)
173
- print('FINAL CV IS ',crafted_cv)
174
  return crafted_cv
175
 
176
  temp_slider = gr.Slider(minimum=0, maximum=2, value=0.9, label="Temperature Value")
@@ -182,7 +182,8 @@ output_text = gr.Textbox()
182
  llm_type = gr.Radio(["Fine tuned Llama3"])
183
  iface = gr.Interface(
184
  fn=pdf_to_text,
185
- inputs=[cv_file, prompt_text, llm_type],
 
186
  outputs=['text'],
187
  title='Craft CV',
188
  description="This application assists to customize CV based on input job description",
 
71
  html_content += "</body></html>"
72
  return html_content
73
 
74
+ def craft_cv(llm, prompt, maxtokens, temperature, top_probability):
75
+ # def craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability):
76
  instruction = "Given input CV and job description. Please revise the CV according to the given job description and output the revised CV."
77
  output = llm.create_chat_completion(
78
  messages=[
79
+ # {"from": "user", "value": instruction + ' Input CV: ' + cv_text + ' , Job Description: ' + job_description},
80
+ {"from": "user", "value": prompt},
81
  ],
82
  max_tokens=maxtokens,
83
  temperature=temperature
 
150
  output = output['choices'][0]['message']['content']
151
  return output
152
 
 
153
  @spaces.GPU(duration=40)
154
+ def pdf_to_text(prompt, maxtokens=2048, temperature=0, top_probability=0.95):
155
+ # def pdf_to_text(cv_file, job_description, llm_type='Fine tuned Llama3', maxtokens=2048, temperature=0, top_probability=0.95):
156
 
157
+ # converter = DocumentConverter()
158
+ # result = converter.convert(cv_file)
159
+ # cv_text = result.document.export_to_markdown()
160
 
161
  # if(llm_type=='Fine tuned Llama3'):
162
  llm = Llama(
 
166
  n_batch=1024,
167
  n_ctx=8192,
168
  )
169
+ # cv_text, crafted_cv = craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability)
170
+ # print('CRAFTED CV IS ',crafted_cv)
171
+ cv_text, crafted_cv = craft_cv(llm, prompt, maxtokens, temperature, top_probability)
172
  crafted_cv = convert_to_json(llm, crafted_cv, maxtokens, temperature, top_probability)
173
+ # print('FINAL CV IS ',crafted_cv)
174
  return crafted_cv
175
 
176
  temp_slider = gr.Slider(minimum=0, maximum=2, value=0.9, label="Temperature Value")
 
182
  llm_type = gr.Radio(["Fine tuned Llama3"])
183
  iface = gr.Interface(
184
  fn=pdf_to_text,
185
+ # inputs=[cv_file, prompt_text, llm_type],
186
+ inputs=['text'],
187
  outputs=['text'],
188
  title='Craft CV',
189
  description="This application assists to customize CV based on input job description",