类型

RawSearchResult (原始搜索结果)

class neo4j_graphrag.types.RawSearchResult(*, records, metadata=None)[source]

表示从检索器的 get_search_result 方法返回的原始结果。在作为 RetrieverResult 返回之前,需要对其进行进一步格式化。

参数:
records

来自 Neo4j 的记录列表。

类型:

list[neo4j.Record]

metadata

与记录相关的元数据,例如得分(score)。

类型:

dict[str, Any] | None

RetrieverResult (检索器结果)

class neo4j_graphrag.types.RetrieverResult(*, items, metadata=None)[source]

表示从检索器返回的结果。

参数:
items

检索到的项目列表。

类型:

list[RetrieverResultItem]

metadata

与上下文相关的元数据,例如 Text2CypherRetriever 中生成的 Cypher 查询。

类型:

dict[str, Any] | None

RetrieverResultItem (检索器结果项)

class neo4j_graphrag.types.RetrieverResultItem(*, content, metadata=None)[source]

从检索器返回的单个记录。

参数:
content

将提供给大模型的上下文。

类型:

str

metadata

可以与文本一起包含的任何与该记录相关的元数据(例如,另一个节点属性)。

类型:

Optional[dict]

LLMResponse (大模型响应)

class neo4j_graphrag.llm.types.LLMResponse(*, content)[source]
参数:

content (str)

LLMMessage (大模型消息)

class neo4j_graphrag.types.LLMMessage[source]

RagResultModel (RAG 结果模型)

class neo4j_graphrag.generation.types.RagResultModel(*, answer, retriever_result=None)[source]
参数:

DocumentInfo (文档信息)

class neo4j_graphrag.experimental.components.types.DocumentInfo(*, path, metadata=None, uid=<factory>, document_type=None)[source]

由 DataLoader 加载的文档。

参数:
path

文档路径。

类型:

str

metadata

与此文档相关的元数据。

类型:

Optional[dict[str, Any]]

uid

此文档的唯一标识符。

类型:

str

TextChunk (文本块)

class neo4j_graphrag.experimental.components.types.TextChunk(*, text, index, metadata=None, uid=<factory>)[source]

由文本拆分器从文档中拆分出的文本块。

参数:
text

原始文本块。

类型:

str

index

此块在原始文档中的位置。

类型:

int

metadata

与此块相关的元数据。

类型:

Optional[dict[str, Any]]

uid

此块的唯一标识符。

类型:

str

TextChunks (文本块集合)

class neo4j_graphrag.experimental.components.types.TextChunks(*, chunks)[source]

由文本拆分器返回的文本块集合。

参数:

chunks (list[TextChunk])

chunks

文本块列表。

类型:

list[TextChunk]

Neo4jNode (Neo4j 节点)

class neo4j_graphrag.experimental.components.types.Neo4jNode(*, id, label, properties=<factory>, embedding_properties=<factory>)[source]

表示一个 Neo4j 节点。

参数:
id

节点的 ID。此 ID 用于在创建关系时引用该节点。

类型:

str

label

节点的标签。

类型:

str

properties

附加到节点的属性字典。

类型:

dict[str, PropertyValue]

embedding_properties

附加到节点的嵌入属性字典。

类型:

dict[str, list[float]]

Neo4jRelationship (Neo4j 关系)

class neo4j_graphrag.experimental.components.types.Neo4jRelationship(*, start_node_id, end_node_id, type, properties=<factory>, embedding_properties=<factory>)[source]

表示一个 Neo4j 关系。

参数:
start_node_id

起始节点的 ID。

类型:

str

end_node_id

结束节点的 ID。

类型:

str

type

关系类型。

类型:

str

properties

附加到关系的属性字典。

类型:

dict[str, PropertyValue]

embedding_properties

附加到关系的嵌入属性字典。

类型:

dict[str, list[float]]

Neo4jGraph (Neo4j 图)

class neo4j_graphrag.experimental.components.types.Neo4jGraph(*, nodes=<factory>, relationships=<factory>)[source]

表示一个 Neo4j 图。

参数:
nodes

图中节点的列表。

类型:

list[Neo4jNode]

relationships

图中关系的列表。

类型:

list[Neo4jRelationship]

GeoPoint (地理坐标点)

class neo4j_graphrag.experimental.components.types.GeoPoint(*, latitude, longitude, height)[source]

