From d6c270ec7af5ec14f67d03807bb59cec2a98c366 Mon Sep 17 00:00:00 2001
From: Alex Yang <himself65@outlook.com>
Date: Wed, 8 Jan 2025 11:23:48 -0800
Subject: [PATCH] feat(cloud): support pass project and org id to llama parse
 reader (#1594)

---
 .changeset/sharp-walls-marry.md |  5 +++++
 packages/cloud/src/reader.ts    | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 .changeset/sharp-walls-marry.md

diff --git a/.changeset/sharp-walls-marry.md b/.changeset/sharp-walls-marry.md
new file mode 100644
index 000000000..4244dfed0
--- /dev/null
+++ b/.changeset/sharp-walls-marry.md
@@ -0,0 +1,5 @@
+---
+"@llamaindex/cloud": patch
+---
+
+feat: support pass project and org id to llama parse reader
diff --git a/packages/cloud/src/reader.ts b/packages/cloud/src/reader.ts
index 3dea35c93..d8197e786 100644
--- a/packages/cloud/src/reader.ts
+++ b/packages/cloud/src/reader.ts
@@ -31,6 +31,8 @@ var process: any;
  * See https://github.com/run-llama/llama_parse
  */
 export class LlamaParseReader extends FileReader {
+  project_id?: string | undefined;
+  organization_id?: string | undefined;
   // The API key for the LlamaParse API. Can be set as an environment variable: LLAMA_CLOUD_API_KEY
   apiKey: string;
   // The base URL of the Llama Cloud Platform.
@@ -259,6 +261,10 @@ export class LlamaParseReader extends FileReader {
     const response = await uploadFileApiV1ParsingUploadPost({
       client: this.#client,
       throwOnError: true,
+      query: {
+        project_id: this.project_id ?? null,
+        organization_id: this.organization_id ?? null,
+      },
       signal: AbortSignal.timeout(this.maxTimeout * 1000),
       body,
     });
@@ -284,6 +290,10 @@ export class LlamaParseReader extends FileReader {
         path: {
           job_id: jobId,
         },
+        query: {
+          project_id: this.project_id ?? null,
+          organization_id: this.organization_id ?? null,
+        },
         signal,
       });
       const { data } = result;
@@ -300,6 +310,10 @@ export class LlamaParseReader extends FileReader {
               path: {
                 job_id: jobId,
               },
+              query: {
+                project_id: this.project_id ?? null,
+                organization_id: this.organization_id ?? null,
+              },
               signal,
             });
             break;
@@ -311,6 +325,10 @@ export class LlamaParseReader extends FileReader {
               path: {
                 job_id: jobId,
               },
+              query: {
+                project_id: this.project_id ?? null,
+                organization_id: this.organization_id ?? null,
+              },
               signal,
             });
             break;
@@ -322,6 +340,10 @@ export class LlamaParseReader extends FileReader {
               path: {
                 job_id: jobId,
               },
+              query: {
+                project_id: this.project_id ?? null,
+                organization_id: this.organization_id ?? null,
+              },
               signal,
             });
             break;
@@ -511,6 +533,10 @@ export class LlamaParseReader extends FileReader {
           job_id: jobId,
           name: imageName,
         },
+        query: {
+          project_id: this.project_id ?? null,
+          organization_id: this.organization_id ?? null,
+        },
       });
     if (response.error) {
       throw new Error(`Failed to download image: ${response.error.detail}`);
-- 
GitLab