Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
};
};
Expand Down
2 changes: 1 addition & 1 deletion src/vercel-ai-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/vision/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion tests/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion tests/vision.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion tests/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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}`);
}
}
});

Expand Down