File size: 817 Bytes
d938037
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)