Chat_bot_OU / app.py
ShynBui's picture
Update app.py
2ff30a9 verified
raw
history blame contribute delete
743 Bytes
from gradio_client import Client
import gradio as gr
import random
import time
import os
client = Client("ShynBui/Vector_db_v3")
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.ClearButton([msg, chatbot])
def respond(message, chat_history):
if len(chat_history) == 0:
chat_history.append(("", ""))
result = client.predict(
quote= message,
history= [chat_history[-1]],
api_name="/predict"
)
bot_message = result[1]
chat_history.append((result[0], bot_message))
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
if __name__ == "__main__":
demo.launch(debug=True)