import gradio as gr from transformers import pipeline model_pipeline = pipeline("text2text-generation", model="tribler/dsi-search-on-toy-dataset") def process_query(query): results = model_pipeline(query, max_length=60) result_text = results[0]['generated_text'].strip() if result_text.startswith("http"): youtube_id = result_text.split('watch?v=')[-1] iframe = f'' return gr.HTML(iframe) elif result_text.startswith("magnet"): return gr.HTML(f'{result_text}') else: bitcoin_logo_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Bitcoin.svg/800px-Bitcoin.svg.png" return gr.Textbox(f'
Bitcoin Logo{result_text}
') interface = gr.Interface(fn=process_query, inputs=gr.Textbox(label="Query"), outputs="html", title="Search Interface", submit_btn="Find", description=""" ### Search for movie trailers, music torrents, and bitcoin wallet addresses! This toy example knows about 500 URLs exactly after merely a few hours of training on a single GPU ([view dataset](https://huggingface.co/tribler/dsi-search-on-toy-dataset/blob/main/dataset.csv)). """, article=""" This project represents both a groundbreaking advance and a preliminary exploration into decentralized systems. As a preliminary model, the project showcases a toy example rather than the full potential of its ultimate capabilities. It serves as a proof of concept that invites further development and imagination. """, examples=[["spider man"], ["oceans 13"], ["sister starlight"], ["bitcoin address of xileno"]], concurrency_limit=50) if __name__ == "__main__": interface.launch()