Spaces:
Runtime error
Runtime error
ffreemt
commited on
Commit
·
5b49de4
1
Parent(s):
0519f89
Update torch.cuda.is_available() for device/device_type
Browse files
app.py
CHANGED
@@ -364,11 +364,24 @@ def main():
|
|
364 |
|
365 |
def respond(message, chat_history):
|
366 |
# bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
367 |
-
if ns.
|
368 |
bot_message = "Upload some file(s) for processing first."
|
369 |
chat_history.append((message, bot_message))
|
370 |
return "", chat_history
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
try:
|
373 |
res = ns.qa(message)
|
374 |
answer, docs = res["result"], res["source_documents"]
|
|
|
364 |
|
365 |
def respond(message, chat_history):
|
366 |
# bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
|
367 |
+
if ns.ingest_done is None: # no files processed yet
|
368 |
bot_message = "Upload some file(s) for processing first."
|
369 |
chat_history.append((message, bot_message))
|
370 |
return "", chat_history
|
371 |
|
372 |
+
if not ns.ingest_done: # embedding database not doen yet
|
373 |
+
bot_message = (
|
374 |
+
"Waiting for ingest (embedding) to finish, "
|
375 |
+
"be patient... You can switch the 'Upload files' "
|
376 |
+
"Tab to check"
|
377 |
+
)
|
378 |
+
chat_history.append((message, bot_message))
|
379 |
+
return "", chat_history
|
380 |
+
|
381 |
+
if ns.qa is None: # load qa one time
|
382 |
+
logger.info("Loading qa, need to do just one time.")
|
383 |
+
ns.qa = load_qa()
|
384 |
+
|
385 |
try:
|
386 |
res = ns.qa(message)
|
387 |
answer, docs = res["result"], res["source_documents"]
|