Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import utils | |
| def main(data: str = None, file: gr.File = None) -> dict: | |
| try: | |
| if isinstance(data, str) and not isinstance(file, gr.File): | |
| report = utils.analyze_tags(data) | |
| else: | |
| with open(file.name, 'r') as f: | |
| data = f.read() | |
| report = utils.analyze_tags(data) | |
| # analysis_report = utils.generate_report(report) | |
| # final_result = pretty_print(analysis_report) | |
| return report | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| inputs = [ | |
| gr.Textbox(label="Text Data", placeholder="Enter or paste text data here", lines=4), | |
| # gr.File(label="Upload File") | |
| ] | |
| output = gr.Textbox(label="Formatted Report") | |
| iface = gr.Interface(fn=main, inputs=inputs, outputs=output, live=True) | |
| iface.launch() | |