jonathanjordan21 commited on
Commit
96ccd72
·
verified ·
1 Parent(s): e75f63f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -22
app.py CHANGED
@@ -35,11 +35,18 @@ initial_parsing = [
35
 
36
 
37
  def update_json(data, name, data_type, desc):
 
 
38
  data.append(
39
  {"name":name, "type":data_type, "description":desc}
40
  )
41
  return data
42
 
 
 
 
 
 
43
 
44
  # UI definition
45
  with gr.Blocks() as demo:
@@ -54,24 +61,23 @@ with gr.Blocks() as demo:
54
  with gr.Column():
55
  @gr.render(inputs=resume_count)
56
  def render_count(count):
57
- for i in range(count):
58
- name = gr.Textbox(
59
- lines=1,
60
- placeholder=f"Category #{i+1} name",
61
- label=f"Name #{i+1}"
62
- )
63
- data_type = gr.Textbox(
64
- lines=1,
65
- placeholder=f"Category #{i+1} data type",
66
- label=f"Data Type #{i+1}"
67
- )
68
- desc = gr.Textbox(
69
- lines=1,
70
- placeholder=f"Category #{i+1} description",
71
- label=f"Description #{i+1}"
72
- )
73
-
74
- update_json_button.click(update_json, inputs=[json_display, name, data_type, desc], outputs=json_display)
75
 
76
  # resumes_list.append(
77
  # {"name":name, "type":data_type, "description":desc}
@@ -96,13 +102,22 @@ with gr.Blocks() as demo:
96
  # resumes_list.append(new_input)
97
  # return resumes_group.update(visible=True)
98
 
99
- add_resume_btn = gr.Button("➕ Add Another Category")
100
- add_resume_btn.click(lambda x: x + 1, resume_count, resume_count)
101
 
102
- update_json_button = gr.Button("Update Parsing")
 
 
 
 
 
 
 
 
103
 
104
  with gr.Column():
105
  json_display = gr.JSON(value=initial_parsing, label="Parsing Categories")
 
106
  job_description = gr.Textbox(
107
  lines=8,
108
  placeholder="Paste Resume here...",
@@ -114,7 +129,7 @@ with gr.Blocks() as demo:
114
  # label="JSON Result",
115
  # interactive=False
116
  # )
117
- output = gr.JSON(show_indices=True)
118
  thinking_output = gr.Textbox(
119
  lines=10,
120
  label="Thinking Result",
 
35
 
36
 
37
  def update_json(data, name, data_type, desc):
38
+ # if name in [x["name"] for x in data]:
39
+ # data.remove(name)
40
  data.append(
41
  {"name":name, "type":data_type, "description":desc}
42
  )
43
  return data
44
 
45
+ def delete_json(data, name):
46
+ for i,x in enumerate(data):
47
+ if x["name"] == name:
48
+ data.pop(i)
49
+ return data
50
 
51
  # UI definition
52
  with gr.Blocks() as demo:
 
61
  with gr.Column():
62
  @gr.render(inputs=resume_count)
63
  def render_count(count):
64
+ name = gr.Textbox(
65
+ lines=1,
66
+ placeholder=f"Category #{i+1} name",
67
+ label=f"Name #{i+1}"
68
+ )
69
+ data_type = gr.Textbox(
70
+ lines=1,
71
+ placeholder=f"Category #{i+1} data type",
72
+ label=f"Data Type #{i+1}"
73
+ )
74
+ desc = gr.Textbox(
75
+ lines=1,
76
+ placeholder=f"Category #{i+1} description",
77
+ label=f"Description #{i+1}"
78
+ )
79
+
80
+ update_json_button.click(update_json, inputs=[json_display, name, data_type, desc], outputs=json_display)
 
81
 
82
  # resumes_list.append(
83
  # {"name":name, "type":data_type, "description":desc}
 
102
  # resumes_list.append(new_input)
103
  # return resumes_group.update(visible=True)
104
 
105
+ # add_resume_btn = gr.Button("➕ Add Another Category")
106
+ # add_resume_btn.click(lambda x: x + 1, resume_count, resume_count)
107
 
108
+ update_json_button = gr.Button("Update Parsing Categories")
109
+
110
+ category_delete = gr.Textbox(
111
+ lines=1,
112
+ placeholder=f"Category Name",
113
+ label=f"Remove Category Based on It's Name"
114
+ )
115
+
116
+ delete_json_button = gr.Button("Delete Category")
117
 
118
  with gr.Column():
119
  json_display = gr.JSON(value=initial_parsing, label="Parsing Categories")
120
+ delete_json_button.click(delete_json, inputs=[json_display, category_delete], outputs=json_display)
121
  job_description = gr.Textbox(
122
  lines=8,
123
  placeholder="Paste Resume here...",
 
129
  # label="JSON Result",
130
  # interactive=False
131
  # )
132
+ output = gr.JSON(show_indices=True, label="Parsing Output")
133
  thinking_output = gr.Textbox(
134
  lines=10,
135
  label="Thinking Result",