Vincent Claes commited on
Commit
d2f51cb
1 Parent(s): 0478601

improve format of the app

Browse files
Files changed (2) hide show
  1. app.py +205 -32
  2. requirements.txt +13 -14
app.py CHANGED
@@ -7,22 +7,33 @@ import recruiting_assistant
7
 
8
  def search_resume(input_text):
9
  url = f"https://n970resrb9.execute-api.eu-west-1.amazonaws.com/dev/prediction" # replace with your API endpoint
10
- headers = {'Content-Type': 'application/json', "x-api-key": os.environ["API_KEY"]} # adjust headers as needed
11
- response = requests.post(url, headers=headers, data=json.dumps({"text": input_text}))
 
 
 
 
 
12
  response_data = response.json()
13
 
14
- if 'prediction' in response_data:
15
  prediction = response_data["prediction"]
16
  if isinstance(prediction, list):
17
  # Insert a newline after each '.'
18
  # Insert a newline after each '.' and add "Candidate <follow up number>:\n" before each item
19
- updated_prediction = [f"Candidate {i+1}:\n=============================\n{s}" for i, s in enumerate(prediction)]
20
- updated_prediction = [s.replace('. ', '.\n') for s in updated_prediction]
21
- updated_prediction = [s.replace('•', '\n - ') for s in updated_prediction]
 
 
 
22
  return "\n\n".join(updated_prediction)
23
  return "No 'prediction' key found in the response or the 'body' is not a list."
24
 
25
- examples = [["""
 
 
 
26
  DATA SCIENTIST - GENTIS
27
  ========================
28
  I am in contact with a top company in Ghent where they are looking for an additional Data Scientist. Beware... Once you start there, you won't be leaving anytime soon. The company likes to keep their employees happy, so few leave.
@@ -45,9 +56,10 @@ Lots of remote work and flexibility, so bye bye traffic JAMS!
45
  A renovated office with everything you could dream of full with surprises and extras
46
 
47
  If you are interested or want more info, don't hesitate to contact me.
48
- """],
49
- [
50
  """
 
 
 
51
  Payroll, Benefits & Office Manager
52
  ================================
53
 
@@ -68,38 +80,199 @@ A company on a human scale in which you quickly see the impact of your actions
68
  An attractive salary package with company car, accompanied by various extra-legal benefits (meal vouchers, group insurance, hospitalization insurance, etc.)
69
  39 days off per year
70
  """
71
- ]
72
  ]
73
 
74
- demo = gr.Blocks()
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  with demo:
78
- gr.Markdown("""
79
- # Recruiter Assistant
80
- ## 1. Provide a vacancy and get back relevant resumes from a database
81
- We have about 1000 resumes in our database: https://huggingface.co/datasets/Sachinkelenjaguri/Resume_dataset
82
- """)
83
- text_vacancy = gr.Textbox(hint="Paste here a Vacancy...", lines=7, label="Copy/paste here a vacancy")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  b1 = gr.Button("Search Resume")
85
- text_search_result = gr.Textbox(hint="Top resumes will appear here ...", label="Top resumes found in the database")
 
 
 
86
  b1.click(search_resume, inputs=text_vacancy, outputs=text_search_result)
87
- gr.Markdown("""
88
- ## 2. Select an appropriate resume for this vacancy, paste it in the textfield and write a relevant introduction email
89
- """)
90
- text_resume = gr.Textbox(hint="Paste here a Resume...", label="Copy / Paste here your prefered resume from above and click the button to write an intro ")
 
 
 
 
 
 
91
  b2 = gr.Button("Write a relevant intro")
92
- gr.Markdown("""
93
- ## 3. You have a relevant introduction email to send to the customer
94
- """)
 
 
 
95
  text_intro = gr.Textbox(label="Intro Email")
96
  evaluation = gr.Textbox(label="Evaluation of the skills")
97
- b2.click(recruiting_assistant.create_intro,
98
- inputs=[
99
- text_vacancy,
100
- text_resume
101
- ],
102
- outputs=[text_intro, evaluation]
103
  )
104
 
105
  gr.Examples(
@@ -110,4 +283,4 @@ with demo:
110
  cache_examples=False,
111
  )
112
 
113
- demo.launch()
 
7
 
8
  def search_resume(input_text):
9
  url = f"https://n970resrb9.execute-api.eu-west-1.amazonaws.com/dev/prediction" # replace with your API endpoint
