Spaces:
Sleeping
Sleeping
Update get_hadiths.py
Browse files- get_hadiths.py +3 -3
get_hadiths.py
CHANGED
@@ -41,14 +41,14 @@ class HadithSearch:
|
|
41 |
if self.data is None:
|
42 |
raise ValueError("Data not loaded.")
|
43 |
|
44 |
-
embedding_column_name = "
|
45 |
try:
|
46 |
-
self.data[embedding_column_name] = self.data.
|
47 |
except Exception as e:
|
48 |
pass
|
49 |
|
50 |
embedding = self._get_embedding(user_input, model='text-embedding-ada-002')
|
51 |
-
self.data['similarities'] = self.data.
|
52 |
|
53 |
results = self.data.sort_values('similarities', ascending=False).head(int(num_hadiths)).to_dict(orient="records")
|
54 |
formatted_results = self._format_results(results)
|
|
|
41 |
if self.data is None:
|
42 |
raise ValueError("Data not loaded.")
|
43 |
|
44 |
+
embedding_column_name = "embeding"
|
45 |
try:
|
46 |
+
self.data[embedding_column_name] = self.data.embeding.apply(lambda x: x["embeding"])
|
47 |
except Exception as e:
|
48 |
pass
|
49 |
|
50 |
embedding = self._get_embedding(user_input, model='text-embedding-ada-002')
|
51 |
+
self.data['similarities'] = self.data.embeding.apply(lambda x: self._cosine_similarity(x, embedding))
|
52 |
|
53 |
results = self.data.sort_values('similarities', ascending=False).head(int(num_hadiths)).to_dict(orient="records")
|
54 |
formatted_results = self._format_results(results)
|