jpcaparas / laravel-llamaparse-client
A Laravel library for interacting with Llamaparse Cloud API to parse PDF, XLS, and other file types into more efficient RAG context.
Requires
- php: ^8.1
- laravel/framework: ^9.0|^10.0|^11.0
Requires (Dev)
- laravel/pint: ^1.19
- orchestra/testbench: *
README
This package provides a Laravel library for interacting with the LlamaCloud Parsing & Transformation API (aka LlamaParse Cloud) to parse PDF, XLS, and other file types into more efficient RAG context for consumption into other systems.
Installation
You can install the package via Composer:
composer require jpcaparas/laravel-llamaparse-client
After installing the package, publish the configuration file:
php artisan vendor:publish --provider="JPCaparas\LLamaparse\LLamaparseServiceProvider"
Then, add your LlamaParse API key to your .env
file:
LLAMAPARSE_API_KEY=your-api-key
Usage
Here is an example of how to use the package with Laravel Tinker:
- Set a variable to a path of the file:
$filePath = 'path/to/your/file.pdf';
Hint: This PDF full of charts is a good resource to upload.
- Instantiate the service:
$llamaparse = app('llamaparse');
- Upload the file and get the job ID:
$response = $llamaparse->uploadFile($filePath); $jobId = $response['id'];
- Get the job status:
$jobStatus = $llamaparse->getJob($jobId);
- Get the job markdown result:
$markdownResult = $llamaparse->getJobResult($jobId); $textResult = $llamaparse->getJobTextResult($jobId);
Running Tests
To run the tests, use the following command:
composer test
API Reference
For a full API reference, please visit the LlamaCloud Parsing & Transformation API documentation.
License
MIT