10
+ headers = {
11
+ "Content-Type": "application/json",
12
+ "x-api-key": os.environ["API_KEY"],
13
+ } # adjust headers as needed
14
+ response = requests.post(
15
+ url, headers=headers, data=json.dumps({"text": input_text})
16
+ )
17
  response_data = response.json()
18
 
19
+ if "prediction" in response_data:
20
  prediction = response_data["prediction"]
21
  if isinstance(prediction, list):
22
  # Insert a newline after each '.'
23
  # Insert a newline after each '.' and add "Candidate <follow up number>:\n" before each item
24
+ updated_prediction = [
25
+ f"Candidate {i+1}:\n=============================\n{s}"
26
+ for i, s in enumerate(prediction)
27
+ ]
28
+ updated_prediction = [s.replace(". ", ".\n") for s in updated_prediction]
29
+ updated_prediction = [s.replace("•", "\n - ") for s in updated_prediction]
30
  return "\n\n".join(updated_prediction)
31
  return "No 'prediction' key found in the response or the 'body' is not a list."
32
 
33
+
34
+ examples = [
35
+ [
36
+ """
37
  DATA SCIENTIST - GENTIS
38
  ========================
39
  I am in contact with a top company in Ghent where they are looking for an additional Data Scientist. Beware... Once you start there, you won't be leaving anytime soon. The company likes to keep their employees happy, so few leave.
 
56
  A renovated office with everything you could dream of full with surprises and extras
57
 
58
  If you are interested or want more info, don't hesitate to contact me.
 
 
59
  """
60
+ ],
61
+ [
62
+ """
63
  Payroll, Benefits & Office Manager
64
  ================================
65
 
 
80
  An attractive salary package with company car, accompanied by various extra-legal benefits (meal vouchers, group insurance, hospitalization insurance, etc.)
81
  39 days off per year
82
  """
83
+ ],
84
  ]
85
 
 
86
 
87
+ css = """
88
+ .gradio-container {
89
+ font-family: 'IBM Plex Sans', sans-serif;
90
+ }
91
+ .gr-button {
92
+ color: white;
93
+ border-color: black;
94
+ background: black;
95
+ }
96
+ input[type='range'] {
97
+ accent-color: black;
98
+ }
99
+ .dark input[type='range'] {
100
+ accent-color: #dfdfdf;
101
+ }
102
+ .container {
103
+ max-width: 730px;
104
+ margin: auto;
105
+ padding-top: 1.5rem;
106
+ }
107
+ #gallery {
108
+ min-height: 22rem;
109
+ margin-bottom: 15px;
110
+ margin-left: auto;
111
+ margin-right: auto;
112
+ border-bottom-right-radius: .5rem !important;
113
+ border-bottom-left-radius: .5rem !important;
114
+ }
115
+ #gallery>div>.h-full {
116
+ min-height: 20rem;
117
+ }
118
+ .details:hover {
119
+ text-decoration: underline;
120
+ }
121
+ .gr-button {
122
+ white-space: nowrap;
123
+ }
124
+ .gr-button:focus {
125
+ border-color: rgb(147 197 253 / var(--tw-border-opacity));
126
+ outline: none;
127
+ box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
128
+ --tw-border-opacity: 1;
129
+ --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
130
+ --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
131
+ --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
132
+ --tw-ring-opacity: .5;
133
+ }
134
+ #advanced-btn {
135
+ font-size: .7rem !important;
136
+ line-height: 19px;
137
+ margin-top: 12px;
138
+ margin-bottom: 12px;
139
+ padding: 2px 8px;
140
+ border-radius: 14px !important;
141
+ }
142
+ #advanced-options {
143
+ display: none;
144
+ margin-bottom: 20px;
145
+ }
146
+ .footer {
147
+ margin-bottom: 45px;
148
+ margin-top: 35px;
149
+ text-align: center;
150
+ border-bottom: 1px solid #e5e5e5;
151
+ }
152
+ .footer>p {
153
+ font-size: .8rem;
154
+ display: inline-block;
155
+ padding: 0 10px;
156
+ transform: translateY(10px);
157
+ background: white;
158
+ }
159
+ .dark .footer {
160
+ border-color: #303030;
161
+ }
162
+ .dark .footer>p {
163
+ background: #0b0f19;
164
+ }
165
+ .acknowledgments h4{
166
+ margin: 1.25em 0 .25em 0;
167
+ font-weight: bold;
168
+ font-size: 115%;
169
+ }
170
+ .animate-spin {
171
+ animation: spin 1s linear infinite;
172
+ }
173
+ @keyframes spin {
174
+ from {
175
+ transform: rotate(0deg);
176
+ }
177
+ to {
178
+ transform: rotate(360deg);
179
+ }
180
+ }
181
+ #share-btn-container {
182
+ display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;
183
+ margin-top: 10px;
184
+ margin-left: auto;
185
+ }
186
+ #share-btn {
187
+ all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;right:0;
188
+ }
189
+ #share-btn * {
190
+ all: unset;
191
+ }
192
+ #share-btn-container div:nth-child(-n+2){
193
+ width: auto !important;
194
+ min-height: 0px !important;
195
+ }
196
+ #share-btn-container .wrap {
197
+ display: none !important;
198
+ }
199
+
200
+ .gr-form{
201
+ flex: 1 1 50%; border-top-right-radius: 0; border-bottom-right-radius: 0;
202
+ }
203
+ #prompt-container{
204
+ gap: 0;
205
+ }
206
+ #prompt-text-input, #negative-prompt-text-input{padding: .45rem 0.625rem}
207
+ #component-16{border-top-width: 1px!important;margin-top: 1em}
208
+ .image_duplication{position: absolute; width: 100px; left: 50px}
209
+ """
210
+
211
+ demo = gr.Blocks(css=css)
212
 
