Index
GraphStore #
Bases: Protocol
Abstract graph store protocol.
This protocol defines the interface for a graph store, which is responsible for storing and retrieving knowledge graph data.
Attributes:
Name | Type | Description |
---|---|---|
client |
Any
|
Any: The client used to connect to the graph store. |
get |
List[List[str]]
|
Callable[[str], List[List[str]]]: Get triplets for a given subject. |
get_rel_map |
Dict[str, List[List[str]]]
|
Callable[[Optional[List[str]], int], Dict[str, List[List[str]]]]: Get subjects' rel map in max depth. |
upsert_triplet |
None
|
Callable[[str, str, str], None]: Upsert a triplet. |
delete |
None
|
Callable[[str, str, str], None]: Delete a triplet. |
persist |
None
|
Callable[[str, Optional[fsspec.AbstractFileSystem]], None]: Persist the graph store to a file. |
get_schema |
str
|
Callable[[bool], str]: Get the schema of the graph store. |
Source code in llama-index-core/llama_index/core/graph_stores/types.py
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 |
|
get #
get(subj: str) -> List[List[str]]
Get triplets.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
241 242 243 |
|
get_rel_map #
get_rel_map(subjs: Optional[List[str]] = None, depth: int = 2, limit: int = 30) -> Dict[str, List[List[str]]]
Get depth-aware rel map.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
245 246 247 248 249 |
|
upsert_triplet #
upsert_triplet(subj: str, rel: str, obj: str) -> None
Add triplet.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
251 252 253 |
|
delete #
delete(subj: str, rel: str, obj: str) -> None
Delete triplet.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
255 256 257 |
|
persist #
persist(persist_path: str, fs: Optional[AbstractFileSystem] = None) -> None
Persist the graph store to a file.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
259 260 261 262 263 |
|
get_schema #
get_schema(refresh: bool = False) -> str
Get the schema of the graph store.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
265 266 267 |
|
query #
query(query: str, param_map: Optional[Dict[str, Any]] = {}) -> Any
Query the graph store with statement and parameters.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
269 270 271 |
|
PropertyGraphStore #
Bases: ABC
Abstract labelled graph store protocol.
This protocol defines the interface for a graph store, which is responsible for storing and retrieving knowledge graph data.
Attributes:
Name | Type | Description |
---|---|---|
client |
Any
|
Any: The client used to connect to the graph store. |
get |
List[LabelledNode]
|
Callable[[str], List[List[str]]]: Get triplets for a given subject. |
get_rel_map |
List[Triplet]
|
Callable[[Optional[List[str]], int], Dict[str, List[List[str]]]]: Get subjects' rel map in max depth. |
upsert_triplet |
List[Triplet]
|
Callable[[str, str, str], None]: Upsert a triplet. |
delete |
None
|
Callable[[str, str, str], None]: Delete a triplet. |
persist |
None
|
Callable[[str, Optional[fsspec.AbstractFileSystem]], None]: Persist the graph store to a file. |
Source code in llama-index-core/llama_index/core/graph_stores/types.py
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 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
|
get
abstractmethod
#
get(properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[LabelledNode]
Get nodes with matching values.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
300 301 302 303 304 305 306 307 |
|
get_triplets
abstractmethod
#
get_triplets(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[Triplet]
Get triplets with matching values.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
309 310 311 312 313 314 315 316 317 318 |
|
get_rel_map
abstractmethod
#
get_rel_map(graph_nodes: List[LabelledNode], depth: int = 2, limit: int = 30, ignore_rels: Optional[List[str]] = None) -> List[Triplet]
Get depth-aware rel map.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
320 321 322 323 324 325 326 327 328 329 |
|
get_llama_nodes #
get_llama_nodes(node_ids: List[str]) -> List[BaseNode]
Get llama-index nodes.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
331 332 333 334 335 336 337 338 339 340 341 342 |
|
upsert_nodes
abstractmethod
#
upsert_nodes(nodes: Sequence[LabelledNode]) -> None
Upsert nodes.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
344 345 346 347 |
|
upsert_relations
abstractmethod
#
upsert_relations(relations: List[Relation]) -> None
Upsert relations.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
349 350 351 352 |
|
upsert_llama_nodes #
upsert_llama_nodes(llama_nodes: List[BaseNode]) -> None
Add llama-index nodes.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
|
delete
abstractmethod
#
delete(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> None
Delete matching data.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
369 370 371 372 373 374 375 376 377 378 |
|
delete_llama_nodes #
delete_llama_nodes(node_ids: Optional[List[str]] = None, ref_doc_ids: Optional[List[str]] = None) -> None
Delete llama-index nodes.
Intended to delete any nodes in the graph store associated with the given llama-index node_ids or ref_doc_ids.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
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 |
|
structured_query
abstractmethod
#
structured_query(query: str, param_map: Optional[Dict[str, Any]] = None) -> Any
Query the graph store with statement and parameters.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
408 409 410 411 412 413 |
|
vector_query
abstractmethod
#
vector_query(query: VectorStoreQuery, **kwargs: Any) -> Tuple[List[LabelledNode], List[float]]
Query the graph store with a vector store query.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
415 416 417 418 419 420 |
|
persist #
persist(persist_path: str, fs: Optional[AbstractFileSystem] = None) -> None
Persist the graph store to a file.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
422 423 424 425 426 |
|
get_schema #
get_schema(refresh: bool = False) -> Any
Get the schema of the graph store.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
428 429 430 |
|
get_schema_str #
get_schema_str(refresh: bool = False) -> str
Get the schema of the graph store as a string.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
432 433 434 |
|
aget
async
#
aget(properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[LabelledNode]
Asynchronously get nodes with matching values.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
438 439 440 441 442 443 444 |
|
aget_triplets
async
#
aget_triplets(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[Triplet]
Asynchronously get triplets with matching values.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
446 447 448 449 450 451 452 453 454 |
|
aget_rel_map
async
#
aget_rel_map(graph_nodes: List[LabelledNode], depth: int = 2, limit: int = 30, ignore_rels: Optional[List[str]] = None) -> List[Triplet]
Asynchronously get depth-aware rel map.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
456 457 458 459 460 461 462 463 464 |
|
aget_llama_nodes
async
#
aget_llama_nodes(node_ids: List[str]) -> List[BaseNode]
Asynchronously get nodes.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
466 467 468 469 470 471 472 473 474 475 476 477 |
|
aupsert_nodes
async
#
aupsert_nodes(nodes: List[LabelledNode]) -> None
Asynchronously add nodes.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
479 480 481 |
|
aupsert_relations
async
#
aupsert_relations(relations: List[Relation]) -> None
Asynchronously add relations.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
483 484 485 |
|
adelete
async
#
adelete(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> None
Asynchronously delete matching data.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
487 488 489 490 491 492 493 494 495 |
|
adelete_llama_nodes
async
#
adelete_llama_nodes(node_ids: Optional[List[str]] = None, ref_doc_ids: Optional[List[str]] = None) -> None
Asynchronously delete llama-index nodes.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
497 498 499 500 501 502 503 |
|
astructured_query
async
#
astructured_query(query: str, param_map: Optional[Dict[str, Any]] = {}) -> Any
Asynchronously query the graph store with statement and parameters.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
505 506 507 508 509 |
|
avector_query
async
#
avector_query(query: VectorStoreQuery, **kwargs: Any) -> Tuple[List[LabelledNode], List[float]]
Asynchronously query the graph store with a vector store query.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
511 512 513 514 515 |
|
aget_schema
async
#
aget_schema(refresh: bool = False) -> str
Asynchronously get the schema of the graph store.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
517 518 519 |
|
aget_schema_str
async
#
aget_schema_str(refresh: bool = False) -> str
Asynchronously get the schema of the graph store as a string.
Source code in llama-index-core/llama_index/core/graph_stores/types.py
521 522 523 |
|