From 43474a51fff111e7e3ed0916d4769f9bf9e27f9b Mon Sep 17 00:00:00 2001
From: Thuc Pham <51660321+thucpn@users.noreply.github.com>
Date: Mon, 29 Jul 2024 15:20:18 +0700
Subject: [PATCH] feat: config llamacloud organization ID (#192)

---------
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
---
 .changeset/bright-snails-drive.md                            | 5 +++++
 helpers/env-variables.ts                                     | 5 +++++
 helpers/python.ts                                            | 2 +-
 templates/components/vectordbs/python/llamacloud/generate.py | 2 ++
 templates/components/vectordbs/python/llamacloud/index.py    | 2 ++
 templates/types/streaming/fastapi/pyproject.toml             | 2 +-
 6 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 .changeset/bright-snails-drive.md

diff --git a/.changeset/bright-snails-drive.md b/.changeset/bright-snails-drive.md
new file mode 100644
index 00000000..66a9a0b0
--- /dev/null
+++ b/.changeset/bright-snails-drive.md
@@ -0,0 +1,5 @@
+---
+"create-llama": patch
+---
+
+Configure LlamaCloud organization ID for Python
diff --git a/helpers/env-variables.ts b/helpers/env-variables.ts
index ef232834..bb04a753 100644
--- a/helpers/env-variables.ts
+++ b/helpers/env-variables.ts
@@ -155,6 +155,11 @@ const getVectorDBEnvs = (
             "The base URL for the LlamaCloud API. Only change this for non-production environments",
           value: "https://api.cloud.llamaindex.ai",
         },
+        {
+          name: "LLAMA_CLOUD_ORGANIZATION_ID",
+          description:
+            "The organization ID for the LlamaCloud project (uses default organization if not specified - Python only)",
+        },
       ];
     case "chroma":
       const envs = [
diff --git a/helpers/python.ts b/helpers/python.ts
index 3092bdbd..095c1a0a 100644
--- a/helpers/python.ts
+++ b/helpers/python.ts
@@ -121,7 +121,7 @@ const getAdditionalDependencies = (
         case "llamacloud":
           dependencies.push({
             name: "llama-index-indices-managed-llama-cloud",
-            version: "^0.2.5",
+            version: "^0.2.7",
           });
           break;
       }
diff --git a/templates/components/vectordbs/python/llamacloud/generate.py b/templates/components/vectordbs/python/llamacloud/generate.py
index f494941a..8bcf6068 100644
--- a/templates/components/vectordbs/python/llamacloud/generate.py
+++ b/templates/components/vectordbs/python/llamacloud/generate.py
@@ -21,6 +21,7 @@ def generate_datasource():
     project_name = os.getenv("LLAMA_CLOUD_PROJECT_NAME")
     api_key = os.getenv("LLAMA_CLOUD_API_KEY")
     base_url = os.getenv("LLAMA_CLOUD_BASE_URL")
+    organization_id = os.getenv("LLAMA_CLOUD_ORGANIZATION_ID")
 
     if name is None or project_name is None or api_key is None:
         raise ValueError(
@@ -40,6 +41,7 @@ def generate_datasource():
         project_name=project_name,
         api_key=api_key,
         base_url=base_url,
+        organization_id=organization_id
     )
 
     logger.info("Finished generating the index")
diff --git a/templates/components/vectordbs/python/llamacloud/index.py b/templates/components/vectordbs/python/llamacloud/index.py
index 160a20c6..da73434f 100644
--- a/templates/components/vectordbs/python/llamacloud/index.py
+++ b/templates/components/vectordbs/python/llamacloud/index.py
@@ -11,6 +11,7 @@ def get_index():
     project_name = os.getenv("LLAMA_CLOUD_PROJECT_NAME")
     api_key = os.getenv("LLAMA_CLOUD_API_KEY")
     base_url = os.getenv("LLAMA_CLOUD_BASE_URL")
+    organization_id = os.getenv("LLAMA_CLOUD_ORGANIZATION_ID")
 
     if name is None or project_name is None or api_key is None:
         raise ValueError(
@@ -23,6 +24,7 @@ def get_index():
         project_name=project_name,
         api_key=api_key,
         base_url=base_url,
+        organization_id=organization_id
     )
 
     return index
diff --git a/templates/types/streaming/fastapi/pyproject.toml b/templates/types/streaming/fastapi/pyproject.toml
index c669162e..e897faff 100644
--- a/templates/types/streaming/fastapi/pyproject.toml
+++ b/templates/types/streaming/fastapi/pyproject.toml
@@ -14,7 +14,7 @@ fastapi = "^0.109.1"
 uvicorn = { extras = ["standard"], version = "^0.23.2" }
 python-dotenv = "^1.0.0"
 aiostream = "^0.5.2"
-llama-index = "0.10.55"
+llama-index = "0.10.58"
 cachetools = "^5.3.3"
 
 [build-system]
-- 
GitLab