Skip to content

Commit 6f69276

Browse files
authored
Merge pull request #67 from JigsawStack/update/vercel-toolkit
2 parents 845ab10 + 1dd751b commit 6f69276

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const respToFileChoice = (
1717
},
1818
file: async (filename: string, options?: FilePropertyBag) => {
1919
const arr = await resp.arrayBuffer();
20-
return new File([Buffer.from(arr)], filename, options);
20+
return new File([arr], filename, options);
2121
},
2222
};
2323
};

src/vercel-ai-toolkit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class JigsawStackToolSet {
106106
token_overflow_mode: z.enum(["truncate", "error"]).optional().describe("How to handle token overflow"),
107107
}),
108108
execute: async ({ text, url, file_store_key, type, token_overflow_mode }) => {
109-
return await this.jigsawStack.embedding({
109+
return await this.jigsawStack.embedding_v2({
110110
text,
111111
url,
112112
file_store_key,

src/vision/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ interface GuiElement {
6161
interface DetectedObject {
6262
bounds: BoundingBox;
6363
label: string;
64-
mask?: string; // URL or base64 string depending on return_type - only present for some objects
64+
mask: string | null; // URL or base64 string depending on return_type - only present for some objects
6565
}
6666

6767
interface BoundingBox {

tests/test-helpers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export function createJigsawStackClient() {
88
throw new Error("JIGSAWSTACK_API_KEY environment variable is required for testing");
99
}
1010

11-
return JigsawStack({ apiKey });
11+
const client = JigsawStack({
12+
apiKey,
13+
baseURL: process.env.JIGSAWSTACK_BASE_URL ? `${process.env.JIGSAWSTACK_BASE_URL}/api` : "https://api.jigsawstack.com",
14+
headers: { "x-jigsaw-skip-cache": "true" },
15+
});
16+
17+
return client;
1218
}
1319

1420
export function expectSuccess(result: any): void {

tests/vision.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,9 @@ describe("Object Detection API", () => {
441441

442442
// Check for optional mask
443443
if (obj.mask !== undefined) {
444-
expectType(obj.mask, "string");
444+
if (obj.mask !== null) {
445+
throw new Error(`Expected mask to be null, got ${typeof obj.mask}`);
446+
}
445447
}
446448
}
447449
}

tests/web.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,12 @@ describe("Web Search API", () => {
10021002

10031003
// Check structure of search results
10041004
for (const searchResult of result.results) {
1005+
console.log(searchResult.title);
10051006
expectProperty(searchResult, "title");
10061007
expectProperty(searchResult, "url");
10071008
expectProperty(searchResult, "description");
1008-
expectProperty(searchResult, "content");
1009+
// this could also be null after 4 search results
1010+
// expectProperty(searchResult, "content");
10091011
expectProperty(searchResult, "is_safe");
10101012
expectProperty(searchResult, "site_name");
10111013
expectProperty(searchResult, "language");
@@ -1014,6 +1016,11 @@ describe("Web Search API", () => {
10141016
expectType(searchResult.url, "string");
10151017
expectType(searchResult.description, "string");
10161018
expectType(searchResult.is_safe, "boolean");
1019+
1020+
// content can be string or null
1021+
if (searchResult.content !== null && typeof searchResult.content !== "string") {
1022+
throw new Error(`Expected content to be string or null, got ${typeof searchResult.content}`);
1023+
}
10171024
}
10181025
});
10191026

0 commit comments

Comments
 (0)