Spaces:
Runtime error
Runtime error
File size: 1,205 Bytes
0657cdd 1a6cb02 0657cdd 6a7d122 1a6cb02 0657cdd 1f16563 28ace0b 4492eec 1f16563 0657cdd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from dataset_recommender import DatasetRecommender
db_lookup = DatasetRecommender()
def predict(input_text, option):
if option == "Semantic search":
response = db_lookup.recommend_based_on_text(input_text)
output = f"Message: {response['message']} \n \n Datasets: {' , '.join([x for x in response['datasets']])}"
elif option == 'Dataset similarity':
response = db_lookup.get_similar_datasets(input_text)
if 'error' in response:
output = response['error']
else:
output = f"Similar Datasets: {' , '.join([x for x in response['datasets']])}"
else:
output = "Please select an option"
return output
input_type = gr.inputs.Textbox(label="Input Text")
checkbox = gr.inputs.Radio(["Semantic search", "Dataset similarity"], label="Please select search type:")
example1 = ["Natural disasters", "Semantic search"]
example2 = ["https://huggingface.co/datasets/turkic_xwmt", "Dataset similarity"]
examples = [example1, example2]
title = "SearchingFace: Search for datasets!"
iface = gr.Interface(fn=predict, inputs=[input_type, checkbox], examples=examples, title=title, outputs="text")
iface.launch()
|