diff --git a/packages/core/package.json b/packages/core/package.json index 011f650a21d9ce46009953339dcf6c45e7c42996..b515482367d57e1fb2ce25d43479f3fcfa712c09 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -27,7 +27,6 @@ "rake-modified": "^1.0.8", "replicate": "^0.21.1", "string-strip-html": "^13.4.3", - "uuid": "^9.0.1", "wink-nlp": "^1.14.3" }, "devDependencies": { @@ -36,7 +35,6 @@ "@types/node": "^18.19.2", "@types/papaparse": "^5.3.14", "@types/pg": "^8.10.9", - "@types/uuid": "^9.0.7", "node-stdlib-browser": "^1.2.0", "tsup": "^7.2.0", "typescript": "^5.3.2" diff --git a/packages/core/src/ChatEngine.ts b/packages/core/src/ChatEngine.ts index 1afbb13d2908cd7e5d6b1820e3d67622f7e02d1c..b1df2aed572620c5bc0ccc4c210c76595203ec0b 100644 --- a/packages/core/src/ChatEngine.ts +++ b/packages/core/src/ChatEngine.ts @@ -1,4 +1,4 @@ -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import { ChatHistory } from "./ChatHistory"; import { NodeWithScore, TextNode } from "./Node"; import { @@ -206,7 +206,7 @@ export class DefaultContextGenerator implements ContextGenerator { async generate(message: string, parentEvent?: Event): Promise<Context> { if (!parentEvent) { parentEvent = { - id: uuidv4(), + id: randomUUID(), type: "wrapper", tags: ["final"], }; @@ -272,7 +272,7 @@ export class ContextChatEngine implements ChatEngine { } const parentEvent: Event = { - id: uuidv4(), + id: randomUUID(), type: "wrapper", tags: ["final"], }; @@ -304,7 +304,7 @@ export class ContextChatEngine implements ChatEngine { chatHistory = chatHistory ?? this.chatHistory; const parentEvent: Event = { - id: uuidv4(), + id: randomUUID(), type: "wrapper", tags: ["final"], }; diff --git a/packages/core/src/GlobalsHelper.ts b/packages/core/src/GlobalsHelper.ts index d1d82280d35234575d681d770b74284cc1aae332..d9d4495b545fc922ade2f108e75af64b2b7d0a6e 100644 --- a/packages/core/src/GlobalsHelper.ts +++ b/packages/core/src/GlobalsHelper.ts @@ -1,6 +1,6 @@ import { encodingForModel } from "js-tiktoken"; -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import { Event, EventTag, EventType } from "./callbacks/CallbackManager"; export enum Tokenizers { @@ -64,7 +64,7 @@ class GlobalsHelper { tags?: EventTag[]; }): Event { return { - id: uuidv4(), + id: randomUUID(), type, // inherit parent tags if tags not set tags: tags || parentEvent?.tags, diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index fef42df933390ef3d6b4e8634c7129822980b1fe..a4a2dcfadc5035931c3f99dd7851c621047bff9f 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -1,7 +1,6 @@ import _ from "lodash"; -import { createHash } from "node:crypto"; -import path from "path"; -import { v4 as uuidv4 } from "uuid"; +import { createHash, randomUUID } from "node:crypto"; +import path from "node:path"; export enum NodeRelationship { SOURCE = "SOURCE", @@ -49,7 +48,7 @@ export abstract class BaseNode<T extends Metadata = Metadata> { * * Set to a UUID by default. */ - id_: string = uuidv4(); + id_: string = randomUUID(); embedding?: number[]; // Metadata fields diff --git a/packages/core/src/QueryEngine.ts b/packages/core/src/QueryEngine.ts index aedbb9be79e581ef6930ac8a4fa80aa3b1e9b18f..6c4fa3d2842b12583ca66f5ac0368e5e8d3b4914 100644 --- a/packages/core/src/QueryEngine.ts +++ b/packages/core/src/QueryEngine.ts @@ -1,4 +1,4 @@ -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import { NodeWithScore, TextNode } from "./Node"; import { BaseQuestionGenerator, @@ -72,7 +72,7 @@ export class RetrieverQueryEngine implements BaseQueryEngine { async query(query: string, parentEvent?: Event) { const _parentEvent: Event = parentEvent || { - id: uuidv4(), + id: randomUUID(), type: "wrapper", tags: ["final"], }; @@ -136,14 +136,14 @@ export class SubQuestionQueryEngine implements BaseQueryEngine { // groups final retrieval+synthesis operation const parentEvent: Event = { - id: uuidv4(), + id: randomUUID(), type: "wrapper", tags: ["final"], }; // groups all sub-queries const subQueryParentEvent: Event = { - id: uuidv4(), + id: randomUUID(), parentId: parentEvent.id, type: "wrapper", tags: ["intermediate"], diff --git a/packages/core/src/indices/BaseIndex.ts b/packages/core/src/indices/BaseIndex.ts index 3d44799a745c2e7ad63be77d388b29b26527a90a..98e60ac5d037a779908b4df0374cef1fedf18942 100644 --- a/packages/core/src/indices/BaseIndex.ts +++ b/packages/core/src/indices/BaseIndex.ts @@ -1,4 +1,4 @@ -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import { BaseNode, Document, jsonToNode } from "../Node"; import { BaseQueryEngine } from "../QueryEngine"; import { BaseRetriever } from "../Retriever"; @@ -16,7 +16,7 @@ export abstract class IndexStruct { indexId: string; summary?: string; - constructor(indexId = uuidv4(), summary = undefined) { + constructor(indexId = randomUUID(), summary = undefined) { this.indexId = indexId; this.summary = summary; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 214a3896d3a9e86066af1caa818c16d2684bddd6..6bdc831782f8ef79160c68d566ce825d6fb4ad2f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -212,9 +212,6 @@ importers: string-strip-html: specifier: ^13.4.3 version: 13.4.3 - uuid: - specifier: ^9.0.1 - version: 9.0.1 wink-nlp: specifier: ^1.14.3 version: 1.14.3 @@ -234,9 +231,6 @@ importers: '@types/pg': specifier: ^8.10.9 version: 8.10.9 - '@types/uuid': - specifier: ^9.0.7 - version: 9.0.7 node-stdlib-browser: specifier: ^1.2.0 version: 1.2.0 @@ -4794,10 +4788,6 @@ packages: resolution: {integrity: sha512-d0XxK3YTObnWVp6rZuev3c49+j4Lo8g4L1ZRm9z5L0xpoZycUPshHgczK5gsUMaZOstjVYYi09p5gYvUtfChYw==} dev: false - /@types/uuid@9.0.7: - resolution: {integrity: sha512-WUtIVRUZ9i5dYXefDEAI7sh9/O7jGvHg7Df/5O/gtH3Yabe5odI3UWopVR1qbPXQtvOxWu3mM4XxlYeZtMWF4g==} - dev: true - /@types/validate-npm-package-name@3.0.0: resolution: {integrity: sha512-iFNNIrEaJH1lbPiyX+O/QyxSbKxrTjdNBVZGckt+iEL9So0hdZNBL68sOfHnt2txuUD8UJXvmKv/1DkgkebgUg==} dev: true @@ -16047,11 +16037,6 @@ packages: hasBin: true dev: false - /uuid@9.0.1: - resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} - hasBin: true - dev: false - /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} dev: true