import gradio as gr
import os
def get_markdown(registry):
with open(registry,"r") as f:
return f.read()
def get_interface(md):
code = "import" + md.split("import")[2].split(".launch")[0]
return code
# need to match the filenames in the regesteries folder
possible_registries = ["gemini-gradio"]
with gr.Blocks() as demo :
gr.Markdown("
Gradio registry
")
dropdown = gr.Dropdown(possible_registries,value=possible_registries[0],interactive=True)
@gr.render(inputs=dropdown)
def create_interface(registry):
filepath = f"registries/{registry}.md"
md = get_markdown(filepath)
gr.Markdown(md)
try :
code = get_interface(md)
exec(code)
except Exception as e :
message = f"could not render the interface because of the following error : {e} "
gr.Info(message)
demo.launch()