Skip to content

Bug when using Extract API #1055

@bwprado

Description

@bwprado

Bug Report: Body is unusable: Body has already been read

Describe the Bug

When attempting to extract data from a PDF file using the extract method of the llama-cloud-services Typescript library, the API returns the error:
TypeError: Body is unusable: Body has already been read.

This suggests that the body stream is being consumed multiple times during the request, which prevents successful processing of the file.


Files

Unfortunately, I cannot attach the specific PDF file here, but the issue occurs consistently with any valid PDF file uploaded.


Job ID

I do not have the specific Job ID, as the request fails before completion. However, the issue can be reproduced by running any extraction job with the provided code.


Client

  • Typescript Library

Additional Context

Options Used:

  • Extraction Target: PER_DOC
  • Extraction Mode: BALANCED
  • Extract Model: openai-gpt-4-1
  • Multimodal Fast Mode: false
  • High Resolution Mode: true
  • System Prompt: Custom instructions to extract transactions from the document.

Code Snippet:

Here is the relevant code used to call the extract method:

const arrayBuffer = await file.arrayBuffer();
const uint8Array = new Uint8Array(arrayBuffer);
const result = await extractor.extract(statementSchema, config, undefined, uint8Array, file.name);

Error Message:

TypeError: Body is unusable: Body has already been read
    at uploadFile (C:\wip\cookies\.next\dev\server\chunks\ssr\82481_llama-cloud-services_24c288ef._.js:5254:57)
    at async Module.extractStateless (C:\wip\cookies\.next\dev\server\chunks\ssr\82481_llama-cloud-services_24c288ef._.js:5524:20)
    at async LlamaExtract.extract (C:\wip\cookies\.next\dev\server\chunks\ssr\82481_llama-cloud-services_24c288ef._.js:6988:16)

This issue appears to be a bug in the API or the Typescript library, as the body stream should not be consumed multiple times during the request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions