jonathanjordan21 commited on
Commit
fa99c44
Β·
verified Β·
1 Parent(s): 689e27d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -2
app.py CHANGED
@@ -1,9 +1,32 @@
1
  import gradio as gr
2
  from parser import parse_resume
3
  # import json
 
 
4
 
5
- def process_input(job_description, resumes):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # resumes = [r for r in resumes if r and r.strip() != ""] # Remove empty
 
 
 
 
7
  if not job_description.strip() or not resumes:
8
  return "Please provide both job description and at least one resume."
9
 
@@ -38,7 +61,11 @@ initial_parsing = [
38
  {"name":"note", "type":"str", "description":"additional note which highlight the best or uniqueness of the person"}
39
  ]
40
 
 
 
 
41
 
 
42
  def update_json(data, name, data_type, desc):
43
  # if name in [x["name"] for x in data]:
44
  # data.remove(name)
@@ -123,6 +150,10 @@ with gr.Blocks() as demo:
123
  placeholder="Paste Resume here...",
124
  label="CV / Resume"
125
  )
 
 
 
 
126
  output = gr.Textbox(
127
  lines=8,
128
  label="Parsing Result",
@@ -138,7 +169,7 @@ with gr.Blocks() as demo:
138
  submit_btn = gr.Button("πŸš€ Parse Resume / CV")
139
  submit_btn.click(
140
  fn=process_input,
141
- inputs=[job_description, json_display],
142
  outputs=[thinking_output, output]
143
  )
144
 
 
1
  import gradio as gr
2
  from parser import parse_resume
3
  # import json
4
+ from langchain_docling.loader import ExportType
5
+ from langchain_docling import DoclingLoader
6
 
7
+ def process_file(file_path, resumes):
8
+ loader = DoclingLoader(file_path=file_path, export_type=ExportType.MARKDOWN)
9
+ job_description = loader.load()[0].page_content
10
+
11
+ if not job_description.strip() or not resumes:
12
+ return "Please provide both job description and at least one resume."
13
+
14
+ print("[CATEGORIES]", resumes)
15
+
16
+ thinking, results = parse_resume(job_description, resumes)
17
+ print("[THINKING]", thinking)
18
+ print("[RESULTS]", results)
19
+ # results = json.loads(results)
20
+ # print("[SUCCESS JSON PARSING]")
21
+ return thinking, results
22
+
23
+
24
+ def process_input(job_description, file_upload, resumes):
25
  # resumes = [r for r in resumes if r and r.strip() != ""] # Remove empty
26
+ print("[FILE UPLOAD]", file_upload)
27
+ if file_upload:
28
+ return process_file(file_upload, resumes)
29
+
30
  if not job_description.strip() or not resumes:
31
  return "Please provide both job description and at least one resume."
32
 
 
61
  {"name":"note", "type":"str", "description":"additional note which highlight the best or uniqueness of the person"}
62
  ]
63
 
64
+ def toggle_textbox(file):
65
+ print("[FILE TOOGLE]", file)
66
+ return gr.Textbox.update(interactive=False if file else True)
67
 
68
+
69
  def update_json(data, name, data_type, desc):
70
  # if name in [x["name"] for x in data]:
71
  # data.remove(name)
 
150
  placeholder="Paste Resume here...",
151
  label="CV / Resume"
152
  )
153
+ file_upload = gr.File(
154
+ label="Input Resume File"
155
+ )
156
+ file_upload.change(fn=toggle_textbox, inputs=file_upload, outputs=textbox)
157
  output = gr.Textbox(
158
  lines=8,
159
  label="Parsing Result",
 
169
  submit_btn = gr.Button("πŸš€ Parse Resume / CV")
170
  submit_btn.click(
171
  fn=process_input,
172
+ inputs=[job_description, file_upload, json_display],
173
  outputs=[thinking_output, output]
174
  )
175