From 1d5ae19be1aeafe84915711e2bfbea2043ab28b2 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 09:36:55 -0700 Subject: [PATCH 01/10] embedding v2, changing all routes to support --- .gitignore | 2 ++ src/general/index.ts | 26 ++++++++++++++------------ src/general/interfaces.ts | 16 ++++++++++++++++ src/request.ts | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index d3ddc9f..eff313e 100644 --- a/.gitignore +++ b/.gitignore @@ -135,3 +135,5 @@ test.ts .DS_Store .vscode + +local_tests/* \ No newline at end of file diff --git a/src/general/index.ts b/src/general/index.ts index 56fc0b3..b91a145 100644 --- a/src/general/index.ts +++ b/src/general/index.ts @@ -5,6 +5,8 @@ import { createFileUploadFormData } from "../utils"; import { EmbeddingParams, EmbeddingResponse, + EmbeddingV2Params, + EmbeddingV2Response, ImageGenerationParams, PredictionParams, PredictionResponse, @@ -29,10 +31,10 @@ class General { translate = { text: async (params: TranslateParams): Promise => { if (Array.isArray(params.text)) { - const resp = await this.client.fetchJSS("/ai/translate", "POST", params); + const resp = await this.client.fetchJSS("/v1/ai/translate", "POST", params); return resp as BaseResponse & { translated_text: string[] }; } - return await this.client.fetchJSS("/ai/translate", "POST", params); + return await this.client.fetchJSS("/v1/ai/translate", "POST", params); }, image: async ( params: Blob | Buffer | TranslateImageParams, @@ -40,39 +42,39 @@ class General { ): Promise> => { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); - const resp = await this.client.fetchJSS("/ai/translate/image", "POST", formData); + const resp = await this.client.fetchJSS("/v1/ai/translate/image", "POST", formData); return respToFileChoice(resp); } - const resp = await this.client.fetchJSS("/ai/translate/image", "POST", params); + const resp = await this.client.fetchJSS("/v1/ai/translate/image", "POST", params); return respToFileChoice(resp); }, }; sentiment = async (params: { text: string }): Promise => { - return await this.client.fetchJSS("/ai/sentiment", "POST", params); + return await this.client.fetchJSS("/v1/ai/sentiment", "POST", params); }; image_generation = async (params: ImageGenerationParams) => { - const resp = await this.client.fetchJSS("/ai/image_generation", "POST", params); + const resp = await this.client.fetchJSS("/v1/ai/image_generation", "POST", params); return respToFileChoice(resp); }; text_to_sql = async (params: TextToSQLParams): Promise => { - return await this.client.fetchJSS("/ai/sql", "POST", params); + return await this.client.fetchJSS("/v1/ai/sql", "POST", params); }; summary(params: SummaryParams & { type: "points" }): Promise; summary(params: SummaryParams & { type: "text" }): Promise; async summary(params: SummaryParams): Promise { if (params.type === "points") { - const resp = await this.client.fetchJSS("/ai/summary", "POST", params); + const resp = await this.client.fetchJSS("/v1/ai/summary", "POST", params); return resp as BaseResponse & { summary: string[] }; } - return await this.client.fetchJSS("/ai/summary", "POST", params); + return await this.client.fetchJSS("/v1/ai/summary", "POST", params); } prediction = async (params: PredictionParams): Promise => { - return await this.client.fetchJSS("/ai/prediction", "POST", params); + return await this.client.fetchJSS("/v1/ai/prediction", "POST", params); }; embedding(params: EmbeddingParams): Promise; @@ -80,9 +82,9 @@ class General { async embedding(params: EmbeddingParams | Blob | Buffer, options?: EmbeddingParams): Promise { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); - return await this.client.fetchJSS("/embedding", "POST", formData); + return await this.client.fetchJSS("/v1/embedding", "POST", formData); } - return await this.client.fetchJSS("/embedding", "POST", params); + return await this.client.fetchJSS("/v1/embedding", "POST", params); } } diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index 1bd2e99..c0c1a35 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -115,6 +115,22 @@ export interface EmbeddingParams { token_overflow_mode?: "truncate" | "error"; } +export interface EmbeddingV2Params { + text?: string; + url?: string; + file_store_key?: string; + file_content?: any; + type: "text" | "text-other" | "image" | "audio" | "pdf"; + token_overflow_mode?: "truncate" | "error"; + speaker_fingerprint?: boolean; +} + +export interface EmbeddingV2Response extends BaseResponse { + embeddings: number[][]; + chunks: string[]; // only for text + speaker_embeddings?: number[][]; // only for audio +} + export interface EmbeddingResponse extends BaseResponse { embeddings: number[][]; chunks: string[]; // only for text diff --git a/src/request.ts b/src/request.ts index 8839085..a1301b6 100644 --- a/src/request.ts +++ b/src/request.ts @@ -1,7 +1,7 @@ import { BaseConfig } from "../types"; import { removeUndefinedProperties } from "./helpers"; -const baseURL = "https://api.jigsawstack.com/v1"; +const baseURL = "https://api.jigsawstack.com/"; // const baseURL = "http://localhost:3000"; export class RequestClient { From a31a03af525b2da1c3a17dc98f3248cd17e47896 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 09:38:33 -0700 Subject: [PATCH 02/10] added v2 embeddings to general --- src/general/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/general/index.ts b/src/general/index.ts index b91a145..cf39802 100644 --- a/src/general/index.ts +++ b/src/general/index.ts @@ -86,6 +86,16 @@ class General { } return await this.client.fetchJSS("/v1/embedding", "POST", params); } + + embeddingV2(params: EmbeddingV2Params): Promise; + embeddingV2(file: Blob | Buffer, params: Omit): Promise; + async embeddingV2(params: EmbeddingV2Params | Blob | Buffer, options?: EmbeddingV2Params): Promise { + if (params instanceof Blob || params instanceof Buffer) { + const formData = createFileUploadFormData(params, options); + return await this.client.fetchJSS("/v2/embedding", "POST", formData); + } + return await this.client.fetchJSS("/v2/embedding", "POST", params); + } } export default General; From 8b614e296dc157115d08b40dbbdcbc6e77e7e35b Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 09:39:25 -0700 Subject: [PATCH 03/10] update file to have v1 --- src/store/file.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/file.ts b/src/store/file.ts index 6379bc1..b9c1de3 100644 --- a/src/store/file.ts +++ b/src/store/file.ts @@ -7,7 +7,7 @@ export class File { upload = async (file: Blob | Buffer, params?: FileUploadParams): Promise => { return await this.client.fetchJSS( - `/store/file`, + `/v1/store/file`, "POST", file, { @@ -22,12 +22,12 @@ export class File { }; retrieve = async (key: string) => { - const resp = await this.client.fetchJSS(`/store/file/read/${key}`, "GET"); + const resp = await this.client.fetchJSS(`/v1/store/file/read/${key}`, "GET"); return respToFileChoice(resp); }; delete = async (key: string): Promise => { - return await this.client.fetchJSS(`/store/file/read/${key}`, "DELETE"); + return await this.client.fetchJSS(`/v1/store/file/read/${key}`, "DELETE"); }; } From a4f465b4a9f2c8fedd07ec07ce12fbfaaef02241 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 09:40:07 -0700 Subject: [PATCH 04/10] update v1 --- src/audio/audio.ts | 4 ++-- src/vision/vision.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/audio/audio.ts b/src/audio/audio.ts index 46f81f7..552505e 100644 --- a/src/audio/audio.ts +++ b/src/audio/audio.ts @@ -11,9 +11,9 @@ class Audio { ): Promise { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); - return await this.client.fetchJSS("/ai/transcribe", "POST", formData); + return await this.client.fetchJSS("/v1/ai/transcribe", "POST", formData); } - return await this.client.fetchJSS("/ai/transcribe", "POST", params); + return await this.client.fetchJSS("/v1/ai/transcribe", "POST", params); } } diff --git a/src/vision/vision.ts b/src/vision/vision.ts index a5599e1..c0344b3 100644 --- a/src/vision/vision.ts +++ b/src/vision/vision.ts @@ -9,9 +9,9 @@ class Vision { async vocr(params: VOCRParams | Blob | Buffer, options?: VOCRParams): Promise { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); - return await this.client.fetchJSS("/vocr", "POST", formData); + return await this.client.fetchJSS("/v1/vocr", "POST", formData); } - return await this.client.fetchJSS("/vocr", "POST", params); + return await this.client.fetchJSS("/v1/vocr", "POST", params); } object_detection(params: ObjectDetectionParams): Promise; @@ -19,9 +19,9 @@ class Vision { async object_detection(params: ObjectDetectionParams | Blob | Buffer, options?: ObjectDetectionParams): Promise { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); - return await this.client.fetchJSS("/object_detection", "POST", formData); + return await this.client.fetchJSS("/v1/object_detection", "POST", formData); } - return await this.client.fetchJSS("/object_detection", "POST", params); + return await this.client.fetchJSS("/v1/object_detection", "POST", params); } } From b07ac7fabbd75d817a4d137394760daf88d578d7 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 09:40:40 -0700 Subject: [PATCH 05/10] update v1 --- src/validate/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/validate/index.ts b/src/validate/index.ts index 586443a..148ea19 100644 --- a/src/validate/index.ts +++ b/src/validate/index.ts @@ -21,23 +21,23 @@ class Validate { async nsfw(params: NSFWParams | Blob | Buffer, options?: NSFWParams): Promise { if (params instanceof Blob || params instanceof Buffer) { const formData = createFileUploadFormData(params, options); - return await this.client.fetchJSS("/validate/nsfw", "POST", formData); + return await this.client.fetchJSS("/v1/validate/nsfw", "POST", formData); } - return await this.client.fetchJSS("/validate/nsfw", "POST", params); + return await this.client.fetchJSS("/v1/validate/nsfw", "POST", params); } profanity = async ({ text, censor_replacement = "*" }: ProfanityParams): Promise => { - return await this.client.fetchJSS("/validate/profanity", "POST", { text, censor_replacement }); + return await this.client.fetchJSS("/v1/validate/profanity", "POST", { text, censor_replacement }); }; spellcheck = async ({ text, language_code = "en" }: SpellCheckParams): Promise => { - return await this.client.fetchJSS("/validate/spell_check", "POST", { text, language_code }); + return await this.client.fetchJSS("/v1/validate/spell_check", "POST", { text, language_code }); }; spamcheck(text: string): Promise; spamcheck(text: string[]): Promise; async spamcheck(text: string | string[]): Promise { - return await this.client.fetchJSS("/validate/spam_check", "POST", { text }); + return await this.client.fetchJSS("/v1/validate/spam_check", "POST", { text }); } } From 52567aafd9c88599b95eb4172b00ad869cedf62a Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Fri, 5 Sep 2025 09:45:37 -0700 Subject: [PATCH 06/10] update v1 to web and classification --- src/classification/index.ts | 4 ++-- src/web/web.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/classification/index.ts b/src/classification/index.ts index ffaf2d4..ec1ec45 100644 --- a/src/classification/index.ts +++ b/src/classification/index.ts @@ -8,11 +8,11 @@ class Classification { } text = async (params: ClassificationTextParams): Promise => { - return await this.client.fetchJSS("/classification", "POST", params); + return await this.client.fetchJSS("/v1/classification", "POST", params); }; image = async (params: ClassificationImageParams): Promise => { - return await this.client.fetchJSS("/classification", "POST", params); + return await this.client.fetchJSS("/v1/classification", "POST", params); }; } diff --git a/src/web/web.ts b/src/web/web.ts index ca54599..be785ca 100644 --- a/src/web/web.ts +++ b/src/web/web.ts @@ -8,23 +8,23 @@ class Web { constructor(private readonly client: RequestClient) {} ai_scrape = async (params: AIScrapeParams): Promise => { - return await this.client.fetchJSS("/ai/scrape", "POST", params); + return await this.client.fetchJSS("/v1/ai/scrape", "POST", params); }; html_to_any = async (params: HTMLAnyParams) => { - const resp = await this.client.fetchJSS("/web/html_to_any", "POST", params); + const resp = await this.client.fetchJSS("/v1/web/html_to_any", "POST", params); return respToFileChoice(resp); }; deep_research = async (params: DeepResearchParams): Promise => { - return await this.client.fetchJSS("/web/deep_research", "POST", params); + return await this.client.fetchJSS("/v1/web/deep_research", "POST", params); }; search = async (params: SearchParams): Promise => { - return await this.client.fetchJSS("/web/search", "POST", params); + return await this.client.fetchJSS("/v1/web/search", "POST", params); }; search_suggestions = async (query: string): Promise => { - return await this.client.fetchJSS(`/web/search/suggest?query=${query}`, "GET", undefined); + return await this.client.fetchJSS(`/v1/web/search/suggest?query=${query}`, "GET", undefined); }; } From 3a069b386144907b24d6f2190fa5da74d9c8dddc Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 8 Sep 2025 08:59:14 -0700 Subject: [PATCH 07/10] update package json to have additional tests --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d26395b..9f7a2cf 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,11 @@ "scripts": { "build": "pkgroll --src=./", "format": "biome check --write .", - "test": "yarn build && node --test --no-warnings --import tsx --test-reporter=spec tests/*.ts" + "test": "yarn build && node --test --no-warnings --import tsx --test-reporter=spec tests/*.ts", + "test:audio": "yarn build && node --test --no-warnings --import tsx --test-reporter=spec tests/audio.test.ts", + "test:vision": "yarn build && node --test --no-warnings --import tsx --test-reporter=spec tests/vision.test.ts", + "test:web": "yarn build && node --test --no-warnings --import tsx --test-reporter=spec tests/web.test.ts", + "test:validate": "yarn build && node --test --no-warnings --import tsx --test-reporter=spec tests/validate.test.ts" }, "dependencies": { "isomorphic-fetch": "^3.0.0", From 367118dc1a28844a801fbcd26266ad3d9f0dcd77 Mon Sep 17 00:00:00 2001 From: Win Cheng Date: Mon, 8 Sep 2025 09:14:10 -0700 Subject: [PATCH 08/10] fix file upload multiform --- src/request.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/request.ts b/src/request.ts index a1301b6..ce8f16f 100644 --- a/src/request.ts +++ b/src/request.ts @@ -1,7 +1,7 @@ import { BaseConfig } from "../types"; import { removeUndefinedProperties } from "./helpers"; -const baseURL = "https://api.jigsawstack.com/"; +const baseURL = "https://api.jigsawstack.com"; // const baseURL = "http://localhost:3000"; export class RequestClient { From 95c2cef0734297b231bf8ef3855f9d5c9da9f15b Mon Sep 17 00:00:00 2001 From: Vineet Agarwal <91052168+VineeTagarwaL-code@users.noreply.github.com> Date: Tue, 9 Sep 2025 02:31:46 +0530 Subject: [PATCH 09/10] fix: added v2 --- src/core.ts | 1 + src/general/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/core.ts b/src/core.ts index f456478..6e6b634 100644 --- a/src/core.ts +++ b/src/core.ts @@ -44,6 +44,7 @@ export const JigsawStack = (config?: BaseConfig) => { prediction: general.prediction, text_to_sql: general.text_to_sql, embedding: general.embedding, + embeddingV2: general.embeddingV2, audio, vision: { vocr: createBoundMethod(vision, vision.vocr), diff --git a/src/general/index.ts b/src/general/index.ts index 2da826f..878146a 100644 --- a/src/general/index.ts +++ b/src/general/index.ts @@ -26,6 +26,7 @@ class General { this.client = client; this.summary = this.summary.bind(this); this.embedding = this.embedding.bind(this); + this.embeddingV2 = this.embeddingV2.bind(this); } translate = { From 577d7ec29cd1bba834ad728d0594bcfabdba1767 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal <91052168+VineeTagarwaL-code@users.noreply.github.com> Date: Tue, 9 Sep 2025 02:46:51 +0530 Subject: [PATCH 10/10] update: more type updates for v2 and v1 response for embedding --- src/general/interfaces.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index 83ea307..384207b 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -128,8 +128,13 @@ export interface EmbeddingV2Params { export interface EmbeddingV2Response extends BaseResponse { embeddings: number[][]; - chunks: string[]; // only for text - speaker_embeddings?: number[][]; // only for audio + chunks?: + | string[] + | Array<{ + text: string; + timestamp: number[]; + }>; + speaker_embeddings?: number[][]; } export interface EmbeddingResponse extends BaseResponse {