llama-index graph stores ApertureDB integration
Project description
LlamaIndex Graph Stores Integration: ApertureDB
ApertureDB is a Multimodal Database. The storage is modelled as a graph.
It can be used off cloud, On premise, and it comes with a public community edition which can run on a laptop too.
This integration implements the PropertyGraph interface of llama_index, which can be used to Store and query a Knowledge Graph using ApertureDB as the store.
Assuming a working and accessible instance of ApertureDB the following examples would work for adding nodes to your graph, and retrieving them.
from llama_index.core.graph_stores.types import Relation, EntityNode
from llama_index.graph_stores.ApertureDB import ApertureDBGraphStore
entities = [
EntityNode(label="PERSON", name="James"),
EntityNode(label="DISH", name="Butter Chicken"),
EntityNode(label="DISH", name="Scrambled Eggs"),
EntityNode(label="INGREDIENT", name="Butter"),
EntityNode(label="INGREDIENT", name="Chicken"),
EntityNode(label="INGREDIENT", name="Eggs"),
EntityNode(label="INGREDIENT", name="Salt"),
]
relations = [
Relation(
label="EATS",
source_id=entities[0].id,
target_id=entities[1].id,
),
Relation(
label="EATS",
source_id=entities[0].id,
target_id=entities[2].id,
),
Relation(
label="CONTAINS",
source_id=entities[1].id,
target_id=entities[3].id,
),
Relation(
label="HAS",
source_id=entities[1].id,
target_id=entities[4].id,
),
Relation(
label="COMPRISED_OF",
source_id=entities[2].id,
target_id=entities[5].id,
),
Relation(
label="GOT",
source_id=entities[2].id,
target_id=entities[6].id,
),
]
graph_store = ApertureDBGraphStore()
graph_store.upsert_nodes(entities)
graph_store.upsert_relations(relations)
Retrieve nodes:
# get all.
print(pg_store.get())
# get nodes by ID.
kg_nodes = pg_store.get(ids=[entities[0].id])
print(kg_nodes)
# get paths from a node
paths = pg_store.get_rel_map(kg_nodes, depth=2)
import json
print(json.dumps(paths, indent=2, default=str))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_graph_stores_aperturedb-0.2.0.tar.gz.
File metadata
- Download URL: llama_index_graph_stores_aperturedb-0.2.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7236e9b38d71603d3063d97ab98599617c867d2b0314fe018421fde7a7fdf312
|
|
| MD5 |
d7748be64bd94f9bd878dadb2f3598a6
|
|
| BLAKE2b-256 |
5d81dc0ead180570358c91d631da830fc98999c76a83ef45d430f14615c352b2
|
File details
Details for the file llama_index_graph_stores_aperturedb-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_graph_stores_aperturedb-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bcc3dafbe49dcbd5c9600e204bc1ea6dd0d917af63eed9554b7248eb2d01e4a
|
|
| MD5 |
29fb977bc43c1513de226a30a8164a9e
|
|
| BLAKE2b-256 |
18774711c425d3805719ce1d0dcc2b7e3840d05508b66be947e43d33b6019dc2
|