Spaces:
Sleeping
Sleeping
File size: 2,178 Bytes
8677815 37f4888 8832a9e 8677815 8832a9e a88b2e6 8677815 |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# Application file for Gradio App
import gradio as gr
import time
from hay.pipeline import rs_pipeline
# d='data'
d='data2'
title = """<h1 align="center">Chat Literature</h1>"""
description = """<br><br><h3 align="center">This is a literature chat model, which can currently answer questions to regulation/two-sided markets topic in Supply chain mangement.</h3>"""
def user(user_message, history):
return "", history + [[user_message, None]]
def respond(message, chat_history):
question = str(message)
answer = rs_pipeline(question, d)
bot_message = answer
chat_history.append((message, bot_message))
time.sleep(2)
return " ", chat_history
with gr.Blocks(theme=gr.themes.Soft(primary_hue="emerald", neutral_hue="slate")) as chat:
gr.HTML(title)
chatbot = gr.Chatbot().style(height=750)
msg = gr.Textbox(label="Send a message", placeholder="Send a message",
show_label=False).style(container=False)
# with gr.Row():
# with gr.Column():
# msg = gr.Textbox(label="Send a message", placeholder="Send a message",
# show_label=False).style(container=False)
# with gr.Column():
# with gr.Row():
# submit = gr.Button("Submit")
# stop = gr.Button("Stop")
# clear = gr.Button("Clear")
msg.submit(respond, [msg, chatbot], [msg, chatbot])
if d=='data':
gr.Examples([
["How to reduce carbon emissions?"],
["What are the main topics in these papers?"],
["What are the major math models in PI."]
], inputs=msg, label= "Click on any example to copy in the chatbox"
)
else:
gr.Examples([
["Who are the main users (participants) in the two-sided market?"],
["What are the decisions made in the two-sided market? And who makes this decision?"],
["What are the main effects in the two-sided market"]
], inputs=msg, label= "Click on any example to copy in the chatbox"
)
gr.HTML(description)
def application():
return None
chat.queue()
chat.launch()
|