langchain_experimental.graph_transformers.diffbot.DiffbotGraphTransformer

class langchain_experimental.graph_transformers.diffbot.DiffbotGraphTransformer(diffbot_api_key: ~typing.Optional[str] = None, fact_confidence_threshold: float = 0.7, include_qualifiers: bool = True, include_evidence: bool = True, simplified_schema: bool = True, extract_types: ~typing.List[~langchain_experimental.graph_transformers.diffbot.TypeOption] = [<TypeOption.FACTS: 'facts'>], *, include_confidence: bool = False)[source]

将文档使用Diffbot NLP API转换为图文档。

图文档转换系统接受一系列文档,并返回一系列图文档。

示例:

初始化图转换器,并设置各种选项。

参数:
diffbot_api_key (str):

Diffbot的NLP服务的API密钥。

fact_confidence_threshold (float):

用于包含事实的最小置信水平。

include_qualifiers (bool):

是否在关系中包含限定词。

include_evidence (bool):

是否在关系中包含证据。

simplified_schema (bool):

是否使用简化的关系模式。

extract_types (List[TypeOption]):

要提取的数据类型列表。支持事实、实体和情感。默认情况下,选项设置为事实。事实表示具有关系类型的源节点和目标节点的组合。

include_confidence (bool):

是否在节点和关系上包含置信度分数。

Methods

__init__([diffbot_api_key, ...])

初始化图转换器,并设置各种选项。

convert_to_graph_documents(documents)

将一系列文档转换为图形文档。

nlp_request(text)

向Diffbot NLP端点发出API请求。

process_response(payload, document)

将Diffbot NLP响应转换为GraphDocument。

Parameters
  • diffbot_api_key (Optional[str]) –

  • fact_confidence_threshold (float) –

  • include_qualifiers (bool) –

  • include_evidence (bool) –

  • simplified_schema (bool) –

  • extract_types (List[TypeOption]) –

  • include_confidence (bool) –

Return type

None

__init__(diffbot_api_key: ~typing.Optional[str] = None, fact_confidence_threshold: float = 0.7, include_qualifiers: bool = True, include_evidence: bool = True, simplified_schema: bool = True, extract_types: ~typing.List[~langchain_experimental.graph_transformers.diffbot.TypeOption] = [<TypeOption.FACTS: 'facts'>], *, include_confidence: bool = False) None[source]

初始化图转换器,并设置各种选项。

参数:
diffbot_api_key (str):

Diffbot的NLP服务的API密钥。

fact_confidence_threshold (float):

用于包含事实的最小置信水平。

include_qualifiers (bool):

是否在关系中包含限定词。

include_evidence (bool):

是否在关系中包含证据。

simplified_schema (bool):

是否使用简化的关系模式。

extract_types (List[TypeOption]):

要提取的数据类型列表。支持事实、实体和情感。默认情况下,选项设置为事实。事实表示具有关系类型的源节点和目标节点的组合。

include_confidence (bool):

是否在节点和关系上包含置信度分数。

Parameters
  • diffbot_api_key (Optional[str]) –

  • fact_confidence_threshold (float) –

  • include_qualifiers (bool) –

  • include_evidence (bool) –

  • simplified_schema (bool) –

  • extract_types (List[TypeOption]) –

  • include_confidence (bool) –

Return type

None

convert_to_graph_documents(documents: Sequence[Document]) List[GraphDocument][source]

将一系列文档转换为图形文档。

参数:

documents(Sequence[Document]):原始文档。 **kwargs:额外的关键字参数。

返回:

Sequence[GraphDocument]:转换后的文档作为图形。

Parameters

documents (Sequence[Document]) –

Return type

List[GraphDocument]

nlp_request(text: str) Dict[str, Any][source]

向Diffbot NLP端点发出API请求。

参数:

text(str):要处理的文本。

返回:

Dict[str, Any]:API的JSON响应。

Parameters

text (str) –

Return type

Dict[str, Any]

process_response(payload: Dict[str, Any], document: Document) GraphDocument[source]

将Diffbot NLP响应转换为GraphDocument。

参数:

payload(Dict[str, Any]):来自Diffbot NLP API的JSON响应。 document(Document):原始文档。

返回:

GraphDocument:作为图形的转换文档。

Parameters
  • payload (Dict[str, Any]) –

  • document (Document) –

Return type

GraphDocument

Examples using DiffbotGraphTransformer