aizanlabs commited on
Commit
1316103
·
verified ·
1 Parent(s): 3e8f405

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -92,14 +92,26 @@ class DocumentRetrievalAndGeneration:
92
  distances, indices = self.cpu_index.search(np.array([query_embedding]), k=5)
93
 
94
  content = ""
 
 
 
 
 
 
 
 
95
  for idx in indices[0]:
96
- content += "-" * 50 + "\n"
97
- content += self.all_splits[idx].page_content + "\n"
98
- distance=distances[0][idx]
99
- print("CHUNK", idx)
100
- print("Distance :",distance)
101
- print(self.all_splits[idx].page_content)
102
- print("############################")
 
 
 
 
103
  prompt = f"""<s>
104
  You are a knowledgeable assistant with access to a comprehensive database.
105
  I need you to answer my question and provide related information in a specific format.
 
92
  distances, indices = self.cpu_index.search(np.array([query_embedding]), k=5)
93
 
94
  content = ""
95
+ # for idx in indices[0]:
96
+ # content += "-" * 50 + "\n"
97
+ # content += self.all_splits[idx].page_content + "\n"
98
+ # distance=distances[0][idx]
99
+ # print("CHUNK", idx)
100
+ # print("Distance :",distance)
101
+ # print(self.all_splits[idx].page_content)
102
+ # print("############################")
103
  for idx in indices[0]:
104
+ if idx < len(self.all_splits) and idx < len(distances[0]):
105
+ content += "-" * 50 + "\n"
106
+ content += self.all_splits[idx].page_content + "\n"
107
+ distance = distances[0][idx]
108
+ print("CHUNK", idx)
109
+ print("Distance :", distance)
110
+ print(self.all_splits[idx].page_content)
111
+ print("############################")
112
+ else:
113
+ print(f"Index {idx} is out of bounds. Skipping.")
114
+
115
  prompt = f"""<s>
116
  You are a knowledgeable assistant with access to a comprehensive database.
117
  I need you to answer my question and provide related information in a specific format.