Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,14 +29,8 @@ def respond(
|
|
29 |
messages.append({"role": "user", "content": "I want you to answer strictly based on quran and hadith"})
|
30 |
messages.append({"role": "assistant", "content": "I'd be happy to help! Please go ahead and provide the sentence you'd like me to analyze. Please specify whether you're referencing a particular verse or hadith (Prophetic tradition) from the Quran or Hadith, or if you're asking me to analyze a general statement."})
|
31 |
|
32 |
-
#adding references
|
33 |
-
|
34 |
-
for index, row in df.iterrows():
|
35 |
-
messages.append({"role": "user", "content": row['user']})
|
36 |
-
messages.append({"role": "assistant", "content": row['assistant']})
|
37 |
-
|
38 |
-
#adding more references
|
39 |
-
"""selected_references = torch.load('selected_references.sav', map_location=torch.device('cpu'))
|
40 |
encoded_questions = torch.load('encoded_questions.sav', map_location=torch.device('cpu'))
|
41 |
|
42 |
task = 'Given a web search query, retrieve relevant passages that answer the query'
|
@@ -51,6 +45,7 @@ def respond(
|
|
51 |
sorted_references = selected_references.sort_values(by='similarity', ascending=False)
|
52 |
sorted_references = sorted_references.head(1)
|
53 |
sorted_references = selected_references.sort_values(by='similarity', ascending=True)
|
|
|
54 |
|
55 |
from googletrans import Translator
|
56 |
translator = Translator()
|
@@ -65,7 +60,12 @@ def respond(
|
|
65 |
#print(assistant)
|
66 |
messages.append({"role": "user", "content":user })
|
67 |
messages.append({"role": "assistant", "content": assistant})
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
#history from chat session
|
71 |
for val in history:
|
|
|
29 |
messages.append({"role": "user", "content": "I want you to answer strictly based on quran and hadith"})
|
30 |
messages.append({"role": "assistant", "content": "I'd be happy to help! Please go ahead and provide the sentence you'd like me to analyze. Please specify whether you're referencing a particular verse or hadith (Prophetic tradition) from the Quran or Hadith, or if you're asking me to analyze a general statement."})
|
31 |
|
32 |
+
#adding fatwa references
|
33 |
+
selected_references = torch.load('selected_references.sav', map_location=torch.device('cpu'))
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
encoded_questions = torch.load('encoded_questions.sav', map_location=torch.device('cpu'))
|
35 |
|
36 |
task = 'Given a web search query, retrieve relevant passages that answer the query'
|
|
|
45 |
sorted_references = selected_references.sort_values(by='similarity', ascending=False)
|
46 |
sorted_references = sorted_references.head(1)
|
47 |
sorted_references = selected_references.sort_values(by='similarity', ascending=True)
|
48 |
+
print(sorted_references['similarity'].tolist())
|
49 |
|
50 |
from googletrans import Translator
|
51 |
translator = Translator()
|
|
|
60 |
#print(assistant)
|
61 |
messages.append({"role": "user", "content":user })
|
62 |
messages.append({"role": "assistant", "content": assistant})
|
63 |
+
|
64 |
+
#adding more references
|
65 |
+
df = pd.read_csv("moslem-bot-reference.csv")
|
66 |
+
for index, row in df.iterrows():
|
67 |
+
messages.append({"role": "user", "content": row['user']})
|
68 |
+
messages.append({"role": "assistant", "content": row['assistant']})
|
69 |
|
70 |
#history from chat session
|
71 |
for val in history:
|