Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def respond(
|
|
45 |
selected_references['similarity'] = scores.tolist()[0]
|
46 |
sorted_references = selected_references.sort_values(by='similarity', ascending=False)
|
47 |
print(sorted_references.shape[0])
|
48 |
-
sorted_references = sorted_references.iloc[:
|
49 |
sorted_references = sorted_references.sort_values(by='similarity', ascending=True)
|
50 |
print(sorted_references.shape[0])
|
51 |
print(sorted_references['similarity'].tolist())
|
@@ -54,17 +54,20 @@ def respond(
|
|
54 |
translator = Translator()
|
55 |
|
56 |
for index, row in sorted_references.iterrows():
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
|
68 |
#adding more references
|
69 |
df = pd.read_csv("moslem-bot-reference.csv")
|
70 |
for index, row in df.iterrows():
|
|
|
45 |
selected_references['similarity'] = scores.tolist()[0]
|
46 |
sorted_references = selected_references.sort_values(by='similarity', ascending=False)
|
47 |
print(sorted_references.shape[0])
|
48 |
+
sorted_references = sorted_references.iloc[:3]
|
49 |
sorted_references = sorted_references.sort_values(by='similarity', ascending=True)
|
50 |
print(sorted_references.shape[0])
|
51 |
print(sorted_references['similarity'].tolist())
|
|
|
54 |
translator = Translator()
|
55 |
|
56 |
for index, row in sorted_references.iterrows():
|
57 |
+
if(type(row["user"]) is str and type(row['assistant']) is str):
|
58 |
+
try:
|
59 |
+
print(index)
|
60 |
+
print(f'{row["user"]}')
|
61 |
+
user = translator.translate(f'{row["user"]}', src='ar', dest='en').text
|
62 |
+
print(user)
|
63 |
+
#print(row['assistant'])
|
64 |
+
assistant = translator.translate(row['assistant']).text
|
65 |
+
#print(assistant)
|
66 |
+
messages.append({"role": "user", "content":user })
|
67 |
+
messages.append({"role": "assistant", "content": assistant})
|
68 |
+
except:
|
69 |
+
print("An exception occurred")
|
70 |
|
|
|
71 |
#adding more references
|
72 |
df = pd.read_csv("moslem-bot-reference.csv")
|
73 |
for index, row in df.iterrows():
|