Source code for langchain_community.graphs.graph_document
from __future__ import annotations
from typing import List, Union
from langchain_core.documents import Document
from langchain_core.load.serializable import Serializable
from langchain_core.pydantic_v1 import Field
[docs]class Node(Serializable):
"""代表图中具有关联属性的节点。
属性:
id (Union[str, int]): 节点的唯一标识符。
type (str): 节点的类型或标签,默认为"Node"。
properties (dict): 与节点关联的其他属性和元数据。"""
id: Union[str, int]
type: str = "Node"
properties: dict = Field(default_factory=dict)
[docs]class Relationship(Serializable):
"""代表图中两个节点之间的有向关系。
属性:
source (Node): 关系的源节点。
target (Node): 关系的目标节点。
type (str): 关系的类型。
properties (dict): 与关系相关的附加属性。"""
source: Node
target: Node
type: str
properties: dict = Field(default_factory=dict)
[docs]class GraphDocument(Serializable):
"""代表由节点和关系组成的图形文档。
属性:
nodes(List[Node]):图中节点的列表。
relationships(List[Relationship]):图中关系的列表。
source(Document):提取图形信息的文档。"""
nodes: List[Node]
relationships: List[Relationship]
source: Document