You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AzureAIDocumentIntelligenceLoader加载文件遇404错误求助

解决AzureAIDocumentIntelligenceLoader加载文件时的404错误

针对你遇到的ResourceNotFoundError,可以从以下几个方面排查解决:

1. 核对Endpoint和API密钥

  • 确保你使用的是Document Intelligence专属资源的Endpoint和密钥,不要混用其他Azure认知服务(如文本分析、计算机视觉)的凭证。登录Azure门户,找到你的Document Intelligence资源,在「密钥和终结点」页面核对信息。
  • 确认Endpoint的区域与资源创建区域完全一致,比如资源在eastus,Endpoint必须包含eastus标识,不能跨区域调用。

2. 验证API模型参数

  • 检查api_model参数拼写是否正确:prebuilt-layout是全小写加连字符,不能出现大小写错误或拼写错误(比如写成prebuilt_layout)。
  • 确认你的资源层级(如S0或F0)支持prebuilt-layout模型,免费层级F0也支持该模型,但如果资源被限制,可能无法调用。

3. 检查文件路径与权限

  • 确认文件路径D:/Python/xuexisucai/LLM/Coffe list.xlsx完全正确:文件实际存在,文件名拼写(包括Coffe是否应为Coffee)、空格和大小写与实际文件一致。
  • 验证Python进程对该文件有读取权限,可以先执行以下代码确认:
    import os
    print(os.path.exists("D:/Python/xuexisucai/LLM/Coffe list.xlsx"))
    
    如果输出False,说明路径错误或文件不存在。

4. 更新依赖包版本

旧版本的langchain-community或azure-ai-documentintelligence可能存在兼容性问题,执行以下命令更新到最新版本:

pip install --upgrade langchain-community azure-ai-documentintelligence

5. 排除LangChain封装问题

直接使用Azure官方SDK测试调用,确认服务本身是否正常:

from azure.core.credentials import AzureKeyCredential
from azure.ai.documentintelligence import DocumentIntelligenceClient

endpoint = "https://xxxxx.cognitiveservices.azure.com/"
key = "123456"
file_path = "D:/Python/xuexisucai/LLM/Coffe list.xlsx"

client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

with open(file_path, "rb") as f:
    poller = client.begin_analyze_document("prebuilt-layout", document=f)
result = poller.result()

print("分析成功:", result.documents)

如果这段代码也报404,说明问题出在Azure服务端(如资源未正确部署、区域不匹配);如果成功,说明LangChain的Loader存在参数或版本问题,建议更新后重试。

6. 确认Azure资源状态

登录Azure门户,检查你的Document Intelligence资源是否处于「运行中」状态,没有被暂停、删除或配额耗尽。

内容的提问来源于stack exchange,提问作者Renjie Tu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 11:52:32