213
  with demo:
214
+ gr.HTML(
215
+ """
216
+ <div style="text-align: center; margin: 0 auto;">
217
+ <div
218
+ style="
219
+ display: inline-flex;
220
+ align-items: center;
221
+ gap: 0.8rem;
222
+ font-size: 1.75rem;
223
+ "
224
+ >
225
+
226
+ <h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">
227
+ Recruiter Assistent
228
+ </h1>
229
+ </div>
230
+ <p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">
231
+ <b>Helps recruiters to find relevant resumes in a database and write a relevant introduction email to the customer.
232
+ </br>We have more than 100 distinct resumes in our database for various type of roles (data scientist / hr / lawyer / ...)\n
233
+ </br>We got the resumes from <a style="text-decoration: underline;" href="https://huggingface.co/datasets/Sachinkelenjaguri/Resume_dataset">here</a>
234
+ </p>
235
+ </div>
236
+ """
237
+ )
238
+ gr.Markdown(
239
+ """
240
+
241
+ ## 1. Provide a vacancy and get back relevant resumes from an entire database of resumes for various roles.
242
+ """
243
+ )
244
+ text_vacancy = gr.Textbox(
245
+ hint="Paste here a Vacancy...", lines=7, label="Copy/paste here a vacancy"
246
+ )
247
  b1 = gr.Button("Search Resume")
248
+ text_search_result = gr.Textbox(
249
+ hint="Top resumes will appear here ...",
250
+ label="Top resumes found in the database",
251
+ )
252
  b1.click(search_resume, inputs=text_vacancy, outputs=text_search_result)
253
+ gr.Markdown(
254
+ """
255
+
256
+ ## 2. Select an appropriate resume for this vacancy, paste it in the textfield and get a relevant introduction email.
257
+ """
258
+ )
259
+ text_resume = gr.Textbox(
260
+ hint="Paste here a Resume...",
261
+ label="Copy / Paste here your prefered resume from above and click the button to write an intro ",
262
+ )
263
  b2 = gr.Button("Write a relevant intro")
264
+ gr.Markdown(
265
+ """
266
+
267
+ ## 3. You have a relevant introduction email to send to the customer.
268
+ """
269
+ )
270
  text_intro = gr.Textbox(label="Intro Email")
271
  evaluation = gr.Textbox(label="Evaluation of the skills")
272
+ b2.click(
273
+ recruiting_assistant.create_intro,
274
+ inputs=[text_vacancy, text_resume],
275
+ outputs=[text_intro, evaluation],
 
 
276
  )
277
 
278
  gr.Examples(
 
283
  cache_examples=False,
284
  )
285
 
286
+ demo.launch()
requirements.txt CHANGED
@@ -3,21 +3,21 @@ aiofiles==23.1.0 ; python_version >= '3.7' and python_version < '4.0'
3
  aiohttp==3.8.5 ; python_version >= '3.6'
4
  aiosignal==1.3.1 ; python_version >= '3.7'
