langchain_community.document_transformers.doctran_text_extract
.DoctranPropertyExtractor¶
- class langchain_community.document_transformers.doctran_text_extract.DoctranPropertyExtractor(properties: List[dict], openai_api_key: Optional[str] = None, openai_api_model: Optional[str] = None)[source]¶
使用doctran从文本文档中提取属性。
- 参数
properties (列表[字典]) – 要提取的属性列表。
openai_api_key (可选[字符串]) – OpenAI API密钥。也可以通过环境变量
OPENAI_API_KEY
指定。openai_api_model (可选[字符串]) –
示例
from langchain_community.document_transformers import DoctranPropertyExtractor properties = [ { "name": "category", "description": "What type of email this is.", "type": "string", "enum": ["update", "action_item", "customer_feedback", "announcement", "other"], "required": True, }, { "name": "mentions", "description": "A list of all people mentioned in this email.", "type": "array", "items": { "name": "full_name", "description": "The full name of the person mentioned.", "type": "string", }, "required": True, }, { "name": "eli5", "description": "Explain this email to me like I'm 5 years old.", "type": "string", "required": True, }, ] # Pass in openai_api_key or set env var OPENAI_API_KEY property_extractor = DoctranPropertyExtractor(properties) transformed_document = await qa_transformer.atransform_documents(documents)
方法
__init__
(properties[, openai_api_key, ...])atransform_documents
(documents, **kwargs)使用doctran从文本文档中提取属性。
transform_documents
(documents, **kwargs)使用doctran从文本文档中提取属性。
- __init__(properties: List[dict], openai_api_key: Optional[str] = None, openai_api_model: Optional[str] = None) None [source]¶
- 参数
properties (列表[字典]) –
openai_api_key (可选[字符串]) –
openai_api_model (可选[字符串]) –
- 返回类型
None