|
import gradio as gr |
|
import json |
|
from pathlib import Path |
|
|
|
fileid2json = json.loads(Path("fileid2json.json").read_text()) |
|
|
|
autov22fileid = json.loads(Path("autov22fileid.json").read_text()) |
|
filename2fileid = json.loads(Path("filename2fileid.json").read_text()) |
|
name2fileid = json.loads(Path("name2fileid.json").read_text()) |
|
|
|
|
|
def greet(query): |
|
result = "Not found" |
|
fileid = query |
|
|
|
if query in autov22fileid: |
|
fileid = str(autov22fileid[query]) |
|
if query in filename2fileid: |
|
fileid = str(filename2fileid[query]) |
|
if query in name2fileid: |
|
fileid = str(name2fileid[query]) |
|
|
|
if fileid in fileid2json: |
|
result = json.dumps(fileid2json[query.strip()]) |
|
return result |
|
|
|
iface = gr.Interface(fn=greet, inputs="text", outputs="text") |
|
iface.launch() |
|
|