langchain_community.graphs.memgraph_graph
.MemgraphGraph¶
- class langchain_community.graphs.memgraph_graph.MemgraphGraph(url: str, username: str, password: str, *, database: str = 'memgraph')[source]¶
Memgraph图操作的包装器。
- 安全提示: 确保数据库连接使用的凭据范围狭窄,仅包括必要的权限。
如果未这样做,可能会导致数据损坏或丢失,因为调用代码可能尝试执行会导致删除、变异数据(如果适当提示)或读取敏感数据(如果数据库中存在此类数据)的命令。 防范这些负面结果的最佳方法是(根据需要)限制授予此工具使用的凭据的权限。
有关更多信息,请参见 https://python.langchain.com/docs/security。
创建一个新的Memgraph图包装实例。
Attributes
get_schema
返回图的模式
get_structured_schema
返回图的结构化模式
Methods
__init__
(url, username, password, *[, database])创建一个新的Memgraph图包装实例。
add_graph_documents
(graph_documents[, ...])该方法根据提供的GraphDocument对象在图中构建节点和关系。
query
(query[, params])查询Neo4j数据库。
刷新Memgraph图模式信息。
- Parameters
url (str) –
username (str) –
password (str) –
database (str) –
- Return type
None
- __init__(url: str, username: str, password: str, *, database: str = 'memgraph') None [source]¶
创建一个新的Memgraph图包装实例。
- Parameters
url (str) –
username (str) –
password (str) –
database (str) –
- Return type
None
- add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False, baseEntityLabel: bool = False) None ¶
该方法根据提供的GraphDocument对象在图中构建节点和关系。
参数: - graph_documents(List[GraphDocument]):包含要添加到图中的节点和关系的GraphDocument对象列表。每个GraphDocument应该封装图的一部分的结构,包括节点、关系和源文档信息。 - include_source(bool,可选):如果为True,则存储源文档并使用MENTIONS关系将其链接到图中的节点。这对于追溯数据的来源很有用。根据源文档元数据中的`id`属性合并源文档(如果可用);否则,根据`page_content`的MD5哈希计算合并过程。默认为False。 - baseEntityLabel(bool,可选):如果为True,则每个新创建的节点都会获得一个次要的__Entity__标签,该标签被索引并提高了导入速度和性能。默认为False。
- Parameters
graph_documents (List[GraphDocument]) –
include_source (bool) –
baseEntityLabel (bool) –
- Return type
None
- query(query: str, params: dict = {}) List[Dict[str, Any]] ¶
查询Neo4j数据库。
- Parameters
query (str) –
params (dict) –
- Return type
List[Dict[str, Any]]