keerthi-balaji
commited on
Commit
•
118896e
1
Parent(s):
02d3075
Update app.py
Browse files
app.py
CHANGED
@@ -28,12 +28,18 @@ class HoroscopeRetriever(RagRetriever):
|
|
28 |
self.docs = docs
|
29 |
|
30 |
def retrieve(self, question_hidden_states, n_docs=1):
|
31 |
-
# Convert the question_hidden_states
|
32 |
-
|
33 |
|
34 |
-
if isinstance(
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
# Simple retrieval logic: return the most relevant document based on the question
|
39 |
for doc in self.docs:
|
|
|
28 |
self.docs = docs
|
29 |
|
30 |
def retrieve(self, question_hidden_states, n_docs=1):
|
31 |
+
# Convert the question_hidden_states to a text string
|
32 |
+
question_hidden_states = question_hidden_states[0]
|
33 |
|
34 |
+
if isinstance(question_hidden_states, np.ndarray):
|
35 |
+
if question_hidden_states.size == 1:
|
36 |
+
question = question_hidden_states.item() # Convert single-element array to scalar
|
37 |
+
else:
|
38 |
+
question = str(question_hidden_states[0]) # Take the first element of the array
|
39 |
+
else:
|
40 |
+
question = str(question_hidden_states)
|
41 |
+
|
42 |
+
question = question.lower()
|
43 |
|
44 |
# Simple retrieval logic: return the most relevant document based on the question
|
45 |
for doc in self.docs:
|