我是编程新手。 我在使用 AzureAIDocumentIntelligenceLoade 加载 DOCX、XLSX、PPTX 时遇到问题 我已经成功创建了Document Intelligence并获得了“端点”和“密钥”。 然而,当我尝试在Python环境中通过langchain_community加载xlsx文档时,我的电脑报告如下:
azure.core.exceptions.ResourceNotFoundError: (404) Resource not found Code: 404 Message: Resource not found
这是我的代码片段:
`file = "D:/Python/xuexisucai/LLM/Coffe list.xlsx"
endpoint = "https://xxxxx.cognitiveservices.azure.com/"
key = "123456"
loader = AzureAIDocumentIntelligenceLoader(
api_endpoint= endpoint, api_key= key, file_path=file, api_model= "prebuilt-layout"
)
documents = loader.load()`
哪位高手可以来帮助一下这个新手?
由于详细信息
Endpoint、Key和文档路径无效而发生错误
ResourceNotFoundError
。
根据Document,文档智能布局模型支持分析 XLSX 文件,确保准确提取文本、表格、图形和层次结构。
XLSX 文档可以使用此模型进行有效处理,需要清晰的照片或高质量的扫描以获得最佳结果。
开发选项包括利用 Document Intelligence Studio、REST API 和 SDK。
输出组件包括段落,其中提取标题、章节标题和脚注等文本块,以及表格,解析表格以确定列和行信息。
from azure.core.credentials import AzureKeyCredential
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.ai.documentintelligence.models import AnalyzeResult
endpoint = "DOCUMENTINTELLIGENCE_ENDPOINT"
key = "DOCUMENTINTELLIGENCE_API_KEY"
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
# Path to your XLSX file
path_to_xlsx_file = "C://Users//file_example_XLSX_101.xlsx"
# Open the XLSX file as a binary read mode
with open(path_to_xlsx_file, "rb") as f:
poller = document_intelligence_client.begin_analyze_document(
"prebuilt-layout", analyze_request=f, content_type="application/octet-stream"
)
result: AnalyzeResult = poller.result()
# Process the analysis result
for page in result.pages:
print(f"----Analyzing layout from page #{page.page_number}----")
print(f"Page has Pageitems: {page.items} and page_number: {page.page_number}, ")
输出: