Summary
LlamaIndex data structures.
ComposableGraph #
Composable graph.
Source code in llama_index/core/indices/composability/graph.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
from_indices
classmethod
#
from_indices(root_index_cls: Type[BaseIndex], children_indices: Sequence[BaseIndex], index_summaries: Optional[Sequence[str]] = None, storage_context: Optional[StorageContext] = None, **kwargs: Any) -> ComposableGraph
Create composable graph using this index class as the root.
Source code in llama_index/core/indices/composability/graph.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
get_index #
get_index(index_struct_id: Optional[str] = None) -> BaseIndex
Get index from index struct id.
Source code in llama_index/core/indices/composability/graph.py
115 116 117 118 119 | |
DocumentSummaryIndex #
Bases: BaseIndex[IndexDocumentSummary]
Document Summary Index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_synthesizer
|
BaseSynthesizer
|
A response synthesizer for generating summaries. |
None
|
summary_query
|
str
|
The query to use to generate the summary for each document. |
DEFAULT_SUMMARY_QUERY
|
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
False
|
embed_summaries
|
bool
|
Whether to embed the summaries. This is required for running the default embedding-based retriever. Defaults to True. |
True
|
Source code in llama_index/core/indices/document_summary/base.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
as_retriever #
as_retriever(retriever_mode: Union[str, _RetrieverMode] = EMBEDDING, **kwargs: Any) -> BaseRetriever
Get retriever.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retriever_mode
|
Union[str, DocumentSummaryRetrieverMode]
|
A retriever mode. Defaults to DocumentSummaryRetrieverMode.EMBEDDING. |
EMBEDDING
|
Source code in llama_index/core/indices/document_summary/base.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_document_summary #
get_document_summary(doc_id: str) -> str
Get document summary by doc id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc_id
|
str
|
A document id. |
required |
Source code in llama_index/core/indices/document_summary/base.py
152 153 154 155 156 157 158 159 160 161 162 163 | |
delete_nodes #
delete_nodes(node_ids: List[str], delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a list of nodes from the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_ids
|
List[str]
|
A list of node_ids from the nodes to delete |
required |
Source code in llama_index/core/indices/document_summary/base.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a document from the index. All nodes in the index related to the document will be deleted.
Source code in llama_index/core/indices/document_summary/base.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
EmptyIndex #
Bases: BaseIndex[EmptyIndexStruct]
Empty Index.
An index that doesn't contain any documents. Used for pure LLM calls. NOTE: this exists because an empty index it allows certain properties, such as the ability to be composed with other indices + token counting + others.
Source code in llama_index/core/indices/empty/base.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
KeywordTableIndex #
Bases: BaseKeywordTableIndex
Keyword Table Index.
This index uses a GPT model to extract keywords from the text.
Source code in llama_index/core/indices/keyword_table/base.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
RAKEKeywordTableIndex #
Bases: BaseKeywordTableIndex
RAKE Keyword Table Index.
This index uses a RAKE keyword extractor to extract keywords from the text.
Source code in llama_index/core/indices/keyword_table/rake_base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
SimpleKeywordTableIndex #
Bases: BaseKeywordTableIndex
Simple Keyword Table Index.
This index uses a simple regex extractor to extract keywords from the text.
Source code in llama_index/core/indices/keyword_table/simple_base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
KnowledgeGraphIndex #
Bases: BaseIndex[KG]
Knowledge Graph Index.
Build a KG by extracting triplets, and leveraging the KG during query-time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kg_triplet_extract_template
|
BasePromptTemplate
|
The prompt to use for extracting triplets. |
None
|
max_triplets_per_chunk
|
int
|
The maximum number of triplets to extract. |
10
|
storage_context
|
Optional[StorageContext]
|
The storage context to use. |
None
|
graph_store
|
Optional[GraphStore]
|
The graph store to use. |
required |
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
False
|
include_embeddings
|
bool
|
Whether to include embeddings in the index. Defaults to False. |
False
|
max_object_length
|
int
|
The maximum length of the object in a triplet. Defaults to 128. |
128
|
kg_triplet_extract_fn
|
Optional[Callable]
|
The function to use for extracting triplets. Defaults to None. |
None
|
Source code in llama_index/core/indices/knowledge_graph/base.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
upsert_triplet #
upsert_triplet(triplet: Tuple[str, str, str], include_embeddings: bool = False) -> None
Insert triplets and optionally embeddings.
Used for manual insertion of KG triplets (in the form of (subject, relationship, object)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
triplet
|
tuple
|
Knowledge triplet |
required |
embedding
|
Any
|
Embedding option for the triplet. Defaults to None. |
required |
Source code in llama_index/core/indices/knowledge_graph/base.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
add_node #
add_node(keywords: List[str], node: BaseNode) -> None
Add node.
Used for manual insertion of nodes (keyed by keywords).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keywords
|
List[str]
|
Keywords to index the node. |
required |
node
|
Node
|
Node to be indexed. |
required |
Source code in llama_index/core/indices/knowledge_graph/base.py
277 278 279 280 281 282 283 284 285 286 287 288 289 | |
upsert_triplet_and_node #
upsert_triplet_and_node(triplet: Tuple[str, str, str], node: BaseNode, include_embeddings: bool = False) -> None
Upsert KG triplet and node.
Calls both upsert_triplet and add_node. Behavior is idempotent; if Node already exists, only triplet will be added.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keywords
|
List[str]
|
Keywords to index the node. |
required |
node
|
Node
|
Node to be indexed. |
required |
include_embeddings
|
bool
|
Option to add embeddings for triplets. Defaults to False |
False
|
Source code in llama_index/core/indices/knowledge_graph/base.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
get_networkx_graph #
get_networkx_graph(limit: int = 100) -> Any
Get networkx representation of the graph structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
Number of starting nodes to be included in the graph. |
100
|
NOTE: This function requires networkx to be installed. NOTE: This is a beta feature.
Source code in llama_index/core/indices/knowledge_graph/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
SummaryIndex #
Bases: BaseIndex[IndexList]
Summary Index.
The summary index is a simple data structure where nodes are stored in a sequence. During index construction, the document texts are chunked up, converted to nodes, and stored in a list.
During query time, the summary index iterates through the nodes with some optional filter parameters, and synthesizes an answer from all the nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_qa_template
|
Optional[BasePromptTemplate]
|
A Question-Answer Prompt
(see :ref: |
required |
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
False
|
Source code in llama_index/core/indices/list/base.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
MultiModalVectorStoreIndex #
Bases: VectorStoreIndex
Multi-Modal Vector Store Index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_async
|
bool
|
Whether to use asynchronous calls. Defaults to False. |
False
|
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
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 |
False
|
Source code in llama_index/core/indices/multi_modal/base.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a document and it's nodes by using ref_doc_id.
Source code in llama_index/core/indices/multi_modal/base.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
SQLStructStoreIndex #
Bases: BaseStructStoreIndex[SQLStructTable]
SQL Struct Store Index.
The SQLStructStoreIndex is an index that uses a SQL database under the hood. During index construction, the data can be inferred from unstructured documents given a schema extract prompt, or it can be pre-loaded in the database.
During query time, the user can either specify a raw SQL query or a natural language query to retrieve their data.
NOTE: this is deprecated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
documents
|
Optional[Sequence[DOCUMENTS_INPUT]]
|
Documents to index. NOTE: in the SQL index, this is an optional field. |
required |
sql_database
|
Optional[SQLDatabase]
|
SQL database to use,
including table names to specify.
See :ref: |
None
|
table_name
|
Optional[str]
|
Name of the table to use for extracting data. Either table_name or table must be specified. |
None
|
table
|
Optional[Table]
|
SQLAlchemy Table object to use. Specifying the Table object explicitly, instead of the table name, allows you to pass in a view. Either table_name or table must be specified. |
None
|
sql_context_container
|
Optional[SQLContextContainer]
|
SQL context container.
an be generated from a SQLContextContainerBuilder.
See :ref: |
None
|
Source code in llama_index/core/indices/struct_store/sql.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
TreeIndex #
Bases: BaseIndex[IndexGraph]
Tree Index.
The tree index is a tree-structured index, where each node is a summary of the children nodes. During index construction, the tree is constructed in a bottoms-up fashion until we end up with a set of root_nodes.
There are a few different options during query time (see :ref:Ref-Query).
The main option is to traverse down the tree from the root nodes.
A secondary answer is to directly synthesize the answer from the root nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary_template
|
Optional[BasePromptTemplate]
|
A Summarization Prompt
(see :ref: |
None
|
insert_prompt
|
Optional[BasePromptTemplate]
|
An Tree Insertion Prompt
(see :ref: |
None
|
num_children
|
int
|
The number of children each node should have. |
10
|
build_tree
|
bool
|
Whether to build the tree during index construction. |
True
|
show_progress
|
bool
|
Whether to show progress bars. Defaults to False. |
False
|
Source code in llama_index/core/indices/tree/base.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
VectorStoreIndex #
Bases: BaseIndex[IndexDict]
Vector Store Index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
use_async
|
bool
|
Whether to use asynchronous calls. Defaults to False. |
False
|
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
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 |
False
|
Source code in llama_index/core/indices/vector_store/base.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
build_index_from_nodes #
build_index_from_nodes(nodes: Sequence[BaseNode], **insert_kwargs: Any) -> IndexDict
Build the index from nodes.
Overrides BaseIndex.build_index_from_nodes.
VectorStoreIndex only stores nodes in document store if vector store does not store text
Source code in llama_index/core/indices/vector_store/base.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
ainsert_nodes
async
#
ainsert_nodes(nodes: Sequence[BaseNode], **insert_kwargs: Any) -> None
Insert nodes.
overrides BaseIndex.ainsert_nodes.
VectorStoreIndex only stores nodes in document store if vector store does not store text
Source code in llama_index/core/indices/vector_store/base.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
insert_nodes #
insert_nodes(nodes: Sequence[BaseNode], **insert_kwargs: Any) -> None
Insert nodes.
overrides BaseIndex.insert_nodes.
VectorStoreIndex only stores nodes in document store if vector store does not store text
Source code in llama_index/core/indices/vector_store/base.py
343 344 345 346 347 348 349 350 351 352 353 354 355 | |
adelete_nodes
async
#
adelete_nodes(node_ids: List[str], delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a list of nodes from the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_ids
|
List[str]
|
A list of node_ids from the nodes to delete |
required |
Source code in llama_index/core/indices/vector_store/base.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
delete_nodes #
delete_nodes(node_ids: List[str], delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a list of nodes from the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_ids
|
List[str]
|
A list of node_ids from the nodes to delete |
required |
Source code in llama_index/core/indices/vector_store/base.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a document and it's nodes by using ref_doc_id.
Source code in llama_index/core/indices/vector_store/base.py
424 425 426 427 428 429 430 431 432 | |
adelete_ref_doc
async
#
adelete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = False, **delete_kwargs: Any) -> None
Delete a document and it's nodes by using ref_doc_id.
Source code in llama_index/core/indices/vector_store/base.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
PropertyGraphIndex #
Bases: BaseIndex[IndexLPG]
An index for a property graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
Optional[Sequence[BaseNode]]
|
A list of nodes to insert into the index. |
None
|
llm
|
Optional[LLM]
|
The language model to use for extracting triplets. Defaults to |
None
|
kg_extractors
|
Optional[List[TransformComponent]]
|
A list of transformations to apply to the nodes to extract triplets.
Defaults to |
None
|
property_graph_store
|
Optional[PropertyGraphStore]
|
The property graph store to use. If not provided, a new |
None
|
vector_store
|
Optional[BasePydanticVectorStore]
|
The vector store index to use, if the graph store does not support vector queries. |
None
|
use_async
|
bool
|
Whether to use async for transformations. Defaults to |
True
|
embed_model
|
Optional[EmbedType]
|
The embedding model to use for embedding nodes.
If not provided, |
None
|
embed_kg_nodes
|
bool
|
Whether to embed the KG nodes. Defaults to |
True
|
callback_manager
|
Optional[CallbackManager]
|
The callback manager to use. |
None
|
transformations
|
Optional[List[TransformComponent]]
|
A list of transformations to apply to the nodes before inserting them into the index.
These are applied prior to the |
None
|
storage_context
|
Optional[StorageContext]
|
The storage context to use. |
None
|
show_progress
|
bool
|
Whether to show progress bars for transformations. Defaults to |
False
|
Source code in llama_index/core/indices/property_graph/base.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
property_graph_store
property
#
property_graph_store: PropertyGraphStore
Get the labelled property graph store.
ref_doc_info
property
#
ref_doc_info: Dict[str, RefDocInfo]
Retrieve a dict mapping of ingested documents and their nodes+metadata.
from_existing
classmethod
#
from_existing(property_graph_store: PropertyGraphStore, vector_store: Optional[BasePydanticVectorStore] = None, llm: Optional[LLM] = None, kg_extractors: Optional[List[TransformComponent]] = None, use_async: bool = True, embed_model: Optional[EmbedType] = None, embed_kg_nodes: bool = True, callback_manager: Optional[CallbackManager] = None, transformations: Optional[List[TransformComponent]] = None, storage_context: Optional[StorageContext] = None, show_progress: bool = False, **kwargs: Any) -> PropertyGraphIndex
Create an index from an existing property graph store (and optional vector store).
Source code in llama_index/core/indices/property_graph/base.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
as_retriever #
as_retriever(sub_retrievers: Optional[List[BasePGRetriever]] = None, include_text: bool = True, **kwargs: Any) -> BaseRetriever
Return a retriever for the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_retrievers
|
Optional[List[BasePGRetriever]]
|
A list of sub-retrievers to use. If not provided, a default list will be used:
|
None
|
include_text
|
bool
|
Whether to include source-text in the retriever results. |
True
|
**kwargs
|
Any
|
Additional kwargs to pass to the retriever. |
{}
|
Source code in llama_index/core/indices/property_graph/base.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
load_graph_from_storage #
load_graph_from_storage(storage_context: StorageContext, root_id: str, **kwargs: Any) -> ComposableGraph
Load composable graph from storage context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage_context
|
StorageContext
|
storage context containing docstore, index store and vector store. |
required |
root_id
|
str
|
ID of the root index of the graph. |
required |
**kwargs
|
Any
|
Additional keyword args to pass to the index constructors. |
{}
|
Source code in llama_index/core/indices/loading.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
load_index_from_storage #
load_index_from_storage(storage_context: StorageContext, index_id: Optional[str] = None, **kwargs: Any) -> BaseIndex
Load index from storage context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage_context
|
StorageContext
|
storage context containing docstore, index store and vector store. |
required |
index_id
|
Optional[str]
|
ID of the index to load. Defaults to None, which assumes there's only a single index in the index store and load it. |
None
|
**kwargs
|
Any
|
Additional keyword args to pass to the index constructors. |
{}
|
Source code in llama_index/core/indices/loading.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
load_indices_from_storage #
load_indices_from_storage(storage_context: StorageContext, index_ids: Optional[Sequence[str]] = None, **kwargs: Any) -> List[BaseIndex]
Load multiple indices from storage context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage_context
|
StorageContext
|
storage context containing docstore, index store and vector store. |
required |
index_id
|
Optional[Sequence[str]]
|
IDs of the indices to load. Defaults to None, which loads all indices in the index store. |
required |
**kwargs
|
Any
|
Additional keyword args to pass to the index constructors. |
{}
|
Source code in llama_index/core/indices/loading.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
options: members: - SummaryIndex