Skip to content

jpcaparas/laravel-llamaparse-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel LlamaParse Cloud API Client

Tests

image

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:

  1. 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.

  1. Instantiate the service:
$llamaparse = app('llamaparse');
  1. Upload the file and get the job ID:
$response = $llamaparse->uploadFile($filePath);
$jobId = $response['id'];
  1. Get the job status:
$jobStatus = $llamaparse->getJob($jobId);
  1. 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