vectorStorIndex.py
· 1.8 KiB · Python
Raw
class VectorStoreIndex(BaseIndex[IndexDict]):
"""
Vector Store Index.
Args:
use_async (bool): Whether to use asynchronous calls. Defaults to False.
show_progress (bool): Whether to show tqdm progress bars. Defaults to False.
store_nodes_override (bool): set to True to always store Node objects in index
store and document store even if vector store keeps text. Defaults to False
"""
index_struct_cls = IndexDict
def __init__(
self,
nodes: Optional[Sequence[BaseNode]] = None,
# vector store index params
use_async: bool = False,
store_nodes_override: bool = False,
embed_model: Optional[EmbedType] = None,
insert_batch_size: int = 2048,
# parent class params
objects: Optional[Sequence[IndexNode]] = None,
index_struct: Optional[IndexDict] = None,
storage_context: Optional[StorageContext] = None,
callback_manager: Optional[CallbackManager] = None,
transformations: Optional[List[TransformComponent]] = None,
show_progress: bool = False,
**kwargs: Any,
) -> None:
"""Initialize params."""
self._use_async = use_async
self._store_nodes_override = store_nodes_override
self._embed_model = (
resolve_embed_model(embed_model, callback_manager=callback_manager)
if embed_model
else Settings.embed_model
)
self._insert_batch_size = insert_batch_size
super().__init__(
nodes=nodes,
index_struct=index_struct,
storage_context=storage_context,
show_progress=show_progress,
objects=objects,
callback_manager=callback_manager,
transformations=transformations,
**kwargs,
)
1 | class VectorStoreIndex(BaseIndex[IndexDict]): |
2 | """ |
3 | Vector Store Index. |
4 | |
5 | Args: |
6 | use_async (bool): Whether to use asynchronous calls. Defaults to False. |
7 | show_progress (bool): Whether to show tqdm progress bars. Defaults to False. |
8 | store_nodes_override (bool): set to True to always store Node objects in index |
9 | store and document store even if vector store keeps text. Defaults to False |
10 | """ |
11 | |
12 | index_struct_cls = IndexDict |
13 | |
14 | def __init__( |
15 | self, |
16 | nodes: Optional[Sequence[BaseNode]] = None, |
17 | # vector store index params |
18 | use_async: bool = False, |
19 | store_nodes_override: bool = False, |
20 | embed_model: Optional[EmbedType] = None, |
21 | insert_batch_size: int = 2048, |
22 | # parent class params |
23 | objects: Optional[Sequence[IndexNode]] = None, |
24 | index_struct: Optional[IndexDict] = None, |
25 | storage_context: Optional[StorageContext] = None, |
26 | callback_manager: Optional[CallbackManager] = None, |
27 | transformations: Optional[List[TransformComponent]] = None, |
28 | show_progress: bool = False, |
29 | **kwargs: Any, |
30 | ) -> None: |
31 | """Initialize params.""" |
32 | self._use_async = use_async |
33 | self._store_nodes_override = store_nodes_override |
34 | self._embed_model = ( |
35 | resolve_embed_model(embed_model, callback_manager=callback_manager) |
36 | if embed_model |
37 | else Settings.embed_model |
38 | ) |
39 | |
40 | self._insert_batch_size = insert_batch_size |
41 | super().__init__( |
42 | nodes=nodes, |
43 | index_struct=index_struct, |
44 | storage_context=storage_context, |
45 | show_progress=show_progress, |
46 | objects=objects, |
47 | callback_manager=callback_manager, |
48 | transformations=transformations, |
49 | **kwargs, |
50 | ) |
51 |