Skip to main content

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

llama_index_graph_stores_aperturedb-0.2.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_graph_stores_aperturedb-0.2.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_graph_stores_aperturedb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5949237b75a077598d3b76ed438d889a0c46b7fd7bd08f5a999114030de63e9a
MD5 8ba4cecad7f727516fcdd3f72ca11534
BLAKE2b-256 53a6d8277cf970a26fb347aa6bc8d32528ad54fac6a36be924f7742de95e5e10

See more details on using hashes here.

File details

Details for the file llama_index_graph_stores_aperturedb-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_graph_stores_aperturedb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39248a90a7fc376afeb61153fcc4f2d2919e0cfc9ee2c7edf57be2a9286dbafd
MD5 2ef9df76e7f0aa4a3162aacebd4782cc
BLAKE2b-256 9c5071f4fbfb25ba61c948b3feee7a0054040fea47ae9ea2c2aaebd04b389ed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page