表示具有纬度、经度和高度的地理点。

参数:
latitude

纬度坐标。

类型:

float

longitude

经度坐标。

类型:

float

height

高度/海拔坐标。

类型:

float

KGWriterModel (知识图谱写入模型)

class neo4j_graphrag.experimental.components.kg_writer.KGWriterModel(*, status, metadata=None)[source]

知识图谱写入器的输出数据模型。

参数:
status

写入操作是否成功(“SUCCESS” 或 “FAILURE”)。

类型:

Literal[‘SUCCESS’, ‘FAILURE’]

metadata

可选字典。当 status 为 SUCCESS 时,至少包含:- “statistics”:包含 node_count(节点数)、relationship_count(关系数)、nodes_per_label(每个标签的节点数)、

rel_per_type(每个类型的关系数)、input_files_count(输入文件数)、input_files_total_size_bytes(输入文件总大小)。

  • “files”:包含文件路径等的文件描述符列表(ParquetWriter)。

类型:

dict[str, Any] | None

PropertyType (属性类型)

class neo4j_graphrag.experimental.components.schema.PropertyType(*, name, type, description='', required=False)[source]

表示图中节点或关系上的属性。

参数:
  • name (str)

  • type (Literal['BOOLEAN', 'DATE', 'DURATION', 'FLOAT', 'INTEGER', 'LIST', 'LOCAL_DATETIME', 'LOCAL_TIME', 'POINT', 'STRING', 'ZONED_DATETIME', 'ZONED_TIME'])

  • description (str)

  • required (bool)

NodeType (节点类型)

class neo4j_graphrag.experimental.components.schema.NodeType(*, label, description='', properties=<factory>, additional_properties=<factory>)[source]

表示图中的一种潜在节点。

参数:

RelationshipType (关系类型)

class neo4j_graphrag.experimental.components.schema.RelationshipType(*, label, description='', properties=[], additional_properties=<factory>)[source]

表示图中节点之间的一种潜在关系。

参数:

Pattern (模式)

class neo4j_graphrag.experimental.components.schema.Pattern(*, source, relationship, target)[source]

表示图架构中的关系模式。

此模型通过辅助方法(__iter__、__getitem__、__eq__、__hash__)提供与基于元组的模式的向后兼容性。

参数:
  • source (str)

  • relationship (str)

  • target (str)

GraphSchema (图架构)

class neo4j_graphrag.experimental.components.schema.GraphSchema(*, node_types, relationship_types=(), patterns=(), constraints=(), additional_node_types=<factory>, additional_relationship_types=<factory>, additional_patterns=<factory>)[source]

此模型表示图中预期的节点和关系类型。

它既用于在实体和关系提取组件中引导大模型,也用于在后处理步骤中清理提取的图。

警告

此模型是不可变的。

参数:

LexicalGraphConfig (词法图配置)

class neo4j_graphrag.experimental.components.types.LexicalGraphConfig(*, id_prefix='', document_node_label='Document', chunk_node_label='Chunk', chunk_to_document_relationship_type='FROM_DOCUMENT', next_chunk_relationship_type='NEXT_CHUNK', node_to_chunk_relationship_type='FROM_CHUNK', chunk_id_property='id', chunk_index_property='index', chunk_text_property='text', chunk_embedding_property='embedding')[source]

配置词法图中的所有标签和属性名称。

参数:
  • id_prefix (str)

  • document_node_label (str)

  • chunk_node_label (str)

  • chunk_to_document_relationship_type (str)

  • next_chunk_relationship_type (str)

  • node_to_chunk_relationship_type (str)

  • chunk_id_property (str)

  • chunk_index_property (str)

  • chunk_text_property (str)

  • chunk_embedding_property (str)

Neo4jDriverType (Neo4j 驱动类型)

class neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverType(root=PydanticUndefined)[source]

用于包装 neo4j.Driver 和 Neo4jDriverConfig 对象的模型。

`parse` 方法始终返回 neo4j.Driver。

参数:

root (Driver | Neo4jDriverConfig)

Neo4jDriverConfig (Neo4j 驱动配置)

class neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverConfig(*, class_=None, params_={})[source]
参数:

LLMType (大模型类型)

class neo4j_graphrag.experimental.pipeline.config.object_config.LLMType(root=PydanticUndefined)[source]

