import json import gradio as gr import pandas as pd def read_json(file_name): with open(file_name, "r") as f: json_data = json.load(f) return json_data data = {"project_name": [], "description": []} json_file = "awesome-ChatGPT-repositories.json" json_data = read_json(json_file) for v in json_data["contents"].values(): for url, repo in v.items(): description = repo["multilingual_descriptions"]["en"] project_name = repo["repository_name"] data["project_name"].append(f"[{project_name}]({url})") data["description"].append(description) data = pd.DataFrame(data) def show_search_results(queries): queries = queries.lower() queries = queries.split() df_search = data for query in queries: contained_description = data["description"].str.contains(query) contained_project_name = data["project_name"].str.contains(query) df_search = df_search[contained_description | contained_project_name] return df_search with gr.Blocks() as demo: gr.Markdown( """ # Awesome ChatGPT repositories search 🔎 You can search for open-source software from [1500+ repositories](https://github.com/taishi-i/awesome-ChatGPT-repositories). """ ) query = gr.Textbox(label="Search words", placeholder="prompt") df = gr.DataFrame( value=data, type="pandas", datatype="markdown", height=1000 ) query.change(fn=show_search_results, inputs=query, outputs=df) demo.launch()