From 19c90bda1ec0783949a5b0276b2eb7d458025758 Mon Sep 17 00:00:00 2001
From: thucpn <thucsh2@gmail.com>
Date: Mon, 17 Mar 2025 14:38:27 +0700
Subject: [PATCH] use crypto

---
 packages/tools/src/tools/img-gen.ts     | 3 +--
 packages/tools/src/tools/interpreter.ts | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/packages/tools/src/tools/img-gen.ts b/packages/tools/src/tools/img-gen.ts
index 5606610b6..b46de53d3 100644
--- a/packages/tools/src/tools/img-gen.ts
+++ b/packages/tools/src/tools/img-gen.ts
@@ -1,5 +1,4 @@
 import { tool } from "@llamaindex/core/tools";
-import { randomUUID } from "@llamaindex/env";
 import { FormData } from "formdata-node";
 import got from "got";
 import path from "path";
@@ -37,7 +36,7 @@ export const imageGenerator = (params: ImgGeneratorToolParams) => {
 
       try {
         const buffer = await promptToImgBuffer(prompt, apiKey, outputFormat);
-        const filename = `${randomUUID()}.${outputFormat}`;
+        const filename = `${crypto.randomUUID()}.${outputFormat}`;
         const filePath = path.join(outputDir, filename);
         await saveDocument(filePath, buffer);
         const imageUrl = getFileUrl(filePath, { fileServerURLPrefix });
diff --git a/packages/tools/src/tools/interpreter.ts b/packages/tools/src/tools/interpreter.ts
index 316690b8b..364cdf6f4 100644
--- a/packages/tools/src/tools/interpreter.ts
+++ b/packages/tools/src/tools/interpreter.ts
@@ -1,6 +1,5 @@
 import { type Logs, Result, Sandbox } from "@e2b/code-interpreter";
 import { tool } from "@llamaindex/core/tools";
-import { randomUUID } from "@llamaindex/env";
 import fs from "fs";
 import path from "node:path";
 import { z } from "zod";
@@ -154,7 +153,7 @@ async function getExtraResult(
 }
 
 async function saveToDisk(outputDir: string, base64Data: string, ext: string) {
-  const filename = `${randomUUID()}.${ext}`;
+  const filename = `${crypto.randomUUID()}.${ext}`;
   const buffer = Buffer.from(base64Data, "base64");
   const filePath = path.join(outputDir, filename);
   await saveDocument(filePath, buffer);
-- 
GitLab