Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ def retrieve_relevant_chunks(query, chunks, chunk_embeddings):
|
|
44 |
query_embedding = get_embeddings(query)
|
45 |
similarities = cosine_similarity([query_embedding], chunk_embeddings)[0]
|
46 |
top_indices = np.argsort(similarities)[::-1][:3] # Get top 3 relevant chunks
|
47 |
-
return [chunks[i] for i in top_indices]
|
48 |
|
49 |
# Function to generate a response
|
50 |
def generate_response(context, query):
|
|
|
44 |
query_embedding = get_embeddings(query)
|
45 |
similarities = cosine_similarity([query_embedding], chunk_embeddings)[0]
|
46 |
top_indices = np.argsort(similarities)[::-1][:3] # Get top 3 relevant chunks
|
47 |
+
return [chunks[i] for i in top_indices] #we use the chunks list to retrieve the actual text of those relevant chunks. These text chunks will form the context.
|
48 |
|
49 |
# Function to generate a response
|
50 |
def generate_response(context, query):
|