Compare commits

..

6 Commits

Author SHA1 Message Date
Thuc Pham 0252c1659a fix: try not uuid 2024-10-08 07:25:33 +07:00
Thuc Pham 1e68fc71c3 fix: test 2024-10-08 07:17:40 +07:00
Thuc Pham 3d5c7de0ae fix: test 2024-10-08 07:08:02 +07:00
Thuc Pham 4f6b38b15c fix: update test 2024-10-08 07:03:01 +07:00
Thuc Pham 75a47d805e Create serious-ears-tap.md 2024-10-08 06:52:57 +07:00
Thuc Pham 396b1d92b1 fix: use UUID when inserting nodes in postgres 2024-10-08 06:48:14 +07:00
47 changed files with 116 additions and 172 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
fix: use UUID when inserting nodes in postgres
-8
View File
@@ -1,13 +1,5 @@
# docs
## 0.0.87
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.0.86
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.87",
"version": "0.0.86",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
-8
View File
@@ -1,13 +1,5 @@
# @llamaindex/autotool
## 3.0.18
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 3.0.17
### Patch Changes
@@ -1,14 +1,5 @@
# @llamaindex/autotool-01-node-example
## 0.0.27
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
- @llamaindex/autotool@3.0.18
## 0.0.26
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.27"
"version": "0.0.26"
}
@@ -1,14 +1,5 @@
# @llamaindex/autotool-02-next-example
## 0.1.71
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
- @llamaindex/autotool@3.0.18
## 0.1.70
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.71",
"version": "0.1.70",
"scripts": {
"dev": "next dev",
"build": "next build",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool",
"type": "module",
"version": "3.0.18",
"version": "3.0.17",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
-7
View File
@@ -1,12 +1,5 @@
# @llamaindex/cloud
## 0.2.14
### Patch Changes
- Updated dependencies [5f67820]
- @llamaindex/core@0.2.12
## 0.2.13
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "0.2.14",
"version": "0.2.13",
"type": "module",
"license": "MIT",
"scripts": {
-7
View File
@@ -1,12 +1,5 @@
# @llamaindex/community
## 0.0.47
### Patch Changes
- Updated dependencies [5f67820]
- @llamaindex/core@0.2.12
## 0.0.46
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.47",
"version": "0.0.46",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
-6
View File
@@ -1,11 +1,5 @@
# @llamaindex/core
## 0.2.12
### Patch Changes
- 5f67820: Fix that node parsers generate nodes with UUIDs
## 0.2.11
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.2.12",
"version": "0.2.11",
"description": "LlamaIndex Core Module",
"exports": {
"./agent": {
+2 -2
View File
@@ -479,7 +479,7 @@ export function buildNodeFromSplits(
) {
const imageDoc = doc as ImageNode;
const imageNode = new ImageNode({
id_: idGenerator(i, imageDoc),
id_: imageDoc.id_ ?? idGenerator(i, imageDoc),
text: textChunk,
image: imageDoc.image,
embedding: imageDoc.embedding,
@@ -496,7 +496,7 @@ export function buildNodeFromSplits(
) {
const textDoc = doc as TextNode;
const node = new TextNode({
id_: idGenerator(i, textDoc),
id_: textDoc.id_ ?? idGenerator(i, textDoc),
text: textChunk,
embedding: textDoc.embedding,
excludedEmbedMetadataKeys: [...textDoc.excludedEmbedMetadataKeys],
+1
View File
@@ -80,3 +80,4 @@ export {
} from "./llms";
export { objectEntries } from "./object-entries";
export { UUIDFromString } from "./uuid";
+22
View File
@@ -0,0 +1,22 @@
import { createSHA256 } from "@llamaindex/env";
export function UUIDFromString(input: string) {
const hashFunction = createSHA256();
hashFunction.update(input);
const base64Hash = hashFunction.digest();
// Convert base64 to hex
const hexHash = Buffer.from(base64Hash, "base64").toString("hex");
// Format the hash to resemble a UUID (version 5 style)
const uuid = [
hexHash.substring(0, 8),
hexHash.substring(8, 12),
"5" + hexHash.substring(12, 15), // Set the version to 5 (name-based)
((parseInt(hexHash.substring(15, 17), 16) & 0x3f) | 0x80).toString(16) +
hexHash.substring(17, 19), // Set the variant
hexHash.substring(19, 31),
].join("-");
return uuid;
}
+37
View File
@@ -0,0 +1,37 @@
import { UUIDFromString } from "@llamaindex/core/utils";
import { describe, expect, it } from "vitest";
const UUID_REGEX =
/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
describe("UUIDFromString", () => {
it("should convert string to UUID", () => {
const string = "document_id_1";
const result = UUIDFromString(string);
expect(result).toBeDefined();
expect(result).toMatch(UUID_REGEX);
});
it("should return the same UUID for the same input string", () => {
const string = "document_id_1";
const result1 = UUIDFromString(string);
const result2 = UUIDFromString(string);
expect(result1).toEqual(result2);
});
it("should return the different UUID for different input strings", () => {
const string1 = "document_id_1";
const string2 = "document_id_2";
const result1 = UUIDFromString(string1);
const result2 = UUIDFromString(string2);
expect(result1).not.toEqual(result2);
});
it("should handle case-sensitive input strings", () => {
const string1 = "document_id_1";
const string2 = "Document_Id_1";
const result1 = UUIDFromString(string1);
const result2 = UUIDFromString(string2);
expect(result1).not.toEqual(result2);
});
});
-8
View File
@@ -1,13 +1,5 @@
# @llamaindex/experimental
## 0.0.96
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.0.95
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.96",
"version": "0.0.95",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
-13
View File
@@ -1,18 +1,5 @@
# llamaindex
## 0.6.18
### Patch Changes
- 5f67820: Fix that node parsers generate nodes with UUIDs
- fe08d04: Fix LlamaCloud retrieval with multiple pipelines
- Updated dependencies [5f67820]
- @llamaindex/core@0.2.12
- @llamaindex/cloud@0.2.14
- @llamaindex/ollama@0.0.7
- @llamaindex/openai@0.1.15
- @llamaindex/groq@0.0.14
## 0.6.17
### Patch Changes
@@ -1,13 +1,5 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.80
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.0.79
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.80",
"version": "0.0.79",
"type": "module",
"private": true,
"scripts": {
@@ -1,11 +1,5 @@
# @llamaindex/llama-parse-browser-test
## 0.0.10
### Patch Changes
- @llamaindex/cloud@0.2.14
## 0.0.9
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.10",
"version": "0.0.9",
"type": "module",
"scripts": {
"dev": "vite",
@@ -1,13 +1,5 @@
# @llamaindex/next-agent-test
## 0.1.80
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.1.79
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.80",
"version": "0.1.79",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,13 +1,5 @@
# test-edge-runtime
## 0.1.79
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.1.78
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.79",
"version": "0.1.78",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,13 +1,5 @@
# @llamaindex/next-node-runtime
## 0.0.61
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.0.60
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.0.61",
"version": "0.0.60",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,13 +1,5 @@
# @llamaindex/waku-query-engine-test
## 0.0.80
### Patch Changes
- Updated dependencies [5f67820]
- Updated dependencies [fe08d04]
- llamaindex@0.6.18
## 0.0.79
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.80",
"version": "0.0.79",
"type": "module",
"private": true,
"scripts": {
@@ -1,4 +1,5 @@
/* eslint-disable turbo/no-undeclared-env-vars */
import { UUIDFromString } from "@llamaindex/core/utils";
import { config } from "dotenv";
import { Document, VectorStoreQueryMode } from "llamaindex";
import { PGVectorStore } from "llamaindex/vector-store/PGVectorStore";
@@ -60,7 +61,7 @@ await test("simple node", async (t) => {
const dimensions = 3;
const schemaName =
"llamaindex_vector_store_test_" + Math.random().toString(36).substring(7);
const nodeId = "5bb16627-f6c0-459c-bb18-71642813ef21";
const nodeId = "document_id_1";
const node = new Document({
text: "hello world",
id_: nodeId,
@@ -78,6 +79,7 @@ await test("simple node", async (t) => {
await vectorStore.add([node]);
const insertedNodeId = UUIDFromString(nodeId);
{
const result = await vectorStore.query({
mode: VectorStoreQueryMode.DEFAULT,
@@ -85,16 +87,18 @@ await test("simple node", async (t) => {
queryEmbedding: [1, 2, 3],
});
const actualJSON = result.nodes![0]!.toJSON();
assert.deepStrictEqual(actualJSON, {
...node.toJSON(),
id_: insertedNodeId,
hash: actualJSON.hash,
metadata: actualJSON.metadata,
});
assert.deepStrictEqual(result.ids, [nodeId]);
assert.deepStrictEqual(result.ids, [insertedNodeId]);
assert.deepStrictEqual(result.similarities, [1]);
}
await vectorStore.delete(nodeId);
await vectorStore.delete(insertedNodeId);
{
const result = await vectorStore.query({
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.6.18",
"version": "0.6.17",
"license": "MIT",
"type": "module",
"keywords": [
@@ -61,7 +61,7 @@ export class LlamaCloudRetriever extends BaseRetriever {
await PipelinesService.searchPipelinesApiV1PipelinesGet({
query: {
project_id: await getProjectId(this.projectName, this.organizationId),
pipeline_name: this.pipelineName,
project_name: this.pipelineName,
},
throwOnError: true,
});
@@ -72,11 +72,25 @@ export class LlamaCloudRetriever extends BaseRetriever {
);
}
const { data: pipeline } =
await PipelinesService.getPipelineApiV1PipelinesPipelineIdGet({
path: {
pipeline_id: pipelines[0]!.id,
},
throwOnError: true,
});
if (!pipeline) {
throw new Error(
`No pipeline found with name ${this.pipelineName} in project ${this.projectName}`,
);
}
const { data: results } =
await PipelinesService.runSearchApiV1PipelinesPipelineIdRetrievePost({
throwOnError: true,
path: {
pipeline_id: pipelines[0]!.id,
pipeline_id: pipeline.id,
},
body: {
...this.retrieveParams,
+2 -2
View File
@@ -40,9 +40,9 @@ export async function getProjectId(
): Promise<string> {
const { data: projects } = await ProjectsService.listProjectsApiV1ProjectsGet(
{
query: {
path: {
project_name: projectName,
organization_id: organizationId ?? null,
organization_id: organizationId,
},
throwOnError: true,
},
@@ -20,6 +20,7 @@ import type { BaseEmbedding } from "@llamaindex/core/embeddings";
import { DEFAULT_COLLECTION } from "@llamaindex/core/global";
import type { BaseNode, Metadata } from "@llamaindex/core/schema";
import { Document, MetadataMode } from "@llamaindex/core/schema";
import { UUIDFromString } from "@llamaindex/core/utils";
// todo: create adapter for postgres client
function fromVercelPool(client: VercelPool): IsomorphicDB {
@@ -293,7 +294,7 @@ export class PGVectorStore
private getDataToInsert(embeddingResults: BaseNode<Metadata>[]) {
return embeddingResults.map((node) => {
const id: any = node.id_.length ? node.id_ : null;
const id: any = node.id_.length ? UUIDFromString(node.id_) : null;
const meta = node.metadata || {};
if (!meta.create_date) {
meta.create_date = new Date();
@@ -10,6 +10,7 @@ import {
type VectorStoreQueryResult,
} from "./types.js";
import { UUIDFromString } from "@llamaindex/core/utils";
import type { QdrantClientParams, Schemas } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest";
import { metadataDictToNode, nodeToMetadata } from "./utils.js";
@@ -170,7 +171,7 @@ export class QdrantVectorStore
for (let k = 0; k < nodeIds.length; k++) {
const point: PointStruct = {
id: nodeIds[k]!.id_,
id: UUIDFromString(nodeIds[k]!.id_),
payload: payloads[k]!,
vector: vectors[k]!,
};
@@ -27,7 +27,7 @@ describe("VectorStoreIndex", () => {
runs: number = 2,
): Promise<Array<number>> => {
const documents = [new Document({ text: "lorem ipsem", id_: "1" })];
const entries = [];
const entries: number[] = [];
for (let i = 0; i < runs; i++) {
await VectorStoreIndex.fromDocuments(documents, {
serviceContext,
@@ -43,7 +43,7 @@ describe("VectorStoreIndex", () => {
test("fromDocuments stores duplicates without a doc store strategy", async () => {
const entries = await testStrategy(DocStoreStrategy.NONE);
expect(entries[0]! + 1).toBe(entries[1]);
expect(entries[0]).toBe(entries[1]);
});
test("fromDocuments ignores duplicates with upserts doc store strategy", async () => {
-6
View File
@@ -1,11 +1,5 @@
# @llamaindex/groq
## 0.0.14
### Patch Changes
- @llamaindex/openai@0.1.15
## 0.0.13
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/groq",
"description": "Groq Adapter for LlamaIndex",
"version": "0.0.14",
"version": "0.0.13",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
-7
View File
@@ -1,12 +1,5 @@
# @llamaindex/ollama
## 0.0.7
### Patch Changes
- Updated dependencies [5f67820]
- @llamaindex/core@0.2.12
## 0.0.6
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/ollama",
"description": "Ollama Adapter for LlamaIndex",
"version": "0.0.7",
"version": "0.0.6",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
-7
View File
@@ -1,12 +1,5 @@
# @llamaindex/openai
## 0.1.15
### Patch Changes
- Updated dependencies [5f67820]
- @llamaindex/core@0.2.12
## 0.1.14
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/openai",
"description": "OpenAI Adapter for LlamaIndex",
"version": "0.1.15",
"version": "0.1.14",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",