diff --git a/src/helpers.ts b/src/helpers.ts index a08e3c6..821b6b7 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -17,7 +17,7 @@ export const respToFileChoice = ( }, file: async (filename: string, options?: FilePropertyBag) => { const arr = await resp.arrayBuffer(); - return new File([Buffer.from(arr)], filename, options); + return new File([arr], filename, options); }, }; }; diff --git a/src/vercel-ai-toolkit.ts b/src/vercel-ai-toolkit.ts index 610e50d..adbae74 100644 --- a/src/vercel-ai-toolkit.ts +++ b/src/vercel-ai-toolkit.ts @@ -106,7 +106,7 @@ export class JigsawStackToolSet { token_overflow_mode: z.enum(["truncate", "error"]).optional().describe("How to handle token overflow"), }), execute: async ({ text, url, file_store_key, type, token_overflow_mode }) => { - return await this.jigsawStack.embedding({ + return await this.jigsawStack.embedding_v2({ text, url, file_store_key, diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index 1a1bbb8..b7107bb 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -61,7 +61,7 @@ interface GuiElement { interface DetectedObject { bounds: BoundingBox; label: string; - mask?: string; // URL or base64 string depending on return_type - only present for some objects + mask: string | null; // URL or base64 string depending on return_type - only present for some objects } interface BoundingBox { diff --git a/tests/test-helpers.ts b/tests/test-helpers.ts index fb6c1aa..267ea9a 100644 --- a/tests/test-helpers.ts +++ b/tests/test-helpers.ts @@ -8,7 +8,13 @@ export function createJigsawStackClient() { throw new Error("JIGSAWSTACK_API_KEY environment variable is required for testing"); } - return JigsawStack({ apiKey }); + const client = JigsawStack({ + apiKey, + baseURL: process.env.JIGSAWSTACK_BASE_URL ? `${process.env.JIGSAWSTACK_BASE_URL}/api` : "https://api.jigsawstack.com", + headers: { "x-jigsaw-skip-cache": "true" }, + }); + + return client; } export function expectSuccess(result: any): void { diff --git a/tests/vision.test.ts b/tests/vision.test.ts index 8dee80f..562a576 100644 --- a/tests/vision.test.ts +++ b/tests/vision.test.ts @@ -441,7 +441,9 @@ describe("Object Detection API", () => { // Check for optional mask if (obj.mask !== undefined) { - expectType(obj.mask, "string"); + if (obj.mask !== null) { + throw new Error(`Expected mask to be null, got ${typeof obj.mask}`); + } } } } diff --git a/tests/web.test.ts b/tests/web.test.ts index 235d6c6..fe39409 100644 --- a/tests/web.test.ts +++ b/tests/web.test.ts @@ -1002,10 +1002,12 @@ describe("Web Search API", () => { // Check structure of search results for (const searchResult of result.results) { + console.log(searchResult.title); expectProperty(searchResult, "title"); expectProperty(searchResult, "url"); expectProperty(searchResult, "description"); - expectProperty(searchResult, "content"); + // this could also be null after 4 search results + // expectProperty(searchResult, "content"); expectProperty(searchResult, "is_safe"); expectProperty(searchResult, "site_name"); expectProperty(searchResult, "language"); @@ -1014,6 +1016,11 @@ describe("Web Search API", () => { expectType(searchResult.url, "string"); expectType(searchResult.description, "string"); expectType(searchResult.is_safe, "boolean"); + + // content can be string or null + if (searchResult.content !== null && typeof searchResult.content !== "string") { + throw new Error(`Expected content to be string or null, got ${typeof searchResult.content}`); + } } });