import gradio as gr import algo algo_rule = algo.AlgoRule() algo_ai = algo.AlgoAI() def process(query): r1 = algo_rule.algo(query) r1 = sorted(r1) text_r1 = '' for item in r1: text_r1 += '\n'+'- '+item r2 = algo_ai.algo(query) text_r2 = '' for item in r2: text_r2 += '\n'+'- '+item output = f''' 绿产目录匹配结果 - 关键词规则: {text_r1} 绿产目录匹配结果 - AI匹配: {text_r2} ''' return output # We instantiate the Textbox class textbox_input = gr.Textbox(label="输入", placeholder="", lines=2) textbox_output = gr.Textbox(label="绿产目录匹配", placeholder="", lines=15) demo = gr.Interface(fn=process, inputs=textbox_input, outputs=textbox_output) demo.launch(share=False, server_name='0.0.0.0', server_port=8001)