File size: 823 Bytes
f40f6ca
208ce78
c717303
 
 
 
 
 
 
e81731d
7cc3b21
e81731d
7409ee4
7cc3b21
 
e81731d
 
 
 
fc40709
e81731d
7cc3b21
fc40709
7d25ed6
f62a3fd
e81731d
f62a3fd
 
7cc3b21
e81731d
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
import gradio as gr
from rag import respond_rag_huggingface as response_hf
import shutil

try:
    shutil.rmtree("/home/user/.cache/huggingface")
    shutil.rmtree("/home/user/.huggingface")
except Exception as e:
    print("Error clearing cache:", e)

chat_history = []

def respond(message):
    global chat_history
    response = response_hf(message)
    chat_history.append((message, response))
    return "", chat_history

with gr.Blocks() as demo:
    gr.Markdown("# Game of Thrones,harry potter Q&A bot")

    chatbot = gr.Chatbot(label="Chat History")
    msg = gr.Textbox(label="Write something about Game of Thrones or harry potter here...")

    submit = gr.Button("Submit")

    submit.click(respond, inputs=[msg], outputs=[msg, chatbot])
    #clear.click(lambda: ([], ""), None, [chatbot, msg])

demo.launch()