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 是由 Apache TinkerPop of the Apache Software Foundation.
本 notebook 展示如何使用 LLMs to provide a 自然语言 interface to a graph database you can query with the Gremlin query language.

设置

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.

填充数据库

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.

刷新图 Schema 信息

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

查询图

我们现在可以使用 gremlin QA chain 来查询图