import gradio as gr from utils import ChemicalConverter, validate_smiles2iupac, plot_mol, login def convert(access_code, chemical_name, plot): if not login(access_code): return "Currently, you don't have access to the service." # Initialize the ChemicalConverter converter = ChemicalConverter(mode="IUPAC2SMILES") converted_name = converter.convert(chemical_name)[:6] styles = {"": "SYSTEMATIC", "": "TRADITIONAL", "": "BASE"} return styles.get(converted_name, "") iupac2style = gr.Interface( fn=convert, allow_flagging='auto', inputs=[ gr.Textbox(label="Enter your access code", placeholder=""), gr.Textbox(label="Enter your IUPAC name", placeholder="Enter IUPAC name here"), ], outputs=[gr.Text(label="IUPAC style")], examples=[ ["", "propan-2-yl 2-[4-(4-chlorophenyl)carbonylphenoxy]-2-methyl-propanoate"] ], )