Issue with LlamaParse ... #355

Closed
opened 2026-02-16 00:17:37 -05:00 by yindo · 3 comments
Owner

Originally created by @cdupland on GitHub (Nov 26, 2024).

Describe the bug
Hello, I am using LlamaParse to get file content in LLM project on Huggingface.
It's globally works fine for documents, but for some ones, I have no complete extraction.
Parsing works perfectly on Llama CLoud, but not using Python library or API.
I don't understand why, if someone can help me.

Files
Bordeaux - Bergeracois - 2019.pdf

Job ID
Llama CLoud : 1cd4f687-030a-44a3-a5d2-9f868a5c7d8b
Python library : 8cae0c58-c21c-4081-8e99-68f016f33039

Client:

  • Python Library
  • API
  • Frontend (cloud.llamaindex.ai)

Additional context

Code with python library

def extract_(path):
    load_dotenv()
    api_key = os.environ.get("LLAMA_CLOUD_API_KEY")

    documents = LlamaParse(api_key=api_key,result_type="markdown").load_data(path)
    
    contents = ""
    for doc in documents:
        contents += doc.text

    return contents

Code with API

def extract(file_path):
    load_dotenv()
    api_key = os.environ.get("LLAMA_CLOUD_API_KEY")

    headers = {"Authorization": f"Bearer {api_key}"}
    base_url = "https://api.cloud.llamaindex.ai/api/parsing"

    with open(file_path, "rb") as f:
        mime_type = mimetypes.guess_type(file_path)[0]
        files = {"file": (f.name, f, mime_type)}

        # send the request, upload the file
        url = f"{base_url}/upload"
        response = requests.post(url, headers=headers, files=files)

    response.raise_for_status()
    # get the job id for the result_url
    job_id = response.json()["id"]
    print(f"obd : {job_id}")
    result_type = "markdown" # "text"  # or "markdown"
    result_url = f"{base_url}/job/{job_id}/result/{result_type}"

    # check for the result until its ready
    while True:
        response = requests.get(result_url, headers=headers)
        if response.status_code == 200:
            break

        time.sleep(2)

    print(response.json())
    # download the result
    result = response.json()
    output = result[result_type]

Result for Frontend (cloud.llamaindex.ai)

# RéférenciA

LE 10 NOVEMBRE

SECTEUR : VITICOLE (BORDEAUX - BERGERACOIS) - DATE : 2019

| INDICATEURS | RÉSULTATS | DONNÉES MAX | DONNÉES MIN |
|-------------|-----------|--------------|--------------|
| 1 HECTARES DE VIGNES EN PRODUCTION | 24,69 HA<br>6 DOSSIERS | 44,80 | 9,75 |
| 2 VOLUME RÉCOLTÉ DANS L'EXERCICE (HL) | 1 098,50 HL<br>6 DOSSIERS | 1 987,00 | 401,00 |
| 3 RÉCOLTE MOYENNE À L'HECTARE (EN HL) | 44,49 HL / HA<br>6 DOSSIERS | 56,31 | 23,43 |
| 4 PRIX DE REVIENT PAR HECTARE | 7 052,93 €<br>6 DOSSIERS | 9 492,43 | 3 251,38 |
| 5 PRIX DE REVIENT PAR HECTOLITRE | 158,54 €<br>6 DOSSIERS | 212,47 | 69,07 |
| 6 ENGRAIS HECTARE | 102,45 €<br>5 DOSSIERS | 158,65 | 22,20 |
| 7 PHYTO. HECTARE | 431,00 €<br>6 DOSSIERS | 494,23 | 243,38 |
| 8 MAIN D'OEUVRE CHARGÉE HECTARE | 4 518,64 €<br>5 DOSSIERS | 5 733,62 | 1 905,57 |
| 9 MAIN D'OEUVRE CHARGÉE HECTOLITRE RÉCOLTÉE | 100,66 €<br>5 DOSSIERS | 116,13 | 46,76 |
| 10 MAIN D'OEUVRE CHARGÉE À L'HECTOLITRE VEILLI DANS L'EXERCICE | 19,10 €<br>5 DOSSIERS | 118,97 | 5,15 |
| 11 COÛT BARRIQUES À L'HECTOLITRE VEILLI | 83,85 €<br>6 DOSSIERS | 115,88 | 15,86 |
| 12 COÛT BOUTEILLE 0,75L AU MILLE | 238,92 €<br>5 DOSSIERS | 254,65 | 191,27 |
| 13 COÛT BOUCHON AU MILLE | 175,91 €<br>5 DOSSIERS | 222,34 | 97,65 |
| 14 COÛT MISE TIRÉ-BOUCHÉ AU MILLE | 101,06 €<br>4 DOSSIERS | 200,10 | 60,13 |
| 15 CHARGES FINANCIÈRES À L'HECTARE | 539,50 €<br>5 DOSSIERS | 1 087,24 | 90,21 |
| 16 FRAIS GÉNÉRAUX ET COMMERCIAUX PAR HECTARE | 10 787,10 €<br>5 DOSSIERS | 19 436,57 | 4 570,07 |
| 17 FRAIS GÉNÉRAUX ET COMMERCIAUX PAR HECTOLITRE VENDU | 260,85 €<br>5 DOSSIERS | 695,23 | 108,03 |
| 18 PRIX DE VENTE MOYEN VRAC | 142,16 €<br>3 DOSSIERS | 185,43 | 110,12 |
| 19 PRIX DE VENTE MOYEN 0,75L | 3,49 €<br>6 DOSSIERS | 4,62 | 1,56 |
| 20 MARGE BRUTE / HECTARE | 2 880,96 €<br>5 DOSSIERS | 9 243,89 | -4 690,40 |
| 21 MARGE BRUTE / CA HT | -3,72 %<br>4 DOSSIERS | 43,72 | -32,34 |
| 22 POIDS DES ANNUITÉS SUR L'EBE | -97,96 %<br>6 DOSSIERS | 70,17 | -207,04 |

