srijaydeshpande commited on
Commit
3f31391
·
verified ·
1 Parent(s): ba1506c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -71,8 +71,8 @@ def txt_to_html(text):
71
  html_content += "</body></html>"
72
  return html_content
73
 
74
- def craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability):
75
  # def craft_cv(llm, prompt, 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=[
@@ -152,19 +152,20 @@ def convert_to_json(llm, cv_text, maxtokens, temperature, top_probability):
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, 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
- llm = Llama(
162
- model_path="models/" + model_id,
163
- flash_attn=True,
164
- n_gpu_layers=81,
165
- n_batch=1024,
166
- n_ctx=8192,
167
- )
 
168
  cv_text, crafted_cv = craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability)
169
  # cv_text, crafted_cv = craft_cv(llm, prompt, maxtokens, temperature, top_probability)
170
  crafted_cv = convert_to_json(llm, crafted_cv, maxtokens, temperature, top_probability)
@@ -179,7 +180,7 @@ output_text = gr.Textbox()
179
  llm_type = gr.Radio(["Fine tuned Llama3"])
180
  iface = gr.Interface(
181
  fn=pdf_to_text,
182
- inputs=[cv_file, prompt_text],
183
  outputs=['text'],
184
  title='Craft CV',
185
  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=[
 
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(
163
+ model_path="models/" + model_id,
164
+ flash_attn=True,
165
+ n_gpu_layers=81,
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
  # cv_text, crafted_cv = craft_cv(llm, prompt, maxtokens, temperature, top_probability)
171
  crafted_cv = convert_to_json(llm, crafted_cv, maxtokens, temperature, top_probability)
 
180
  llm_type = gr.Radio(["Fine tuned Llama3"])
181
  iface = gr.Interface(
182
  fn=pdf_to_text,
183
+ inputs=[cv_file, prompt_text, llm_type],
184
  outputs=['text'],
185
  title='Craft CV',
186
  description="This application assists to customize CV based on input job description",