Spaces:
Running
Running
Karthikeyan
commited on
Commit
•
5c44b2c
1
Parent(s):
4ea05d0
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ import tempfile
|
|
14 |
import gradio as gr
|
15 |
import openai
|
16 |
|
|
|
17 |
def get_empty_state():
|
18 |
return {"knowledge_base": None}
|
19 |
|
@@ -80,33 +81,51 @@ def answer_question(question, state):
|
|
80 |
return response
|
81 |
except:
|
82 |
return "Please upload Proper Document"
|
83 |
-
|
84 |
-
|
85 |
-
</p>"""
|
86 |
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
|
87 |
state = gr.State(get_empty_state())
|
|
|
|
|
88 |
with gr.Column(elem_id="col-container"):
|
89 |
-
gr.HTML(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
gr.Markdown("**Upload your file**")
|
91 |
with gr.Row(elem_id="row-flex"):
|
92 |
-
with gr.Column(scale=0.85):
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
102 |
with gr.Row():
|
103 |
-
|
104 |
-
|
105 |
with gr.Row():
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
109 |
upload_button.upload(upload_file, upload_button, [file_output,state])
|
110 |
user_question.submit(answer_question, [user_question, state], [answer])
|
111 |
|
112 |
-
demo.launch()
|
|
|
14 |
import gradio as gr
|
15 |
import openai
|
16 |
|
17 |
+
|
18 |
def get_empty_state():
|
19 |
return {"knowledge_base": None}
|
20 |
|
|
|
81 |
return response
|
82 |
except:
|
83 |
return "Please upload Proper Document"
|
84 |
+
|
85 |
+
|
|
|
86 |
with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
|
87 |
state = gr.State(get_empty_state())
|
88 |
+
gr.HTML("""<img class="leftimage" align="left" src="https://lh4.googleusercontent.com/wby8w9nmEC8w03w4H3m8_glMEyp5GBUsMX6osOFRi7NiiogfHKTw0PHhKsdJUBj2N246g5kExR2qfkyLGsVbgVEX6x9SMqsRxP6g89R0cjrgbwcbu7Iyp0-8qRJdNT3I2g=w1280" alt="Image" width="210" height="210">
|
89 |
+
<img class="rightimage" align="right" src="https://www.dmgflooringltd.co.uk/wp-content/uploads/NHS.png" alt="Image" width="210" height="210">""")
|
90 |
with gr.Column(elem_id="col-container"):
|
91 |
+
gr.HTML(
|
92 |
+
"""<hr style="border-top: 5px solid white;">"""
|
93 |
+
)
|
94 |
+
gr.HTML(
|
95 |
+
"""<br>
|
96 |
+
<h1 style="text-align:center;">
|
97 |
+
NHS Document QA
|
98 |
+
</h1> """
|
99 |
+
)
|
100 |
+
gr.HTML(
|
101 |
+
"""<hr style="border-top: 5px solid white;">"""
|
102 |
+
)
|
103 |
+
|
104 |
gr.Markdown("**Upload your file**")
|
105 |
with gr.Row(elem_id="row-flex"):
|
106 |
+
# with gr.Column(scale=0.85):
|
107 |
+
# file_url = gr.Textbox(
|
108 |
+
# value="",
|
109 |
+
# label="Upload your file",
|
110 |
+
# placeholder="Enter a url",
|
111 |
+
# show_label=False,
|
112 |
+
# visible=False
|
113 |
+
# )
|
114 |
+
with gr.Column(scale=0.90, min_width=160):
|
115 |
+
file_output = gr.File(elem_classes="filenameshow")
|
116 |
+
with gr.Column(scale=0.10, min_width=160):
|
117 |
+
upload_button = gr.UploadButton(
|
118 |
+
"Browse File", file_types=[".txt", ".pdf", ".doc", ".docx"],
|
119 |
+
elem_classes="filenameshow")
|
120 |
with gr.Row():
|
121 |
+
with gr.Column(scale=1, min_width=0):
|
122 |
+
user_question = gr.Textbox(value="",label='Question Box :',show_label=True, placeholder="Ask a question about your file:",elem_classes="spaceH")
|
123 |
with gr.Row():
|
124 |
+
with gr.Column(scale=1, min_width=0):
|
125 |
+
answer = gr.Textbox(value="",label='Answer Box :',show_label=True, placeholder="",lines=5)
|
126 |
+
|
127 |
+
#file_url.submit(upload_via_url, file_url, [file_output, state])
|
128 |
upload_button.upload(upload_file, upload_button, [file_output,state])
|
129 |
user_question.submit(answer_question, [user_question, state], [answer])
|
130 |
|
131 |
+
demo.queue().launch()
|