Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -91,32 +91,34 @@ with st.container():
|
|
91 |
.image-container { height: 680px; }
|
92 |
</style>
|
93 |
""")
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
submit_btn.
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
).success(
|
118 |
-
|
119 |
-
)
|
|
|
|
|
120 |
|
121 |
if __name__ == "__main__":
|
122 |
gr.Interface(
|
|
|
91 |
.image-container { height: 680px; }
|
92 |
</style>
|
93 |
""")
|
94 |
+
|
95 |
+
with gr.Blocks() as demo: # Introduce a Blocks context
|
96 |
+
with gr.Row():
|
97 |
+
enable_box = gr.Textbox(placeholder='Enter OpenAI API key',
|
98 |
+
show_label=False, interactive=True)
|
99 |
+
disable_box = gr.Textbox(value='OpenAI API key is Set', interactive=False)
|
100 |
+
change_api_key = gr.Button('Change Key')
|
101 |
+
|
102 |
+
with gr.Row():
|
103 |
+
chatbot = gr.Chatbot(value=[], elem_id='chatbot')
|
104 |
+
show_img = gr.Image(label='Upload PDF')
|
105 |
+
pdf_upload = gr.UploadButton("π Upload a PDF", file_types=[".pdf"])
|
106 |
+
|
107 |
+
# Event handlers within the Blocks context
|
108 |
+
enable_box.submit(fn=set_apikey, inputs=[enable_box], outputs=[disable_box])
|
109 |
+
change_api_key.click(fn=enable_api_box, outputs=[enable_box])
|
110 |
+
pdf_upload.upload(fn=render_first, inputs=[pdf_upload], outputs=[show_img])
|
111 |
+
|
112 |
+
txt = gr.Textbox(label="Enter your query", placeholder="Ask a question...")
|
113 |
+
submit_btn = gr.Button('Submit')
|
114 |
+
|
115 |
+
submit_btn.click(
|
116 |
+
fn=add_text, inputs=[chatbot, txt], outputs=[chatbot], queue=False
|
117 |
+
).success(
|
118 |
+
fn=generate_response, inputs=[chatbot, txt, pdf_upload], outputs=[chatbot, txt]
|
119 |
+
).success(
|
120 |
+
fn=render_file, inputs=[pdf_upload], outputs=[show_img]
|
121 |
+
)
|
122 |
|
123 |
if __name__ == "__main__":
|
124 |
gr.Interface(
|