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.1.0.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.1.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_graph_stores_aperturedb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af825266f885e329fe9f54861d52b4536ce00c3550a30889192ed4968b9d656c
MD5 c7fc538a0de36cfacce74763c367460f
BLAKE2b-256 dced8126f1cfc408c83a7745acfd649036f9d88bb032d689db44dd7bc6261b4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_graph_stores_aperturedb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22260f14c4dbc5b4cea3baa283131b1ab8692e466576b2490ec10315077708f9
MD5 09bda93a6a07fd85ee9a6c766ed7168d
BLAKE2b-256 bf5a0ff190db32d75e5f5d0113ba9187b32f99ec45b3eeda318dc789026fcd96

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