Issue with LlamaParse ... #387

Open
opened 2026-02-16 00:17:42 -05:00 by yindo · 2 comments
Owner

Originally created by @krtarunsingh on GitHub (Dec 22, 2024).

Describe the bug
Write a concise description of what the bug is.

Files
If possible, please provide the PDF file causing the issue.

**Job ID-ada0e2fd-799d-4a2a-ba43-8a67ce4577fc

Client:
Please remove untested options:

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

Additional context
Add any additional context about the problem here.
What options did you use? Premium mode, multimodal, fast mode, parsing instructions, etc.
Screenshots, code snippets, etc.

Originally created by @krtarunsingh on GitHub (Dec 22, 2024). **Describe the bug** Write a concise description of what the bug is. **Files** If possible, please provide the PDF file causing the issue. **Job ID-ada0e2fd-799d-4a2a-ba43-8a67ce4577fc **Client:** Please remove untested options: - Python Library - API - Frontend (cloud.llamaindex.ai) - Typescript Library - Notebook **Additional context** Add any additional context about the problem here. What options did you use? Premium mode, multimodal, fast mode, parsing instructions, etc. Screenshots, code snippets, etc.
yindo added the bugLlamaCloud labels 2026-02-16 00:17:42 -05:00
Author
Owner

@apostolos-geyer commented on GitHub (Dec 26, 2024):

@krtarunsingh You should provide more information about the bug you are facing,

  • Stack traces, if any, from the Python library
  • Error message from the LlamaCloud UI
  • Your source code, your expected result, and the result you're seeing instead.

Otherwise, there is not much anyone can do for you here.

@apostolos-geyer commented on GitHub (Dec 26, 2024): @krtarunsingh You should provide more information about the bug you are facing, - Stack traces, if any, from the Python library - Error message from the LlamaCloud UI - Your source code, your expected result, and the result you're seeing instead. Otherwise, there is not much anyone can do for you here.
Author
Owner

@krtarunsingh commented on GitHub (Dec 27, 2024):

Image 2024-12-27 at 1 51 06 PM

below is the code

import os
from dotenv import load_dotenv
from rich import print
from llama_extract import LlamaExtract
import llama_cloud.core.api_error

Load the API key from .env file

load_dotenv()
api_key = os.getenv("LLAMA_CLOUD_API_KEY")

if not api_key:
raise ValueError("LLAMA_CLOUD_API_KEY is not set in the .env file. Please add it before proceeding.")

Initialize LlamaExtract with the API key

extractor = LlamaExtract(api_key=api_key)

Define schema for the bank statement

bank_statement_data_config = {
"type": "object",
"title": "BankStatementData",
"required": [
"account_holder_name", "account_number", "bank_name", "transactions"
],
"properties": {
"account_holder_name": {"type": "string", "title": "Account Holder Name"},
"account_number": {"type": "string", "title": "Account Number"},
"bank_name": {"type": "string", "title": "Bank Name"},
"statement_date": {"type": "string", "format": "date", "title": "Statement Date"},
"transactions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": {"type": "string", "format": "date", "title": "Transaction Date"},
"description": {"type": "string", "title": "Transaction Description"},
"transaction_type": {"type": "string", "title": "Transaction Type (Credit/Debit)"},
"amount": {"type": "number", "title": "Transaction Amount"},
"balance": {"type": "number", "title": "Balance After Transaction"}
},
"required": ["date", "description", "transaction_type", "amount", "balance"]
}
}
}
}

try:
# Create schema in LlamaExtract
extraction_schema = extractor.create_schema("InvoiceData Schema", bank_statement_data_config)
print("[green]Schema Created Successfully:[/green]", extraction_schema)

# Extract data using the created schema
results = extractor.extract(
    schema_id="652d91d5-cf0b-4ff4-bc23-98e6743b28c9",  # Use schema ID from creation
    file_input=[r"C:\Users\user\Downloads\Account_stmt_XX4259_27092024.pdf"]  # Updated to use the uploaded file path
)
print("[green]Extraction Successful! Results:[/green]")
print(results)

except llama_cloud.core.api_error.ApiError as e:
# Handle API-specific errors
print("[red]API Error Occurred:[/red]", e)
if e.body:
print("[red]Error Details:[/red]", e.body)

except Exception as e:
# Handle any other exceptions
print("[red]An unexpected error occurred:[/red]", e)

@krtarunsingh commented on GitHub (Dec 27, 2024): ![Image 2024-12-27 at 1 51 06 PM](https://github.com/user-attachments/assets/54dae137-9a87-4767-a8ac-651d43b03f14) below is the code import os from dotenv import load_dotenv from rich import print from llama_extract import LlamaExtract import llama_cloud.core.api_error # Load the API key from .env file load_dotenv() api_key = os.getenv("LLAMA_CLOUD_API_KEY") if not api_key: raise ValueError("LLAMA_CLOUD_API_KEY is not set in the .env file. Please add it before proceeding.") # Initialize LlamaExtract with the API key extractor = LlamaExtract(api_key=api_key) # Define schema for the bank statement bank_statement_data_config = { "type": "object", "title": "BankStatementData", "required": [ "account_holder_name", "account_number", "bank_name", "transactions" ], "properties": { "account_holder_name": {"type": "string", "title": "Account Holder Name"}, "account_number": {"type": "string", "title": "Account Number"}, "bank_name": {"type": "string", "title": "Bank Name"}, "statement_date": {"type": "string", "format": "date", "title": "Statement Date"}, "transactions": { "type": "array", "items": { "type": "object", "properties": { "date": {"type": "string", "format": "date", "title": "Transaction Date"}, "description": {"type": "string", "title": "Transaction Description"}, "transaction_type": {"type": "string", "title": "Transaction Type (Credit/Debit)"}, "amount": {"type": "number", "title": "Transaction Amount"}, "balance": {"type": "number", "title": "Balance After Transaction"} }, "required": ["date", "description", "transaction_type", "amount", "balance"] } } } } try: # Create schema in LlamaExtract extraction_schema = extractor.create_schema("InvoiceData Schema", bank_statement_data_config) print("[green]Schema Created Successfully:[/green]", extraction_schema) # Extract data using the created schema results = extractor.extract( schema_id="652d91d5-cf0b-4ff4-bc23-98e6743b28c9", # Use schema ID from creation file_input=[r"C:\Users\user\Downloads\Account_stmt_XX4259_27092024.pdf"] # Updated to use the uploaded file path ) print("[green]Extraction Successful! Results:[/green]") print(results) except llama_cloud.core.api_error.ApiError as e: # Handle API-specific errors print("[red]API Error Occurred:[/red]", e) if e.body: print("[red]Error Details:[/red]", e.body) except Exception as e: # Handle any other exceptions print("[red]An unexpected error occurred:[/red]", e)
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#387