Spaces:
Paused
Paused
Davide Fiocco commited on
Commit ·
b39f806
1
Parent(s): ad2c89a
Rotate answers when not sure
Browse files
utils.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import datetime
|
| 2 |
import json
|
|
|
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
import tokenizers
|
| 5 |
import torch
|
|
@@ -13,7 +15,12 @@ def get_answer(input, context, engine, threshold=0.5):
|
|
| 13 |
if answer["score"] > threshold:
|
| 14 |
return answer["answer"]
|
| 15 |
else:
|
| 16 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
@st.cache
|
|
|
|
| 1 |
import datetime
|
| 2 |
import json
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
import streamlit as st
|
| 6 |
import tokenizers
|
| 7 |
import torch
|
|
|
|
| 15 |
if answer["score"] > threshold:
|
| 16 |
return answer["answer"]
|
| 17 |
else:
|
| 18 |
+
return random.choice(
|
| 19 |
+
[
|
| 20 |
+
"Non lo so, prova con un'altra domanda!",
|
| 21 |
+
"Non so rispondere a questa domanda, riprova!",
|
| 22 |
+
]
|
| 23 |
+
)
|
| 24 |
|
| 25 |
|
| 26 |
@st.cache
|