NaimaAqeel commited on
Commit
b3c77f8
·
verified ·
1 Parent(s): 3047beb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -92,7 +92,7 @@ def upload_files(files):
92
  embeddings = embedding_model.encode(sentences)
93
  print(f"Embeddings shape: {embeddings.shape}") # Debug: Show the shape of the embeddings
94
  index.add(np.array(embeddings))
95
- document_texts.append(text)
96
 
97
  # Save the updated index and documents
98
  with open(index_path, "wb") as f:
@@ -122,7 +122,7 @@ def query_text(text):
122
  top_documents = []
123
  for idx in I[0]:
124
  if idx != -1 and idx < len(document_texts): # Ensure that a valid index is found
125
- top_documents.append(document_texts[idx])
126
  else:
127
  print(f"Invalid index found: {idx}")
128
  return top_documents
@@ -158,6 +158,7 @@ demo.launch()
158
 
159
 
160
 
 
161
 
162
 
163
 
 
92
  embeddings = embedding_model.encode(sentences)
93
  print(f"Embeddings shape: {embeddings.shape}") # Debug: Show the shape of the embeddings
94
  index.add(np.array(embeddings))
95
+ document_texts.append(sentences) # Store sentences for retrieval
96
 
97
  # Save the updated index and documents
98
  with open(index_path, "wb") as f:
 
122
  top_documents = []
123
  for idx in I[0]:
124
  if idx != -1 and idx < len(document_texts): # Ensure that a valid index is found
125
+ top_documents.append(" ".join(document_texts[idx])) # Combine the sentences for the response
126
  else:
127
  print(f"Invalid index found: {idx}")
128
  return top_documents
 
158
 
159
 
160
 
161
+
162
 
163
 
164