Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
262d6ef
base typing for sdks for usage
winzamark123 Aug 29, 2025
a3eedb0
success and extend base response
winzamark123 Aug 29, 2025
cd6e880
obj detection return masks
winzamark123 Aug 31, 2025
92bf560
update object detection
winzamark123 Aug 31, 2025
413cc06
linting
winzamark123 Aug 31, 2025
411ca78
update stt, typing for non webhooks and webhooks
winzamark123 Aug 31, 2025
08b9412
linting
winzamark123 Sep 1, 2025
1b9fc41
update to embedding
winzamark123 Sep 2, 2025
e1ad1cc
classification into one type accepts either image or text
winzamark123 Sep 2, 2025
719385a
update nsfw
winzamark123 Sep 2, 2025
0ae5385
update scrape
winzamark123 Sep 2, 2025
8978631
update params scrape
winzamark123 Sep 2, 2025
2cb2d6b
update ai scrape types
winzamark123 Sep 2, 2025
9714225
update scrape advance config response
winzamark123 Sep 2, 2025
3cf9873
updated classification test to match new classification
winzamark123 Sep 2, 2025
3a3064a
update web search
winzamark123 Sep 3, 2025
62b96ee
update spell check
winzamark123 Sep 3, 2025
36042b7
update spam check
winzamark123 Sep 3, 2025
bd0f986
update spamcheck
winzamark123 Sep 3, 2025
f381d1c
update html to any
winzamark123 Sep 3, 2025
36a5a1c
add object to vocr prompts
winzamark123 Sep 3, 2025
0a4e5ea
update deep research
winzamark123 Sep 3, 2025
8456c56
update deep research
winzamark123 Sep 3, 2025
950df4e
update search suggestions
winzamark123 Sep 3, 2025
d5aea5d
add types to utils
winzamark123 Sep 3, 2025
013b50e
update translate text
winzamark123 Sep 3, 2025
8d27f0f
update summary
winzamark123 Sep 3, 2025
0a2dc1b
update sql
winzamark123 Sep 3, 2025
a92f1c4
udpate to sentiment
winzamark123 Sep 4, 2025
07a741c
update web test for search
winzamark123 Sep 4, 2025
474c6a5
update file retrieve
winzamark123 Sep 4, 2025
b3715be
summary depends on params
winzamark123 Sep 6, 2025
e43d64e
added types for gui elements
winzamark123 Sep 7, 2025
3ef3b35
update bounds to be of same type
winzamark123 Sep 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ test.ts
.DS_Store

.vscode

