[Python] What is giving Azure document intelligence a TypeError?

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Azure Doc Intelligence to analyze PDFs. I am trying the code from here.

    Code:

    from azure.core.credentials import AzureKeyCredential
    from azure.ai.documentintelligence import DocumentIntelligenceClient
    from azure.ai.documentintelligence.models import AnalyzeOutputOption, AnalyzeResult

    endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
    key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

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

    with open(path_to_sample_documents, "rb") as f:
    poller = document_intelligence_client.begin_analyze_document(
    "prebuilt-read",
    body=f,
    output=[AnalyzeOutputOption.PDF],
    )
    result: AnalyzeResult = poller.result()
    operation_id = poller.details["operation_id"]

    response = document_intelligence_client.get_analyze_result_pdf(model_id=result.model_id, result_id=operation_id)
    with open("analyze_result.pdf", "wb") as writer:
    writer.writelines(response)


    I am getting TypeError as follows,


    TypeError: Session.request() got an unexpected keyword argument 'body'
    ​

    How can I resolve it?

    Continue reading...

Compartilhe esta Página