PAGE 1 / 2
---
| INDICATEURS | RÉSULTATS | DONNÉES MAX | DONNÉES MIN |
|-------------|-----------|--------------|--------------|
| 1 COUVERTURE DES DETTES À COURT TERME | 82,27 %<br>6 DOSSIERS | 837,29 | 26,16 |
| 2 AUTONOMIE FINANCIÈRE | 78,52 %<br>6 DOSSIERS | 93,55 | 17,63 |

PAGE 2 / 2

Results for API & Python library :

BSF# INDICATEURS

|INDICATEURS|RESULTATS|DONNEES MAX|DONNEES MIN|
|---|---|---|---|
|1 COUVERTURE DES DETTES A COURT TERME|82,27 %|837,29|26,16|
|2 AUTONOMIE FINANCIERE|78,52 %|93,55|17,63|

PAGE 2 / 2
Bordeaux - Bergeracois - 2019.pdf

Don't understand why there is difference between CLoud and API/Library.

Originally created by @cdupland on GitHub (Nov 26, 2024). **Describe the bug** Hello, I am using LlamaParse to get file content in LLM project on Huggingface. It's globally works fine for documents, but for some ones, I have no complete extraction. Parsing works perfectly on Llama CLoud, but not using Python library or API. I don't understand why, if someone can help me. **Files** [Bordeaux - Bergeracois - 2019.pdf](https://github.com/user-attachments/files/17916674/Bordeaux.-.Bergeracois.-.2019.pdf) **Job ID** Llama CLoud : 1cd4f687-030a-44a3-a5d2-9f868a5c7d8b Python library : 8cae0c58-c21c-4081-8e99-68f016f33039 **Client:** - Python Library - API - Frontend (cloud.llamaindex.ai) **Additional context** *Code with python library* ``` def extract_(path): load_dotenv() api_key = os.environ.get("LLAMA_CLOUD_API_KEY") documents = LlamaParse(api_key=api_key,result_type="markdown").load_data(path) contents = "" for doc in documents: contents += doc.text return contents ``` *Code with API* ``` def extract(file_path): load_dotenv() api_key = os.environ.get("LLAMA_CLOUD_API_KEY") headers = {"Authorization": f"Bearer {api_key}"} base_url = "https://api.cloud.llamaindex.ai/api/parsing" with open(file_path, "rb") as f: mime_type = mimetypes.guess_type(file_path)[0] files = {"file": (f.name, f, mime_type)} # send the request, upload the file url = f"{base_url}/upload" response = requests.post(url, headers=headers, files=files) response.raise_for_status() # get the job id for the result_url job_id = response.json()["id"] print(f"obd : {job_id}") result_type = "markdown" # "text" # or "markdown" result_url = f"{base_url}/job/{job_id}/result/{result_type}" # check for the result until its ready while True: response = requests.get(result_url, headers=headers) if response.status_code == 200: break time.sleep(2) print(response.json()) # download the result result = response.json() output = result[result_type] ``` Result for Frontend (cloud.llamaindex.ai) ``` # RéférenciA LE 10 NOVEMBRE SECTEUR : VITICOLE (BORDEAUX - BERGERACOIS) - DATE : 2019 | INDICATEURS | RÉSULTATS | DONNÉES MAX | DONNÉES MIN | |-------------|-----------|--------------|--------------| | 1 HECTARES DE VIGNES EN PRODUCTION | 24,69 HA<br>6 DOSSIERS | 44,80 | 9,75 | | 2 VOLUME RÉCOLTÉ DANS L'EXERCICE (HL) | 1 098,50 HL<br>6 DOSSIERS | 1 987,00 | 401,00 | | 3 RÉCOLTE MOYENNE À L'HECTARE (EN HL) | 44,49 HL / HA<br>6 DOSSIERS | 56,31 | 23,43 | | 4 PRIX DE REVIENT PAR HECTARE | 7 052,93 €<br>6 DOSSIERS | 9 492,43 | 3 251,38 | | 5 PRIX DE REVIENT PAR HECTOLITRE | 158,54 €<br>6 DOSSIERS | 212,47 | 69,07 | | 6 ENGRAIS HECTARE | 102,45 €<br>5 DOSSIERS | 158,65 | 22,20 | | 7 PHYTO. HECTARE | 431,00 €<br>6 DOSSIERS | 494,23 | 243,38 | | 8 MAIN D'OEUVRE CHARGÉE HECTARE | 4 518,64 €<br>5 DOSSIERS | 5 733,62 | 1 905,57 | | 9 MAIN D'OEUVRE CHARGÉE HECTOLITRE RÉCOLTÉE | 100,66 €<br>5 DOSSIERS | 116,13 | 46,76 | | 10 MAIN D'OEUVRE CHARGÉE À L'HECTOLITRE VEILLI DANS L'EXERCICE | 19,10 €<br>5 DOSSIERS | 118,97 | 5,15 | | 11 COÛT BARRIQUES À L'HECTOLITRE VEILLI | 83,85 €<br>6 DOSSIERS | 115,88 | 15,86 | | 12 COÛT BOUTEILLE 0,75L AU MILLE | 238,92 €<br>5 DOSSIERS | 254,65 | 191,27 | | 13 COÛT BOUCHON AU MILLE | 175,91 €<br>5 DOSSIERS | 222,34 | 97,65 | | 14 COÛT MISE TIRÉ-BOUCHÉ AU MILLE | 101,06 €<br>4 DOSSIERS | 200,10 | 60,13 | | 15 CHARGES FINANCIÈRES À L'HECTARE | 539,50 €<br>5 DOSSIERS | 1 087,24 | 90,21 | | 16 FRAIS GÉNÉRAUX ET COMMERCIAUX PAR HECTARE | 10 787,10 €<br>5 DOSSIERS | 19 436,57 | 4 570,07 | | 17 FRAIS GÉNÉRAUX ET COMMERCIAUX PAR HECTOLITRE VENDU | 260,85 €<br>5 DOSSIERS | 695,23 | 108,03 | | 18 PRIX DE VENTE MOYEN VRAC | 142,16 €<br>3 DOSSIERS | 185,43 | 110,12 | | 19 PRIX DE VENTE MOYEN 0,75L | 3,49 €<br>6 DOSSIERS | 4,62 | 1,56 | | 20 MARGE BRUTE / HECTARE | 2 880,96 €<br>5 DOSSIERS | 9 243,89 | -4 690,40 | | 21 MARGE BRUTE / CA HT | -3,72 %<br>4 DOSSIERS | 43,72 | -32,34 | | 22 POIDS DES ANNUITÉS SUR L'EBE | -97,96 %<br>6 DOSSIERS | 70,17 | -207,04 | PAGE 1 / 2 --- | INDICATEURS | RÉSULTATS | DONNÉES MAX | DONNÉES MIN | |-------------|-----------|--------------|--------------| | 1 COUVERTURE DES DETTES À COURT TERME | 82,27 %<br>6 DOSSIERS | 837,29 | 26,16 | | 2 AUTONOMIE FINANCIÈRE | 78,52 %<br>6 DOSSIERS | 93,55 | 17,63 | PAGE 2 / 2 ``` Results for API & Python library : ``` BSF# INDICATEURS |INDICATEURS|RESULTATS|DONNEES MAX|DONNEES MIN| |---|---|---|---| |1 COUVERTURE DES DETTES A COURT TERME|82,27 %|837,29|26,16| |2 AUTONOMIE FINANCIERE|78,52 %|93,55|17,63| PAGE 2 / 2 Bordeaux - Bergeracois - 2019.pdf ``` Don't understand why there is difference between CLoud and API/Library.
yindo added the bug label 2026-02-16 00:17:37 -05:00
yindo closed this issue 2026-02-16 00:17:37 -05:00
Author
Owner

@VolDonets commented on GitHub (Nov 27, 2024):

What parsing configurations have you used while parsed on the frontend?
I mean there is might be the issue. Cause results looks like inconsistent in the selected parsing method.
For example default in frontend is 'premium'-mode, but from Python lib 'accurate'-mode. Which by the way has different parsing accuracy.
image

@VolDonets commented on GitHub (Nov 27, 2024): What parsing configurations have you used while parsed on the frontend? I mean there is might be the issue. Cause results looks like inconsistent in the selected parsing method. For example default in frontend is 'premium'-mode, but from Python lib 'accurate'-mode. Which by the way has different parsing accuracy. ![image](https://github.com/user-attachments/assets/1afed73d-cea9-4b63-89ca-ff4f7f749b2b)
Author
Owner

@VolDonets commented on GitHub (Nov 27, 2024):

Also, try using vendor, for example some vendors like openai-gpt4o or genimini-1.5-pro or anthropic-sonnet-3.5 works much better when u need to parse tables compared to standard LlamaParse Solutions.

To use other vendor consider following code:

def extract_(path):
    load_dotenv()
    api_key = os.environ.get("LLAMA_CLOUD_API_KEY")

    documents = LlamaParse(
         api_key=api_key,
         result_type="markdown",
         use_vendor_multimodal_model=True,
         vendor_multimodal_model_name="openai-gpt4o",
    ).load_data(path)
    
    contents = ""
    for doc in documents:
        contents += doc.text

    return contents

To use premium mode:

def extract_(path):
    load_dotenv()
    api_key = os.environ.get("LLAMA_CLOUD_API_KEY")

    documents = LlamaParse(
         api_key=api_key,
         result_type="markdown",
         premium_mode=True,
    ).load_data(path)
    
    contents = ""
    for doc in documents:
        contents += doc.text

    return contents
@VolDonets commented on GitHub (Nov 27, 2024): Also, try using vendor, for example some vendors like `openai-gpt4o` or `genimini-1.5-pro` or `anthropic-sonnet-3.5` works much better when u need to parse tables compared to standard LlamaParse Solutions. To use other vendor consider following code: ``` def extract_(path): load_dotenv() api_key = os.environ.get("LLAMA_CLOUD_API_KEY") documents = LlamaParse( api_key=api_key, result_type="markdown", use_vendor_multimodal_model=True, vendor_multimodal_model_name="openai-gpt4o", ).load_data(path) contents = "" for doc in documents: contents += doc.text return contents ``` To use premium mode: ``` def extract_(path): load_dotenv() api_key = os.environ.get("LLAMA_CLOUD_API_KEY") documents = LlamaParse( api_key=api_key, result_type="markdown", premium_mode=True, ).load_data(path) contents = "" for doc in documents: contents += doc.text return contents ```
Author
Owner

@cdupland commented on GitHub (Nov 28, 2024):

Hi,

You all right 👍
It's works fine with premium_mode

Very big thanks

@cdupland commented on GitHub (Nov 28, 2024): Hi, You all right 👍 It's works fine with premium_mode Very big thanks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#355