Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 12f530a

Browse files
authored
add hash functions generateUniqueHexId generateHashFromString (#22)
1 parent 47adf41 commit 12f530a

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

package-lock.json

+10-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "getindexify",
3-
"version": "0.0.28",
3+
"version": "0.0.29",
44
"description": "This is the TypeScript client for interacting with the Indexify service.",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",
@@ -31,6 +31,7 @@
3131
"typescript": "^5.3.3"
3232
},
3333
"dependencies": {
34-
"axios": "^1.6.7"
34+
"axios": "^1.6.7",
35+
"crypto": "^1.0.1"
3536
}
3637
}

packages/langchain/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@getindexify/langchain",
3-
"version": "0.0.18",
3+
"version": "0.0.28",
44
"description": "Langchain retriever for indexify client.",
55
"main": "index.ts",
66
"scripts": {
@@ -18,7 +18,7 @@
1818
},
1919
"homepage": "https://github.com/tensorlakeai/indexify-typescript-client#readme",
2020
"dependencies": {
21-
"getindexify": "^0.0.17",
21+
"getindexify": "^0.0.28",
2222
"langchain": "^0.1.21"
2323
},
2424
"devDependencies": {

src/client.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import {
1111
IDocument,
1212
ISearchIndexResponse,
1313
IBaseContentMetadata,
14-
IExtractedMetadata,
1514
ISchema,
1615
IMtlsConfig,
1716
} from "./types";
1817
import { Agent } from "https";
18+
import { randomUUID } from "crypto";
19+
import { createHash } from "crypto";
1920

2021
const DEFAULT_SERVICE_URL = "http://localhost:8900"; // Set your default service URL
2122

@@ -366,7 +367,17 @@ class IndexifyClient {
366367
mime_type,
367368
labels,
368369
});
369-
return resp
370+
return resp;
371+
}
372+
373+
generateUniqueHexId(): string {
374+
return randomUUID().replace(/-/g, "").substring(0, 16);
375+
}
376+
377+
generateHashFromString(inputString: string): string {
378+
const hashObject = createHash("sha256");
379+
hashObject.update(inputString);
380+
return hashObject.digest("hex").substring(0, 16);
370381
}
371382
}
372383

0 commit comments

Comments
 (0)