Skip to content

Commit

Permalink
hotfix: rm useless test file & add vector_stores for multiple stores (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
suluyana authored Jul 3, 2024
1 parent bddd086 commit f2d878f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 13 additions & 0 deletions modelscope_agent/rag/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def __init__(self,
vector_store: Union[BasePydanticVectorStore,
Type[BasePydanticVectorStore],
None] = None,
vector_stores: Dict[
str, Union[BasePydanticVectorStore,
Type[BasePydanticVectorStore]]] = {},
image_store: Union[BasePydanticVectorStore,
Type[BasePydanticVectorStore],
None] = None,
Expand All @@ -90,6 +93,10 @@ def __init__(self,
vector_store = self.get_storage(vector_store)
image_store = self.get_storage(image_store)
graph_store = self.get_storage(graph_store)
v_stores = dict()
if vector_stores:
for key, value in vector_stores.items():
v_stores[key] = self.get_storage(value)

documents.extend(self.read(files))

Expand All @@ -108,6 +115,7 @@ def __init__(self,
docstore=docstore,
index_store=index_store,
vector_store=vector_store,
vector_stores=v_stores,
image_store=image_store,
graph_store=graph_store,
**kwargs)
Expand Down Expand Up @@ -219,6 +227,8 @@ def get_index(self,
docstore: Optional[BaseDocumentStore] = None,
index_store: Optional[BaseIndexStore] = None,
vector_store: Optional[BasePydanticVectorStore] = None,
vector_stores: Optional[Dict[
str, BasePydanticVectorStore]] = None,
image_store: Optional[BasePydanticVectorStore] = None,
graph_store: Optional[GraphStore] = None,
**kwargs) -> BaseIndex:
Expand All @@ -235,6 +245,7 @@ def get_index(self,
docstore=docstore,
index_store=index_store,
vector_store=vector_store,
vector_stores=vector_stores,
image_store=image_store,
graph_store=graph_store,
persist_dir=self.cache_dir)
Expand Down Expand Up @@ -271,6 +282,7 @@ def get_root_retriever(
docstore: Optional[BaseDocumentStore] = None,
index_store: Optional[BaseIndexStore] = None,
vector_store: Optional[BasePydanticVectorStore] = None,
vector_stores: Optional[Dict[str, BasePydanticVectorStore]] = None,
image_store: Optional[BasePydanticVectorStore] = None,
graph_store: Optional[GraphStore] = None,
**kwargs) -> BaseRetriever:
Expand All @@ -280,6 +292,7 @@ def get_root_retriever(
docstore=docstore,
index_store=index_store,
vector_store=vector_store,
vector_stores=vector_stores,
image_store=image_store,
graph_store=graph_store,
**kwargs)
Expand Down
6 changes: 0 additions & 6 deletions tests/samples/code.py

This file was deleted.

0 comments on commit f2d878f

Please sign in to comment.