用于包装 LLMInterface 和 LLMConfig 对象的模型。

`parse` 方法始终返回继承自 LLMInterface 的对象。

参数:

root (LLMInterface | LLMConfig)

LLMConfig (大模型配置)

class neo4j_graphrag.experimental.pipeline.config.object_config.LLMConfig(*, class_=None, params_={})[source]

任何 LLMInterface 对象的配置。

默认情况下,将尝试从 `neo4j_graphrag.llm` 导入。

参数:

EmbedderType (嵌入器类型)

class neo4j_graphrag.experimental.pipeline.config.object_config.EmbedderType(root=PydanticUndefined)[source]

用于包装 Embedder 和 EmbedderConfig 对象的模型。

`parse` 方法始终返回继承自 Embedder 的对象。

参数:

root (Embedder | EmbedderConfig)

EmbedderConfig (嵌入器配置)

class neo4j_graphrag.experimental.pipeline.config.object_config.EmbedderConfig(*, class_=None, params_={})[source]

任何 Embedder 对象的配置。

默认情况下,将尝试从 `neo4j_graphrag.embeddings` 导入。

参数:

ComponentType (组件类型)

class neo4j_graphrag.experimental.pipeline.config.object_config.ComponentType(root=PydanticUndefined)[source]
参数:

root (Component | ComponentConfig)

ComponentConfig (组件配置)

class neo4j_graphrag.experimental.pipeline.config.object_config.ComponentConfig(*, class_=None, params_={}, run_params_={})[source]

所有组件的配置模型。

除了对象配置外,组件还可以拥有预定义的参数,这些参数将传递给 `run` 方法,即 `run_params_`。

参数:

ParamFromEnvConfig (来自环境变量的参数配置)

class neo4j_graphrag.experimental.pipeline.config.param_resolver.ParamFromEnvConfig(*, resolver_=ParamResolverEnum.ENV, var_)[source]
参数:
  • resolver_ (Literal[ParamResolverEnum.ENV])

  • var_ (str)

EventType (事件类型)

enum neo4j_graphrag.experimental.pipeline.notification.EventType(value)[source]

有效值如下:

PIPELINE_STARTED = <EventType.PIPELINE_STARTED: 'PIPELINE_STARTED'>
TASK_STARTED = <EventType.TASK_STARTED: 'TASK_STARTED'>
TASK_PROGRESS = <EventType.TASK_PROGRESS: 'TASK_PROGRESS'>
TASK_FINISHED = <EventType.TASK_FINISHED: 'TASK_FINISHED'>
PIPELINE_FINISHED = <EventType.PIPELINE_FINISHED: 'PIPELINE_FINISHED'>
PIPELINE_FAILED = <EventType.PIPELINE_FAILED: 'PIPELINE_FAILED'>

PipelineEvent (流水线事件)

class neo4j_graphrag.experimental.pipeline.notification.PipelineEvent(*, event_type, run_id, timestamp=<factory>, message=None, payload=None)[source]
参数:

TaskEvent (任务事件)

class neo4j_graphrag.experimental.pipeline.notification.TaskEvent(*, event_type, run_id, timestamp=<factory>, message=None, payload=None, task_name)[source]
参数:

EventCallbackProtocol (事件回调协议)

class neo4j_graphrag.experimental.pipeline.notification.EventCallbackProtocol(*args, **kwargs)[source]

此协议用于从流水线本身发送有关流水线进度的事件。它将根据事件类型接收 PipelineEvent 或 TaskEvent。

__call__(event)[source]

像函数一样调用 self。

参数:

event (Event)

返回类型:

Awaitable[None]

TaskProgressCallbackProtocol (任务进度回调协议)

class neo4j_graphrag.experimental.pipeline.types.context.TaskProgressNotifierProtocol(*args, **kwargs)[source]

此协议用于将事件从组件发送到流水线回调协议。发送到回调的事件将是 TaskEvent 类型,其 `event_type=TASK_PROGRESS`。

__call__(message, data)[source]

像函数一样调用 self。

参数:
返回类型:

Awaitable[None]

RunContext (运行上下文)

class neo4j_graphrag.experimental.pipeline.types.context.RunContext(*, run_id, task_name, notifier=None)[source]

传递给组件的上下文。

参数:
© . This site is unofficial and not affiliated with Neo4j, Inc.