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
54 changes: 47 additions & 7 deletions .github/workflows/sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,61 @@ on:
branches: [main]

jobs:
sdk-tests:
name: Run SDK Integration Tests
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run SDK Integration Tests

- name: Build package
run: yarn build

- name: Cache build
uses: actions/cache/save@v4
with:
path: |
node_modules
dist
key: build-${{ github.sha }}

test:
name: Test (${{ matrix.test }})
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
test:
- audio
- classification
- validate
- vision
- web
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"

- name: Restore build cache
uses: actions/cache/restore@v4
with:
path: |
node_modules
dist
key: build-${{ github.sha }}

- name: Run ${{ matrix.test }} tests
env:
JIGSAWSTACK_API_KEY: ${{ secrets.JIGSAWSTACK_API_KEY }}
run: yarn test
run: yarn test:${{ matrix.test }}
4 changes: 2 additions & 2 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@jigsawstack/jigsawstack",
"version": "0.3.8",
"version": "0.4.0",
"exports": "./index.ts"
}
}
28 changes: 12 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"name": "jigsawstack",
"description": "JigsawStack - The AI SDK for Typescript and Javascript",
"keywords": [
"framework",
"ai",
"nextjs",
"react"
],
"keywords": ["framework", "ai", "nextjs", "react"],
"type": "module",
"license": "MIT",
"version": "0.3.8",
"version": "0.4.0",
"homepage": "https://jigsawstack.com",
"repository": {
"type": "git",
Expand All @@ -25,9 +20,7 @@
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.cts",
"files": [
"dist/**"
],
"files": ["dist/**"],
"exports": {
"require": {
"types": "./dist/index.d.cts",
Expand All @@ -41,11 +34,14 @@
"scripts": {
"build": "pkgroll --src=./",
"format": "biome check --write .",
"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"
"test": "yarn build && yarn test:all",
"test:run": "node --test --no-warnings --import tsx --test-reporter=spec",
"test:all": "yarn test:run tests/*.ts",
"test:audio": "yarn test:run tests/audio.test.ts",
"test:classification": "yarn test:run tests/classification.test.ts",
"test:validate": "yarn test:run tests/validate.test.ts",
"test:vision": "yarn test:run tests/vision.test.ts",
"test:web": "yarn test:run tests/web.test.ts"
},
"dependencies": {
"isomorphic-fetch": "^3.0.0",
Expand All @@ -58,4 +54,4 @@
"tsx": "^4.16.4",
"typescript": "^5.5.4"
}
}
}
7 changes: 5 additions & 2 deletions src/general/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface TranslateParams {

export type TranslateImageParams = {
url?: string;
file_store_key?: string;
target_language: string;
return_type?: "url" | "binary" | "base64";
};
Expand Down Expand Up @@ -99,8 +100,7 @@ export interface PredictionParams {
value: number | string;
date: string;
}>;

steps: number;
steps?: number;
}

export interface PredictionResponse extends BaseResponse {
Expand All @@ -123,6 +123,9 @@ export interface EmbeddingV2Params {
file_content?: any;
type: "text" | "text-other" | "image" | "audio" | "pdf";
token_overflow_mode?: "truncate" | "error";
dimensions?: number;
instruction?: string;
query?: boolean;
speaker_fingerprint?: boolean;
}

Expand Down
2 changes: 2 additions & 0 deletions src/prompt_engine/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Stream } from "../lib/streaming";

export interface PromptCreateParams {
/** Name of the prompt engine. Max 300 characters. */
name?: string;
prompt: string;
return_prompt?: string | Array<Record<string, any>> | Record<string, any>;
inputs?: Array<{
Expand Down
2 changes: 2 additions & 0 deletions src/vision/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export type VOCRParams = {
url?: string;
file_store_key?: string;
page_range?: Array<number>;
/** High fidelity word-level bounding boxes within complex documents. Default: false. */
fine_grained?: boolean;
};

export interface VOCRResponse extends BaseResponse {
Expand Down
3 changes: 2 additions & 1 deletion src/web/interfaces/scrape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export interface BaseAIScrapeParams {
}

export interface AIScrapeParams extends BaseAIScrapeParams {
element_prompts?: string[] | null;
/** List of prompts or a dictionary of key-value prompts for element extraction. Max 5 items. */
element_prompts?: string[] | Record<string, string> | null;
root_element_selector?: string;
page_position?: number;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/vision.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createJigsawStackClient, expectArray, expectProperty, expectSuccess, ex

const TEST_URLS = {
image: "https://jigsawstack.com/preview/object-detection-example-input.jpg",
pdf: "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf",
pdf: "https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf",
textImage: "https://jigsawstack.com/preview/vocr-example.jpg",
};

Expand Down Expand Up @@ -196,7 +196,7 @@ describe("VOCR (Visual OCR) API", () => {
// PDF-specific tests
test("should work with PDF URL", async () => {
const result = await client.vision.vocr({
prompt: "Extract all text from this PDF",
prompt: "What is this pdf about? Give me a 50 word summary.",
url: TEST_URLS.pdf,
});

Expand Down
66 changes: 33 additions & 33 deletions tests/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,22 @@ describe("AI Scrape API", () => {
});

// Test cookies parameter
test("should work with cookies", async () => {
const result = await client.web.ai_scrape({
url: TEST_URLS.webpage,
element_prompts: ["Get content"],
cookies: [
{
name: "test_cookie",
value: "test_value",
domain: "example.com",
},
],
});

expectSuccess(result);
expectArray(result.data);
});
// test("should work with cookies", async () => {
// const result = await client.web.ai_scrape({
// url: TEST_URLS.webpage,
// element_prompts: ["Get content"],
// cookies: [
// {
// name: "test_cookie",
// value: "test_value",
// domain: "example.com",
// },
// ],
// });

// expectSuccess(result);
// expectArray(result.data);
// });

// Test reject_request_pattern parameter
test("should work with reject_request_pattern", async () => {
Expand Down Expand Up @@ -455,23 +455,23 @@ describe("AI Scrape API", () => {
}
});

test("should work with advance_config cookies tracking", async () => {
const result = await client.web.ai_scrape({
url: TEST_URLS.webpage,
element_prompts: ["Get content"],
advance_config: {
cookies: true,
},
});

expectSuccess(result);
expectArray(result.data);

if (result.advance_config) {
expectProperty(result.advance_config, "cookies");
expectArray(result.advance_config.cookies);
}
});
// test("should work with advance_config cookies tracking", async () => {
// const result = await client.web.ai_scrape({
// url: TEST_URLS.webpage,
// element_prompts: ["Get content"],
// advance_config: {
// cookies: true,
// },
// });

// expectSuccess(result);
// expectArray(result.data);

// if (result.advance_config) {
// expectProperty(result.advance_config, "cookies");
// expectArray(result.advance_config.cookies);
// }
// });

test("should work with all advance_config options", async () => {
const result = await client.web.ai_scrape({
Expand Down
Loading