File size: 740 Bytes
8ed590c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import paddlenlp
import gradio as gr

from paddlenlp import Taskflow
from paddlenlp.taskflow.text_similarity import TextSimilarityTask

def get_response():
    similarity = Taskflow("text_similarity")
    # query = "有哪些功能"
    # support_set = ["你有哪些功能呢?", "你能做什么?", "你能帮我们做什么?"]
    
    query = "春天适合种什么花?"
    support_set = ["春天适合种什么菜?"]
    
    inputs = []
    for support_item in support_set:
        inputs.append(
            [query, support_item]
        )
    
    result = similarity(inputs)

def greet(name):
    result = get_response()
    return str(result)

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()