Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,46 +1,31 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
def
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
print
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
return html, chat_history
|
33 |
-
import gradio as grad
|
34 |
-
css = """
|
35 |
-
.mychat {display:flex;flex-direction:column}
|
36 |
-
.mesg {padding:5px;margin-bottom:5px;border-radius:5px;width:75%}
|
37 |
-
.mesg.user {background-color:lightblue;color:white}
|
38 |
-
.mesg.alicia {background-color:orange;color:white,align-self:self-end}
|
39 |
-
.footer {display:none !important}
|
40 |
-
"""
|
41 |
-
text=grad.inputs.Textbox(placeholder="Lets chat")
|
42 |
-
grad.Interface(fn=converse,
|
43 |
-
theme="default",
|
44 |
-
inputs=[text, "state"],
|
45 |
-
outputs=["html", "state"],
|
46 |
-
css=css).launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import 期刊论文投稿推荐系统
|
3 |
+
textbox_keyword_inputs = gr.inputs.Textbox(lines=6, placeholder='关键词', default='', label=None, optional=False)
|
4 |
+
textbox_abstract = gr.inputs.Textbox(lines=1, placeholder='请输入文章摘要', default='', label='摘要', optional=False)
|
5 |
+
|
6 |
+
|
7 |
+
def greet(textbox_keyword_inputs, history=[]):
|
8 |
+
outputs = 期刊论文投稿推荐系统.extract_tags(textbox_keyword_inputs)
|
9 |
+
label = outputs[0]
|
10 |
+
values_1 = outputs[1]
|
11 |
+
history.append(textbox_keyword_inputs)
|
12 |
+
print([(f"{history[len(history)-1]}", f"{label[0]}")])
|
13 |
+
print('----------------------------------')
|
14 |
+
print(textbox_keyword_inputs)
|
15 |
+
# return [(f"{history[0]}",f"{gr.HTML('根据您的论文所推荐的期刊.html')}")], history
|
16 |
+
return [(f"{history[len(history)-1][:50]+'.....'}", f"{label[0]+'综合影响因子:'+str(values_1[0])}")], history
|
17 |
+
|
18 |
+
|
19 |
+
with gr.Blocks() as Interface:
|
20 |
+
# 实例化一个机器人聊天组件
|
21 |
+
chatbot = gr.Chatbot()
|
22 |
+
# 状态码
|
23 |
+
state = gr.State([])
|
24 |
+
# 水平居中排列
|
25 |
+
with gr.Row():
|
26 |
+
# 实例化输入文本框
|
27 |
+
txt = gr.Textbox(show_label=False, placeholder="请输入文章摘要").style(container=False)
|
28 |
+
# 提交文本框后执行分析并输出
|
29 |
+
txt.submit(greet, [txt, state], [chatbot, state])
|
30 |
+
if __name__ == "__main__":
|
31 |
+
Interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|