Skip to main content
Azure Cosmos DB for Apache Gremlin is a graph database service that can be used to store massive graphs with billions of vertices and edges. You can query the graphs with millisecond latency and evolve the graph structure easily. Gremlin is a graph traversal language and virtual machine developed by Apache TinkerPop of the Apache Software Foundation.
This notebook shows how to use LLMs to provide a natural language interface to a graph database you can query with the Gremlin query language.

Setting up

Install a library:
You will need an Azure CosmosDB Graph database instance. One option is to create a free CosmosDB Graph database instance in Azure. When you create your Cosmos DB account and Graph, use /type as a partition key.

Seeding the database

Assuming your database is empty, you can populate it using the GraphDocuments For Gremlin, always add property called ‘label’ for each Node. If no label is set, Node.type is used as a label. For cosmos using natural id’s make sense, as they are visible in the graph explorer.

Refresh graph schema information

If the schema of database changes (after updates), you can refresh the schema information.

Querying the graph

We can now use the gremlin QA chain to ask question of the graph