t4ai commited on
Commit
487fc4b
·
1 Parent(s): 1d7ee16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -44,10 +44,10 @@ with gr.Blocks() as demo:
44
  bot_message = "Hm, I don't see any document text, please paste in the box on the left."
45
  else:
46
  query_bot = query_model({"inputs": {"question": message, "context": context}})
47
- if(len(query_bot) and ("answer" in query_bot)):
48
  bot_message = query_bot['answer']
49
  else:
50
- bot_message = "I'm having trouble with this question, please try rewording (Sometimes, I need a few seconds to load...)"
51
 
52
 
53
  chat_history.append((message, bot_message))
 
44
  bot_message = "Hm, I don't see any document text, please paste in the box on the left."
45
  else:
46
  query_bot = query_model({"inputs": {"question": message, "context": context}})
47
+ if(len(query_bot) and ("answer" in query_bot)) and (query_bot['score'] > 0.1):
48
  bot_message = query_bot['answer']
49
  else:
50
+ bot_message = random.choice(["I'm having trouble with this question, please try rewording and make sure it is relevant to the document.", "Hm, I'm having trouble finding the answer to that. Can you reword the question?", "Sorry, I can't find the answer to this question."])
51
 
52
 
53
  chat_history.append((message, bot_message))