From efa326a871eb979c3330631ce6ddc8c7f0128a45 Mon Sep 17 00:00:00 2001
From: Alex Yang <himself65@outlook.com>
Date: Sun, 5 May 2024 18:30:46 -0500
Subject: [PATCH] chore: update package.json and usage of lodash (#809)

---
 .changeset/cold-pumas-join.md      |  6 ++++++
 .changeset/thick-terms-nail.md     |  5 +++++
 packages/core/package.json         | 16 ++++++++++++++++
 packages/env/README.md             |  7 +++++++
 packages/env/package.json          | 19 +++++++++++++++++--
 packages/env/src/index.polyfill.ts |  7 +++++++
 packages/env/src/type.ts           |  8 +++-----
 pnpm-lock.yaml                     |  3 ---
 8 files changed, 61 insertions(+), 10 deletions(-)
 create mode 100644 .changeset/cold-pumas-join.md
 create mode 100644 .changeset/thick-terms-nail.md
 create mode 100644 packages/env/README.md

diff --git a/.changeset/cold-pumas-join.md b/.changeset/cold-pumas-join.md
new file mode 100644
index 000000000..12dd40bff
--- /dev/null
+++ b/.changeset/cold-pumas-join.md
@@ -0,0 +1,6 @@
+---
+"llamaindex": patch
+"@llamaindex/env": patch
+---
+
+chore: update package.json
diff --git a/.changeset/thick-terms-nail.md b/.changeset/thick-terms-nail.md
new file mode 100644
index 000000000..45005f514
--- /dev/null
+++ b/.changeset/thick-terms-nail.md
@@ -0,0 +1,5 @@
+---
+"@llamaindex/env": patch
+---
+
+refactor: remove usage of lodash
diff --git a/packages/core/package.json b/packages/core/package.json
index 98ee926b0..5a2d23b18 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -4,6 +4,22 @@
   "expectedMinorVersion": "3",
   "license": "MIT",
   "type": "module",
+  "keywords": [
+    "llm",
+    "llama",
+    "openai",
+    "gpt",
+    "data science",
+    "prompt",
+    "prompt engineering",
+    "chatgpt",
+    "machine learning",
+    "ml",
+    "embedding",
+    "vectorstore",
+    "data framework",
+    "llamaindex"
+  ],
   "dependencies": {
     "@anthropic-ai/sdk": "^0.20.6",
     "@aws-crypto/sha256-js": "^5.2.0",
diff --git a/packages/env/README.md b/packages/env/README.md
new file mode 100644
index 000000000..c5b318155
--- /dev/null
+++ b/packages/env/README.md
@@ -0,0 +1,7 @@
+# @llamaindex/env
+
+> Environment wrapper, supports all JS environment including node, deno, bun, edge runtime, and cloudflare worker.
+
+## LICENSE
+
+MIT
diff --git a/packages/env/package.json b/packages/env/package.json
index 7d415e8a8..b352d2da3 100644
--- a/packages/env/package.json
+++ b/packages/env/package.json
@@ -5,6 +5,22 @@
   "type": "module",
   "types": "dist/type/index.d.ts",
   "main": "dist/cjs/index.js",
+  "keywords": [
+    "llm",
+    "llama",
+    "openai",
+    "gpt",
+    "data science",
+    "prompt",
+    "prompt engineering",
+    "chatgpt",
+    "machine learning",
+    "ml",
+    "embedding",
+    "vectorstore",
+    "data framework",
+    "llamaindex"
+  ],
   "exports": {
     ".": {
       "node": {
@@ -67,8 +83,7 @@
   },
   "dependencies": {
     "@types/lodash": "^4.14.202",
-    "@types/node": "^20.12.7",
-    "lodash": "^4.17.21"
+    "@types/node": "^20.12.7"
   },
   "peerDependencies": {
     "@aws-crypto/sha256-js": "^5.2.0",
diff --git a/packages/env/src/index.polyfill.ts b/packages/env/src/index.polyfill.ts
index 35149f8cb..88521fd06 100644
--- a/packages/env/src/index.polyfill.ts
+++ b/packages/env/src/index.polyfill.ts
@@ -1,3 +1,10 @@
+/**
+ * Polyfill implementation some node.js APIs.
+ *
+ * The code should be compatible with any JS runtime.
+ *
+ * @module
+ */
 import { Sha256 } from "@aws-crypto/sha256-js";
 import pathe from "pathe";
 import { InMemoryFileSystem, type CompleteFileSystem } from "./type.js";
diff --git a/packages/env/src/type.ts b/packages/env/src/type.ts
index c8e80295b..4cb7f6599 100644
--- a/packages/env/src/type.ts
+++ b/packages/env/src/type.ts
@@ -1,5 +1,3 @@
-import _ from "lodash";
-
 /**
  * A filesystem interface that is meant to be compatible with
  * the 'fs' module from Node.js.
@@ -41,14 +39,14 @@ export class InMemoryFileSystem implements CompleteFileSystem {
     content: string,
     options?: unknown,
   ): Promise<void> {
-    this.files[path] = _.cloneDeep(content);
+    this.files[path] = structuredClone(content);
   }
 
   async readFile(path: string): Promise<string> {
     if (!(path in this.files)) {
       throw new Error(`File ${path} does not exist`);
     }
-    return _.cloneDeep(this.files[path]);
+    return structuredClone(this.files[path]);
   }
 
   async access(path: string): Promise<void> {
@@ -58,7 +56,7 @@ export class InMemoryFileSystem implements CompleteFileSystem {
   }
 
   async mkdir(path: string): Promise<undefined> {
-    this.files[path] = _.get(this.files, path, null);
+    this.files[path] = this.files[path] ?? null;
   }
 
   async readdir(path: string): Promise<string[]> {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a44840739..58bc36220 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -628,9 +628,6 @@ importers:
       '@types/node':
         specifier: ^20.12.7
         version: 20.12.7
-      lodash:
-        specifier: ^4.17.21
-        version: 4.17.21
     devDependencies:
       '@aws-crypto/sha256-js':
         specifier: ^5.2.0
-- 
GitLab