Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -152,7 +152,11 @@ def validate_api_key(api_key):
|
|
| 152 |
return "β API Key appears to be too short"
|
| 153 |
|
| 154 |
return "β API Key format looks valid (not verified with server)"
|
|
|
|
|
|
|
|
|
|
| 155 |
|
|
|
|
| 156 |
# Create the Gradio interface
|
| 157 |
with gr.Blocks(title="ChatPDF with Together AI", theme=gr.themes.Ocean()) as app:
|
| 158 |
gr.Markdown("# π ChatPDF with Together AI")
|
|
@@ -218,6 +222,8 @@ with gr.Blocks(title="ChatPDF with Together AI", theme=gr.themes.Ocean()) as app
|
|
| 218 |
|
| 219 |
# Submit button
|
| 220 |
submit_button = gr.Button("Submit Question")
|
|
|
|
|
|
|
| 221 |
|
| 222 |
# Event handlers
|
| 223 |
def update_preview(text):
|
|
@@ -266,6 +272,20 @@ with gr.Blocks(title="ChatPDF with Together AI", theme=gr.themes.Ocean()) as app
|
|
| 266 |
outputs=question
|
| 267 |
)
|
| 268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
# Launch the app
|
| 270 |
if __name__ == "__main__":
|
| 271 |
app.launch(share=True)
|
|
|
|
| 152 |
return "β API Key appears to be too short"
|
| 153 |
|
| 154 |
return "β API Key format looks valid (not verified with server)"
|
| 155 |
+
# β
Clear function
|
| 156 |
+
def clear_all():
|
| 157 |
+
return "", "", "", "", [], "", ""
|
| 158 |
|
| 159 |
+
|
| 160 |
# Create the Gradio interface
|
| 161 |
with gr.Blocks(title="ChatPDF with Together AI", theme=gr.themes.Ocean()) as app:
|
| 162 |
gr.Markdown("# π ChatPDF with Together AI")
|
|
|
|
| 222 |
|
| 223 |
# Submit button
|
| 224 |
submit_button = gr.Button("Submit Question")
|
| 225 |
+
# clear button
|
| 226 |
+
|
| 227 |
|
| 228 |
# Event handlers
|
| 229 |
def update_preview(text):
|
|
|
|
| 272 |
outputs=question
|
| 273 |
)
|
| 274 |
|
| 275 |
+
# β
Clear Button Handler
|
| 276 |
+
clear_button.click(
|
| 277 |
+
fn=clear_all,
|
| 278 |
+
outputs=[
|
| 279 |
+
api_key_input,
|
| 280 |
+
api_key_status,
|
| 281 |
+
question,
|
| 282 |
+
pdf_text,
|
| 283 |
+
chatbot,
|
| 284 |
+
status_message,
|
| 285 |
+
pdf_preview
|
| 286 |
+
]
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
# Launch the app
|
| 290 |
if __name__ == "__main__":
|
| 291 |
app.launch(share=True)
|