Spaces:
Running
Running
update
Browse files- app.py +20 -14
- settings.py +2 -2
app.py
CHANGED
@@ -4,9 +4,6 @@ import docx2txt
|
|
4 |
from typing import Optional, List, Dict
|
5 |
import re
|
6 |
from pinecone_handler import PineconeHandler
|
7 |
-
from datetime import datetime
|
8 |
-
import sqlite3
|
9 |
-
import threading
|
10 |
import hopsworks
|
11 |
import pandas as pd
|
12 |
import os
|
@@ -166,10 +163,21 @@ def create_interface():
|
|
166 |
def update_job_displays(file, num_results, city):
|
167 |
results = matcher.search_jobs(file, num_results, city)
|
168 |
|
|
|
|
|
|
|
169 |
if "error" in results[0]:
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
-
|
173 |
for i in range(20):
|
174 |
if i < len(results):
|
175 |
job = results[i]
|
@@ -198,22 +206,22 @@ def create_interface():
|
|
198 |
"" # Reset feedback status
|
199 |
])
|
200 |
else:
|
|
|
201 |
updates.extend([
|
202 |
-
gr.update(visible=False),
|
203 |
-
"",
|
204 |
-
""
|
205 |
])
|
206 |
|
|
|
207 |
updates.append("Jobs found! Rate them as relevant or not relevant.")
|
|
|
208 |
return updates
|
209 |
|
210 |
def handle_feedback(container_index: int, is_relevant: bool):
|
211 |
pinecone_id = job_containers[container_index]['pinecone_id']
|
212 |
if pinecone_id:
|
213 |
response = matcher.submit_feedback(pinecone_id, is_relevant)
|
214 |
-
# Convert the response to a string if it's a dictionary
|
215 |
-
if isinstance(response, dict):
|
216 |
-
return str(response)
|
217 |
return response
|
218 |
return "Error: Job ID not found"
|
219 |
|
@@ -243,12 +251,10 @@ def create_interface():
|
|
243 |
not_relevant_btn = container_obj.children[1].children[1]
|
244 |
|
245 |
relevant_btn.click(
|
246 |
-
inputs=[],
|
247 |
fn=lambda idx=i: handle_feedback(idx, True),
|
248 |
outputs=[feedback_status]
|
249 |
)
|
250 |
not_relevant_btn.click(
|
251 |
-
inputs=[],
|
252 |
fn=lambda idx=i: handle_feedback(idx, False),
|
253 |
outputs=[feedback_status]
|
254 |
)
|
@@ -257,4 +263,4 @@ def create_interface():
|
|
257 |
|
258 |
if __name__ == "__main__":
|
259 |
interface = create_interface()
|
260 |
-
interface.launch()
|
|
|
4 |
from typing import Optional, List, Dict
|
5 |
import re
|
6 |
from pinecone_handler import PineconeHandler
|
|
|
|
|
|
|
7 |
import hopsworks
|
8 |
import pandas as pd
|
9 |
import os
|
|
|
163 |
def update_job_displays(file, num_results, city):
|
164 |
results = matcher.search_jobs(file, num_results, city)
|
165 |
|
166 |
+
# Initialize updates list with default values for all containers
|
167 |
+
updates = []
|
168 |
+
|
169 |
if "error" in results[0]:
|
170 |
+
# If there's an error, hide all containers and show error message
|
171 |
+
for _ in range(20):
|
172 |
+
updates.extend([
|
173 |
+
gr.update(visible=False), # Container visibility
|
174 |
+
"", # Job content
|
175 |
+
"" # Feedback status
|
176 |
+
])
|
177 |
+
updates.append(results[0]["error"]) # Status message
|
178 |
+
return updates
|
179 |
|
180 |
+
# Process results and generate updates
|
181 |
for i in range(20):
|
182 |
if i < len(results):
|
183 |
job = results[i]
|
|
|
206 |
"" # Reset feedback status
|
207 |
])
|
208 |
else:
|
209 |
+
# For unused containers, hide them and clear content
|
210 |
updates.extend([
|
211 |
+
gr.update(visible=False), # Container visibility
|
212 |
+
"", # Job content
|
213 |
+
"" # Reset feedback status
|
214 |
])
|
215 |
|
216 |
+
# Add final status message
|
217 |
updates.append("Jobs found! Rate them as relevant or not relevant.")
|
218 |
+
|
219 |
return updates
|
220 |
|
221 |
def handle_feedback(container_index: int, is_relevant: bool):
|
222 |
pinecone_id = job_containers[container_index]['pinecone_id']
|
223 |
if pinecone_id:
|
224 |
response = matcher.submit_feedback(pinecone_id, is_relevant)
|
|
|
|
|
|
|
225 |
return response
|
226 |
return "Error: Job ID not found"
|
227 |
|
|
|
251 |
not_relevant_btn = container_obj.children[1].children[1]
|
252 |
|
253 |
relevant_btn.click(
|
|
|
254 |
fn=lambda idx=i: handle_feedback(idx, True),
|
255 |
outputs=[feedback_status]
|
256 |
)
|
257 |
not_relevant_btn.click(
|
|
|
258 |
fn=lambda idx=i: handle_feedback(idx, False),
|
259 |
outputs=[feedback_status]
|
260 |
)
|
|
|
263 |
|
264 |
if __name__ == "__main__":
|
265 |
interface = create_interface()
|
266 |
+
interface.launch(debug=True)
|
settings.py
CHANGED
@@ -2,8 +2,8 @@ import logging
|
|
2 |
|
3 |
PINECONE_ENVIRONMENT = "gcp-starter"
|
4 |
#PINECONE_INDEX_NAME = "jobads-index"
|
5 |
-
|
6 |
-
PINECONE_INDEX_NAME = "jobads-finetuned-small"
|
7 |
|
8 |
DB_TABLE_NAME = 'jobads'
|
9 |
DB_FILE_NAME = 'jobads_database_20220127.db'
|
|
|
2 |
|
3 |
PINECONE_ENVIRONMENT = "gcp-starter"
|
4 |
#PINECONE_INDEX_NAME = "jobads-index"
|
5 |
+
PINECONE_INDEX_NAME = "jobsai-multilingual-small"
|
6 |
+
#PINECONE_INDEX_NAME = "jobads-finetuned-small"
|
7 |
|
8 |
DB_TABLE_NAME = 'jobads'
|
9 |
DB_FILE_NAME = 'jobads_database_20220127.db'
|