File size: 1,083 Bytes
71d962d
e96fcdf
71d962d
 
737f413
285167f
9844b78
285167f
e9d1176
 
 
 
285167f
22f5a4b
 
eb3051f
737f413
 
 
b166b64
c5a14aa
737f413
 
 
c5a14aa
737f413
eb3051f
737f413
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
import os
import random
import time
import gradio as gr
from document_chatbot import DocumentChatbot

document_chatbot = DocumentChatbot()



#os.environ["HUGGINGFACEHUB_API_TOKEN"] = "xxxxxxxxxxxxxxx" (uncomment this line and paste your own hf token to run the models)

with gr.Blocks() as demo:
    title = """<p><h1 align="center" style="font-size: 36px;">Talk with your document</h1></p>"""
    gr.HTML(title)
    with gr.Row():
        text_input = gr.Textbox(label="Enter text or URL to text file")
        with gr.Column():
            with gr.Row():
                picked_model = gr.Dropdown(["google/flan-t5-base","google/flan-t5-small"], label="Models", interactive=True)  #"google/flan-t5-large", 
            
            chatbot = gr.Chatbot()
            q_input = gr.Textbox(label="Please write your question")
            clear = gr.Button("Clear")
            q_input.submit(document_chatbot.respond, [text_input, q_input, chatbot, picked_model], [q_input, chatbot])
            clear.click(lambda: None, None, chatbot, queue=False)
        
demo.launch(debug=True)