Spaces:
Sleeping
Sleeping
Commit
Β·
81f334a
1
Parent(s):
caca9eb
fix 3
Browse files- app.py +72 -57
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -347,63 +347,78 @@ def chat_interface(message, history):
|
|
| 347 |
elif isinstance(chunk, dict) and "answer" in chunk:
|
| 348 |
response += chunk["answer"]
|
| 349 |
yield response
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
.chatbox-container {
|
| 365 |
-
display: flex;
|
| 366 |
-
flex-direction: column;
|
| 367 |
-
height: 95%;
|
| 368 |
-
}
|
| 369 |
-
|
| 370 |
-
.chatbot {
|
| 371 |
-
flex: 1;
|
| 372 |
-
overflow-y: auto;
|
| 373 |
-
min-height: 500px;
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
.textbox {
|
| 377 |
-
margin-top: 1rem;
|
| 378 |
-
}
|
| 379 |
-
#component-523 {
|
| 380 |
-
height: 98%;
|
| 381 |
-
}
|
| 382 |
-
""") as demo:
|
| 383 |
-
with gr.Column(elem_classes="chatbox-container"):
|
| 384 |
-
gr.Markdown("## π¬ Ask Krishna's AI Assistant")
|
| 385 |
-
gr.Markdown("π‘ Ask anything about Krishna Vamsi Dhulipalla")
|
| 386 |
-
chatbot = gr.Chatbot(elem_classes="chatbot", type="messages")
|
| 387 |
-
textbox = gr.Textbox(placeholder="Ask a question about Krishna...", elem_classes="textbox")
|
| 388 |
-
|
| 389 |
-
gr.ChatInterface(
|
| 390 |
-
fn=chat_interface,
|
| 391 |
-
chatbot=chatbot,
|
| 392 |
-
textbox=textbox,
|
| 393 |
-
examples=[
|
| 394 |
-
"What are Krishna's research interests?",
|
| 395 |
-
"Where did Krishna work?",
|
| 396 |
-
"What did he study at Virginia Tech?"
|
| 397 |
-
],
|
| 398 |
-
type= "messages",
|
| 399 |
-
)
|
| 400 |
|
| 401 |
if __name__ == "__main__":
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
|
| 408 |
-
|
| 409 |
-
|
|
|
|
| 347 |
elif isinstance(chunk, dict) and "answer" in chunk:
|
| 348 |
response += chunk["answer"]
|
| 349 |
yield response
|
| 350 |
+
|
| 351 |
+
demo = gr.ChatInterface(
|
| 352 |
+
fn=chat_interface,
|
| 353 |
+
title="π¬ Ask Krishna's AI Assistant",
|
| 354 |
+
description="π‘ Ask anything about Krishna Vamsi Dhulipalla",
|
| 355 |
+
# examples=[
|
| 356 |
+
# "What are Krishna's research interests?",
|
| 357 |
+
# "Where did Krishna work?",
|
| 358 |
+
# "What did he study at Virginia Tech?"
|
| 359 |
+
# ],
|
| 360 |
+
theme="default"
|
| 361 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
|
| 363 |
if __name__ == "__main__":
|
| 364 |
+
demo.launch(debug=True)
|
| 365 |
+
|
| 366 |
+
# with gr.Blocks(css="""
|
| 367 |
+
# html, body, .gradio-container {
|
| 368 |
+
# height: 100%;
|
| 369 |
+
# margin: 0;
|
| 370 |
+
# padding: 0;
|
| 371 |
+
# }
|
| 372 |
+
# .gradio-container {
|
| 373 |
+
# width: 90%;
|
| 374 |
+
# max-width: 1000px;
|
| 375 |
+
# margin: 0 auto;
|
| 376 |
+
# padding: 1rem;
|
| 377 |
+
# }
|
| 378 |
+
|
| 379 |
+
# .chatbox-container {
|
| 380 |
+
# display: flex;
|
| 381 |
+
# flex-direction: column;
|
| 382 |
+
# height: 95%;
|
| 383 |
+
# }
|
| 384 |
+
|
| 385 |
+
# .chatbot {
|
| 386 |
+
# flex: 1;
|
| 387 |
+
# overflow-y: auto;
|
| 388 |
+
# min-height: 500px;
|
| 389 |
+
# }
|
| 390 |
+
|
| 391 |
+
# .textbox {
|
| 392 |
+
# margin-top: 1rem;
|
| 393 |
+
# }
|
| 394 |
+
# #component-523 {
|
| 395 |
+
# height: 98%;
|
| 396 |
+
# }
|
| 397 |
+
# """) as demo:
|
| 398 |
+
# with gr.Column(elem_classes="chatbox-container"):
|
| 399 |
+
# gr.Markdown("## π¬ Ask Krishna's AI Assistant")
|
| 400 |
+
# gr.Markdown("π‘ Ask anything about Krishna Vamsi Dhulipalla")
|
| 401 |
+
# chatbot = gr.Chatbot(elem_classes="chatbot", type="messages")
|
| 402 |
+
# textbox = gr.Textbox(placeholder="Ask a question about Krishna...", elem_classes="textbox")
|
| 403 |
+
|
| 404 |
+
# gr.ChatInterface(
|
| 405 |
+
# fn=chat_interface,
|
| 406 |
+
# chatbot=chatbot,
|
| 407 |
+
# textbox=textbox,
|
| 408 |
+
# # examples=[
|
| 409 |
+
# # "What are Krishna's research interests?",
|
| 410 |
+
# # "Where did Krishna work?",
|
| 411 |
+
# # "What did he study at Virginia Tech?"
|
| 412 |
+
# # ],
|
| 413 |
+
# type= "messages",
|
| 414 |
+
# )
|
| 415 |
+
|
| 416 |
+
# if __name__ == "__main__":
|
| 417 |
+
# # Add resource verification
|
| 418 |
+
# print(f"FAISS path exists: {Path(FAISS_PATH).exists()}")
|
| 419 |
+
# print(f"Chunks path exists: {Path(CHUNKS_PATH).exists()}")
|
| 420 |
+
# print(f"Vectorstore type: {type(vectorstore)}")
|
| 421 |
+
# print(f"All chunks count: {len(all_chunks)}")
|
| 422 |
|
| 423 |
+
# # Launch the application
|
| 424 |
+
# demo.launch(debug=True)
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
-
gradio
|
| 4 |
rich
|
| 5 |
numpy
|
| 6 |
python-dotenv
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
+
gradio==5.31.0
|
| 4 |
rich
|
| 5 |
numpy
|
| 6 |
python-dotenv
|