#%% import gradio as gr from dotenv import load_dotenv from search import search_bm25, search_exact, prepare_data, merge_results import os import json import datetime from datasets import load_dataset, Dataset load_dotenv() data = prepare_data() HF_TOKEN = os.getenv('HF_TOKEN') hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "budu_search_data_new") #%% def search_handler(query: str): results, exact_results = ( search_bm25(query, data), search_exact(query, data) ) json_results = merge_results(exact_results, results) return {'results': json_results} def create_ui(query): recommendations = [] results = search_handler(query) for result in results['results'][:5]: recommendations.append(f"