-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
28 lines (21 loc) · 1.06 KB
/
app.py
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-large", "google/flan-t5-base","google/flan-t5-small"], label="Models", interactive=True)
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)