Spaces:
Sleeping
Sleeping
added multi index search
Browse files
rag_app/multi_index_search.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain_core.vectorstores import VectorStoreRetriever
|
2 |
+
from langchain_core.documents import Document
|
3 |
+
from typing import List, Dict
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
def multi_index_search(
|
8 |
+
vector_Store_retrievers:List[VectorStoreRetriever],
|
9 |
+
query:str,
|
10 |
+
) -> List[Dict[VectorStoreRetriever,List[str]]]:
|
11 |
+
"""
|
12 |
+
|
13 |
+
## Summary
|
14 |
+
Search a set of vector stores and returns a list of `Documents` for each vector store
|
15 |
+
in a query
|
16 |
+
|
17 |
+
## Arguements
|
18 |
+
vector_Store_retrievers (List[VectorStoreRetriever]): A set of VectorStoreRetriever
|
19 |
+
query (str): the query
|
20 |
+
|
21 |
+
## Return
|
22 |
+
List[Dict[VectorStoreRetriever,List[str]]]
|
23 |
+
"""
|
24 |
+
|
25 |
+
multi_indices_search_list = []
|
26 |
+
for i in vector_Store_retrievers:
|
27 |
+
results = i.invoke(query)
|
28 |
+
data = {i : results }
|
29 |
+
multi_indices_search_list.append(data)
|
30 |
+
|
31 |
+
|
32 |
+
return multi_indices_search_list
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
pass
|