text_similarity / app.py
wjmcat's picture
Create new file
8ed590c
raw
history blame contribute delete
740 Bytes
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()