File size: 1,164 Bytes
736e7a3
97531f4
 
6ca347a
736e7a3
 
97531f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736e7a3
97531f4
 
 
736e7a3
97531f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import gradio as gr
from src.brain import generate_answers
processing = False


def response(query, history):
    global processing
    processing = True
    output = generate_answers(query)
    history.append((query, output))
    processing = False
    return "", history


with open("src/style.css", "r") as file:
    css = file.read()

with open("src/content.html", "r") as file:
    html_content = file.read()
    parts = html_content.split("<!-- split here -->")
    title_html = parts[0]
    bts_html = parts[1] if len(parts) > 1 else ""


def loading():
    return "Loading ..."


with gr.Blocks(css=css) as app:
    with gr.Column(elem_id="column_container"):
        gr.HTML(title_html)
        chatbot = gr.Chatbot([], elem_id="chatbot")
        with gr.Column():
            send = gr.Label(value="Write your QUESTION bellow and hit ENTER")
        query = gr.Textbox(
            label="Type your questions here:",
            placeholder="What do you want to know?",
        )
        clear = gr.ClearButton([query, chatbot])
        gr.HTML(bts_html)
    query.submit(response, [query, chatbot], [query, chatbot], queue=True)

app.launch()