5
  altair==5.0.1 ; python_version >= '3.7'
6
- annotated-types==0.5.0 ; python_version >= '3.7'
7
  anyio==3.7.1 ; python_version >= '3.7'
8
- async-timeout==4.0.2 ; python_version < '3.11'
9
  attrs==23.1.0 ; python_version >= '3.7'
10
- certifi==2023.5.7 ; python_version >= '3.6'
 
 
11
  charset-normalizer==3.2.0 ; python_full_version >= '3.7.0'
12
  click==8.1.6 ; python_version >= '3.7'
13
  contourpy==1.1.0 ; python_version >= '3.8'
14
  cycler==0.11.0 ; python_version >= '3.6'
15
  dataclasses-json==0.5.13 ; python_version < '3.12' and python_version >= '3.7'
16
- exceptiongroup==1.1.2 ; python_version < '3.11'
17
  fastapi==0.100.0 ; python_version >= '3.7'
18
  ffmpy==0.3.1
19
  filelock==3.12.2 ; python_version >= '3.7'
20
- fonttools==4.41.0 ; python_version >= '3.8'
21
  frozenlist==1.4.0 ; python_version >= '3.8'
22
  fsspec==2023.6.0 ; python_version >= '3.8'
23
  gradio==3.38.0
@@ -27,13 +27,13 @@ httpcore==0.17.3 ; python_version >= '3.7'
27
  httpx==0.24.1 ; python_version >= '3.7'
28
  huggingface-hub==0.16.4 ; python_full_version >= '3.7.0'
29
  idna==3.4 ; python_version >= '3.5'
30
- importlib-resources==6.0.0 ; python_version < '3.10'
31
  jinja2==3.1.2 ; python_version >= '3.7'
 
32
  jsonschema==4.18.4 ; python_version >= '3.8'
33
  jsonschema-specifications==2023.7.1 ; python_version >= '3.8'
34
  kiwisolver==1.4.4 ; python_version >= '3.7'
35
- langchain==0.0.238
36
- langsmith==0.0.12 ; python_version < '4.0' and python_full_version >= '3.8.1'
37
  linkify-it-py==2.0.2
38
  markdown-it-py[linkify]==2.2.0 ; python_version >= '3.7'
39
  markupsafe==2.1.3 ; python_version >= '3.7'
@@ -44,18 +44,15 @@ mdurl==0.1.2 ; python_version >= '3.7'
44
  multidict==6.0.4 ; python_version >= '3.7'
45
  mypy-extensions==1.0.0 ; python_version >= '3.5'
46
  numexpr==2.8.4 ; python_version >= '3.7'
47
- numpy==1.24.4 ; python_version >= '3.8'
48
  openai==0.27.8
49
  openapi-schema-pydantic==1.2.4 ; python_full_version >= '3.6.1'
50
  orjson==3.9.2 ; python_version >= '3.7'
51
  packaging==23.1 ; python_version >= '3.7'
52
  pandas==2.0.3 ; python_version >= '3.8'
53
  pillow==10.0.0 ; python_version >= '3.8'
54
- pkgutil-resolve-name==1.3.10 ; python_version < '3.9'
55
  pydantic==1.10.11 ; python_version >= '3.7'
56
- pydantic-core==2.3.0 ; python_version >= '3.7'
57
  pydub==0.25.1
58
- pygments==2.15.1 ; python_version >= '3.7'
59
  pyparsing==3.0.9 ; python_full_version >= '3.6.8'
60
  python-dateutil==2.8.2 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
61
  python-multipart==0.0.6 ; python_version >= '3.7'
@@ -64,6 +61,8 @@ pyyaml==6.0.1 ; python_version >= '3.6'
64
  referencing==0.30.0 ; python_version >= '3.8'
65
  requests==2.31.0
66
  rpds-py==0.9.2 ; python_version >= '3.8'
 
 
67
  semantic-version==2.10.0 ; python_version >= '2.7'
68
  six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
69
  sniffio==1.3.0 ; python_version >= '3.7'
@@ -76,8 +75,8 @@ typing-extensions==4.7.1 ; python_version >= '3.7'
76
  typing-inspect==0.9.0
77
  tzdata==2023.3 ; python_version >= '2'
78
  uc-micro-py==1.0.2 ; python_version >= '3.7'
79
- urllib3==2.0.4 ; python_version >= '3.7'
 
80
  uvicorn==0.23.1 ; python_version >= '3.8'
