description update app.py
Browse filesgradio interface description update
app.py
CHANGED
|
@@ -8,20 +8,20 @@ df.drop_duplicates(inplace=True, ignore_index=True)
|
|
| 8 |
|
| 9 |
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
| 10 |
|
| 11 |
-
def run_question(
|
| 12 |
somme = []
|
| 13 |
for jdx, j in enumerate(list(df.Question)):
|
| 14 |
somme.append(float(util.pytorch_cos_sim(
|
| 15 |
model.encode(list(df.Question)[jdx], convert_to_tensor=True),
|
| 16 |
-
model.encode(
|
| 17 |
if round(max(somme)*100) < 70:
|
| 18 |
-
return '
|
| 19 |
else:
|
| 20 |
return df.loc[somme.index(max(somme)), 'Answer']
|
| 21 |
|
| 22 |
gradio.Interface(run_question, "text", "text",
|
| 23 |
title='Introducing C.A.BOT',
|
| 24 |
-
description='This is Cabot, the Consular Affairs bot.
|
| 25 |
|
| 26 |
|
| 27 |
|
|
|
|
| 8 |
|
| 9 |
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
| 10 |
|
| 11 |
+
def run_question(Question):
|
| 12 |
somme = []
|
| 13 |
for jdx, j in enumerate(list(df.Question)):
|
| 14 |
somme.append(float(util.pytorch_cos_sim(
|
| 15 |
model.encode(list(df.Question)[jdx], convert_to_tensor=True),
|
| 16 |
+
model.encode(Question, convert_to_tensor=True))))
|
| 17 |
if round(max(somme)*100) < 70:
|
| 18 |
+
return 'I\'m sorry, I\'m not sure I understood your question. Could you try again?'
|
| 19 |
else:
|
| 20 |
return df.loc[somme.index(max(somme)), 'Answer']
|
| 21 |
|
| 22 |
gradio.Interface(run_question, "text", "text",
|
| 23 |
title='Introducing C.A.BOT',
|
| 24 |
+
description='Hi! This is Cabot, the Consular Affairs bot.\nI will help you answer your questions about the Citizen Services that you can request at the Consular Sections within U.S. Embassy Rome.').launch()
|
| 25 |
|
| 26 |
|
| 27 |
|