local_tests/*
27 changes: 23 additions & 4 deletions src/audio/audio.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import { RequestClient } from "../request";
import { createFileUploadFormData } from "../utils";
import { SpeechToTextParams, SpeechToTextSyncResponse, SpeechToTextWebhookResponse } from "./interfaces";
import {
SpeechToTextParams,
SpeechToTextParamsWithWebhook,
SpeechToTextParamsWithoutWebhook,
SpeechToTextResponse,
SpeechToTextWebhookResponse,
} from "./interfaces";

class Audio {
constructor(private readonly client: RequestClient) {}
speech_to_text(params: SpeechToTextParams): Promise<SpeechToTextSyncResponse>;
speech_to_text(file: Blob | Buffer, params?: Omit<SpeechToTextParams, "url" | "file_store_key">): Promise<SpeechToTextSyncResponse>;

// Overload for webhook case
speech_to_text(params: SpeechToTextParamsWithWebhook): Promise<SpeechToTextWebhookResponse>;

// Overload for Blob/Buffer with webhook
speech_to_text(file: Blob | Buffer, params: Omit<SpeechToTextParamsWithWebhook, "url" | "file_store_key">): Promise<SpeechToTextWebhookResponse>;

// Overload for non-webhook case
speech_to_text(params: SpeechToTextParamsWithoutWebhook): Promise<SpeechToTextResponse>;

// Overload for Blob/Buffer without webhook
speech_to_text(file: Blob | Buffer, params?: Omit<SpeechToTextParamsWithoutWebhook, "url" | "file_store_key">): Promise<SpeechToTextResponse>;

// Implementation
async speech_to_text(
params: SpeechToTextParams | Blob | Buffer,
options?: SpeechToTextParams
): Promise<SpeechToTextSyncResponse | SpeechToTextWebhookResponse> {
): Promise<SpeechToTextResponse | SpeechToTextWebhookResponse> {
if (params instanceof Blob || params instanceof Buffer) {
const formData = createFileUploadFormData(params, options);
return await this.client.fetchJSS("/ai/transcribe", "POST", formData);
Expand Down
179 changes: 12 additions & 167 deletions src/audio/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseResponse } from "../../types";
import { LanguageCodes } from "../utils";

export interface SpeechToTextParams {
url?: string;
Expand All @@ -11,184 +12,28 @@ export interface SpeechToTextParams {
chunk_duration?: number;
}

export interface SpeechToTextSyncResponse extends BaseResponse {
export interface SpeechToTextParamsWithWebhook extends SpeechToTextParams {
webhook_url: string;
}

export interface SpeechToTextParamsWithoutWebhook extends Omit<SpeechToTextParams, "webhook_url"> {
webhook_url?: never;
}

export interface SpeechToTextResponse extends BaseResponse {
text: string;
chunks: Array<{
timestamp: number[];
text: string;
}>;
speakers?: {
speakers?: Array<{
speaker: string;
timestamp: number[];
text: string;
}[];
}>;
}

export interface SpeechToTextWebhookResponse extends BaseResponse {
status: "processing" | "error";
id: string;
}

export type LanguageCodes =
| "af"
| "am"
| "ar"
| "as"
| "az"
| "ba"
| "be"
| "bg"
| "bn"
| "bo"
| "br"
| "bs"
| "ca"
| "ch"
| "co"
| "cs"
| "cy"
| "da"
| "de"
| "dv"
| "dz"
| "el"
| "en"
| "eo"
| "es"
| "et"
| "eu"
| "fa"
| "ff"
| "fi"
| "fj"
| "fo"
| "fr"
| "fy"
| "ga"
| "gd"
| "gl"
| "gu"
| "gv"
| "ha"
| "he"
| "hi"
| "hr"
| "ht"
| "hu"
| "hy"
| "id"
| "ig"
| "is"
| "it"
| "iu"
| "ja"
| "jv"
| "ka"
| "kg"
| "ki"
| "kj"
| "kk"
| "kl"
| "km"
| "kn"
| "ko"
| "kr"
| "ks"
| "ku"
| "kv"
| "kw"
| "ky"
| "la"
| "lb"
| "lg"
| "li"
| "ln"
| "lo"
| "lt"
| "lu"
| "lv"
| "mg"
| "mh"
| "mi"
| "mk"
| "ml"
| "mn"
| "mo"
| "mr"
| "ms"
| "mt"
| "my"
| "na"
| "nb"
| "nd"
| "ne"
| "ng"
| "nl"
| "nn"
| "no"
| "nr"
| "nv"
| "ny"
| "oc"
| "oj"
| "om"
| "or"
| "os"
| "pa"
| "pi"
| "pl"
| "ps"
| "pt"
| "qu"
| "rm"
| "rn"
| "ro"
| "ru"
| "rw"
| "sa"
| "sc"
| "sd"
| "se"
| "sg"
| "sh"
| "si"
| "sk"
| "sl"
| "sm"
| "sn"
| "so"
| "sq"
| "sr"
| "ss"
| "st"
| "su"
| "sv"
| "sw"
| "ta"
| "te"
| "tg"
| "th"
| "ti"
| "tk"
| "tl"
| "tn"
| "to"
| "tr"
| "ts"
| "tt"
| "tw"
| "ty"
| "ug"
| "uk"
| "ur"
| "uz"
| "ve"
| "vi"
| "vo"
| "wo"
| "xh"
| "yi"
| "yo"
| "zh"
| "zh-TW"
| "zu";
8 changes: 2 additions & 6 deletions src/classification/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { RequestClient } from "../request";
import { ClassificationImageParams, ClassificationResponse, ClassificationTextParams } from "./interfaces";
import { ClassificationParams, ClassificationResponse } from "./interfaces";

class Classification {
private readonly client: RequestClient;
constructor(client: RequestClient) {
this.client = client;
}

text = async (params: ClassificationTextParams): Promise<ClassificationResponse> => {
return await this.client.fetchJSS("/classification", "POST", params);
};

image = async (params: ClassificationImageParams): Promise<ClassificationResponse> => {
classify = async (params: ClassificationParams): Promise<ClassificationResponse> => {
return await this.client.fetchJSS("/classification", "POST", params);
};
}
Expand Down
19 changes: 3 additions & 16 deletions src/classification/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,14 @@ export interface ClassificationResponse extends BaseResponse {
predictions: (string | string[])[];
}

export interface ClassificationTextParams {
export interface ClassificationParams {
dataset: Array<{
type: "text";
type: "text" | "image";
value: string;
}>;
labels: Array<{
key?: string;
type: "text";
value: string;
}>;
multiple_labels?: boolean;
}

export interface ClassificationImageParams {
dataset: Array<{
type: "image";
value: string;
}>;
labels: Array<{
key?: string;
type: "image" | "text";
type: "text" | "image";
value: string;
}>;
multiple_labels?: boolean;
Expand Down
5 changes: 3 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ export const JigsawStack = (config?: BaseConfig) => {
},
web: {
ai_scrape: web.ai_scrape,
html_to_any: web.html_to_any,
html_to_any: createBoundMethod(web, web.html_to_any),
search: web.search,
search_suggestions: web.search_suggestions,
deep_research: web.deep_research,
},
store,
validate,
classification,
classification: classification.classify,
};
};
4 changes: 2 additions & 2 deletions src/general/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class General {
};

summary(params: SummaryParams & { type: "points" }): Promise<BaseResponse & { summary: string[] }>;
summary(params: SummaryParams & { type: "text" }): Promise<SummaryResponse>;
async summary(params: SummaryParams): Promise<SummaryResponse | (BaseResponse & { summary: string[] })> {
summary(params: SummaryParams & { type: "text" }): Promise<BaseResponse & { summary: string }>;
async summary(params: SummaryParams): Promise<(BaseResponse & { summary: string[] }) | (BaseResponse & { summary: string })> {
if (params.type === "points") {
const resp = await this.client.fetchJSS("/ai/summary", "POST", params);
return resp as BaseResponse & { summary: string[] };
Expand Down
29 changes: 15 additions & 14 deletions src/general/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseResponse } from "../../types";
import { LanguageCodes } from "../utils";

export type TextToSQLParams = {
prompt: string;
Expand All @@ -7,6 +8,10 @@ export type TextToSQLParams = {
file_store_key?: string;
};

export interface TextToSQLResponse extends BaseResponse {
sql: string;
}

export interface ImageGenerationParams {
prompt: string;
aspect_ratio?: "1:1" | "16:9" | "21:9" | "3:2" | "2:3" | "4:5" | "5:4" | "3:4" | "4:3" | "9:16" | "9:21";
Expand Down Expand Up @@ -43,13 +48,13 @@ export interface SentimentResponse extends BaseResponse {
}

export interface TranslateResponse extends BaseResponse {
translated_text: string;
translated_text: string | string[];
}

export interface TranslateParams {
current_language?: string;
target_language: string;
text: string | string[];
current_language?: LanguageCodes;
target_language: LanguageCodes;
}

export type TranslateImageParams = {
Expand All @@ -76,21 +81,17 @@ export interface SpeechToTextWebhookResponse extends BaseResponse {
id: string;
}

export interface TextToSQLResponse extends BaseResponse {
sql: string;
}

export interface SummaryParams {
text?: string; // maximum 300_000 characters
text?: string | null; // maximum 300_000 characters
url?: string | null; // PDF url only supported
type?: "text" | "points";
url?: string; // PDF url only supported
file_store_key?: string;
max_points?: number; // max 100
max_characters?: number;
file_store_key?: string | null;
max_points?: number | null; // max 100
max_characters?: number | null;
}

export interface SummaryResponse extends BaseResponse {
summary: string;
summary: string | string[];
}

export interface PredictionParams {
Expand All @@ -117,5 +118,5 @@ export interface EmbeddingParams {

export interface EmbeddingResponse extends BaseResponse {
embeddings: number[][];
chunks: string[]; // only for text
chunks?: Array<{ text: string; timestamp: number[] }>; // only available for text and audio
}
Loading