81
  websockets==11.0.3 ; python_version >= '3.7'
82
  yarl==1.9.2 ; python_version >= '3.7'
83
- zipp==3.16.2 ; python_version < '3.10'
 
3
  aiohttp==3.8.5 ; python_version >= '3.6'
4
  aiosignal==1.3.1 ; python_version >= '3.7'
5
  altair==5.0.1 ; python_version >= '3.7'
 
6
  anyio==3.7.1 ; python_version >= '3.7'
7
+ async-timeout==4.0.2 ; python_version >= '3.6'
8
  attrs==23.1.0 ; python_version >= '3.7'
9
+ boto3==1.28.10
10
+ botocore==1.31.10 ; python_version >= '3.7'
11
+ certifi==2023.7.22 ; python_version >= '3.6'
12
  charset-normalizer==3.2.0 ; python_full_version >= '3.7.0'
13
  click==8.1.6 ; python_version >= '3.7'
14
  contourpy==1.1.0 ; python_version >= '3.8'
15
  cycler==0.11.0 ; python_version >= '3.6'
16
  dataclasses-json==0.5.13 ; python_version < '3.12' and python_version >= '3.7'
 
17
  fastapi==0.100.0 ; python_version >= '3.7'
18
  ffmpy==0.3.1
19
  filelock==3.12.2 ; python_version >= '3.7'
20
+ fonttools==4.41.1 ; python_version >= '3.8'
21
  frozenlist==1.4.0 ; python_version >= '3.8'
22
  fsspec==2023.6.0 ; python_version >= '3.8'
23
  gradio==3.38.0
 
27
  httpx==0.24.1 ; python_version >= '3.7'
28
  huggingface-hub==0.16.4 ; python_full_version >= '3.7.0'
29
  idna==3.4 ; python_version >= '3.5'
 
30
  jinja2==3.1.2 ; python_version >= '3.7'
31
+ jmespath==1.0.1 ; python_version >= '3.7'
32
  jsonschema==4.18.4 ; python_version >= '3.8'
33
  jsonschema-specifications==2023.7.1 ; python_version >= '3.8'
34
  kiwisolver==1.4.4 ; python_version >= '3.7'
35
+ langchain==0.0.240
36
+ langsmith==0.0.14 ; python_version < '4.0' and python_full_version >= '3.8.1'
37
  linkify-it-py==2.0.2
38
  markdown-it-py[linkify]==2.2.0 ; python_version >= '3.7'
39
  markupsafe==2.1.3 ; python_version >= '3.7'
 
44
  multidict==6.0.4 ; python_version >= '3.7'
45
  mypy-extensions==1.0.0 ; python_version >= '3.5'
46
  numexpr==2.8.4 ; python_version >= '3.7'
47
+ numpy==1.25.1 ; python_version >= '3.9'
48
  openai==0.27.8
49
  openapi-schema-pydantic==1.2.4 ; python_full_version >= '3.6.1'
50
  orjson==3.9.2 ; python_version >= '3.7'
51
  packaging==23.1 ; python_version >= '3.7'
52
  pandas==2.0.3 ; python_version >= '3.8'
53
  pillow==10.0.0 ; python_version >= '3.8'
 
54
  pydantic==1.10.11 ; python_version >= '3.7'
 
55
  pydub==0.25.1
 
56
  pyparsing==3.0.9 ; python_full_version >= '3.6.8'
57
  python-dateutil==2.8.2 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
58
  python-multipart==0.0.6 ; python_version >= '3.7'
 
61
  referencing==0.30.0 ; python_version >= '3.8'
62
  requests==2.31.0
63
  rpds-py==0.9.2 ; python_version >= '3.8'
64
+ s3fs==0.4.2
65
+ s3transfer==0.6.1 ; python_version >= '3.7'
66
  semantic-version==2.10.0 ; python_version >= '2.7'
67
  six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
68
  sniffio==1.3.0 ; python_version >= '3.7'
 
75
  typing-inspect==0.9.0
76
  tzdata==2023.3 ; python_version >= '2'
77
  uc-micro-py==1.0.2 ; python_version >= '3.7'
78
+ urllib3==1.26.16 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
79
+ utils==1.0.1
80
  uvicorn==0.23.1 ; python_version >= '3.8'
81
  websockets==11.0.3 ; python_version >= '3.7'
82
  yarl==1.9.2 ; python_version >= '3.7'