Spaces:
Sleeping
Sleeping
etadevosyan
commited on
Commit
•
18ed8b2
1
Parent(s):
22356a6
logging not flagged data
Browse files- __pycache__/search.cpython-311.pyc +0 -0
- app.py +14 -8
__pycache__/search.cpython-311.pyc
ADDED
Binary file (6.98 kB). View file
|
|
app.py
CHANGED
@@ -1,9 +1,11 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from dotenv import load_dotenv
|
3 |
from search import search_bm25, search_exact, prepare_data, merge_results
|
4 |
import os
|
5 |
import json
|
6 |
import datetime
|
|
|
7 |
|
8 |
load_dotenv()
|
9 |
|
@@ -12,8 +14,11 @@ data = prepare_data()
|
|
12 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
13 |
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "budu_search_data_new")
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
def search_handler(query: str):
|
18 |
results, exact_results = (
|
19 |
search_bm25(query, data),
|
@@ -28,14 +33,15 @@ def create_ui(query):
|
|
28 |
results = search_handler(query)
|
29 |
for result in results['results'][:5]:
|
30 |
recommendations.append(f"<div style='padding: 10px; border-bottom: 1px solid #ddd;'>{result['name']}</div>")
|
31 |
-
log_non_flagged_queries(query)
|
32 |
return gr.HTML(f"<div style='max-height: 400px; overflow-y: auto;'>{''.join(recommendations)}</div>")
|
33 |
|
34 |
-
def log_non_flagged_queries(query):
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
iface = gr.Interface(
|
41 |
fn=create_ui,
|
|
|
1 |
+
#%%
|
2 |
import gradio as gr
|
3 |
from dotenv import load_dotenv
|
4 |
from search import search_bm25, search_exact, prepare_data, merge_results
|
5 |
import os
|
6 |
import json
|
7 |
import datetime
|
8 |
+
from datasets import load_dataset, Dataset
|
9 |
|
10 |
load_dotenv()
|
11 |
|
|
|
14 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
15 |
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "budu_search_data_new")
|
16 |
|
17 |
+
new = Dataset.from_dict({'Введите запрос':[],
|
18 |
+
'output':[]})
|
19 |
+
new.push_to_hub("etadevosyan/not_flagged_data",
|
20 |
+
token=HF_TOKEN)
|
21 |
+
|
22 |
def search_handler(query: str):
|
23 |
results, exact_results = (
|
24 |
search_bm25(query, data),
|
|
|
33 |
results = search_handler(query)
|
34 |
for result in results['results'][:5]:
|
35 |
recommendations.append(f"<div style='padding: 10px; border-bottom: 1px solid #ddd;'>{result['name']}</div>")
|
36 |
+
log_non_flagged_queries(query,recommendations)
|
37 |
return gr.HTML(f"<div style='max-height: 400px; overflow-y: auto;'>{''.join(recommendations)}</div>")
|
38 |
|
39 |
+
def log_non_flagged_queries(query,recommendations):
|
40 |
+
dataset = load_dataset('etadevosyan/not_flagged_data')
|
41 |
+
dataset.add_item({'Введите запрос':query,
|
42 |
+
'output':recommendations})
|
43 |
+
dataset.push_to_hub("etadevosyan/not_flagged_data",
|
44 |
+
token=HF_TOKEN)
|
45 |
|
46 |
iface = gr.Interface(
|
47 |
fn=create_ui,
|