diff --git a/.github/workflows/sdk-tests.yml b/.github/workflows/sdk-tests.yml index 21470a5..5e52b44 100644 --- a/.github/workflows/sdk-tests.yml +++ b/.github/workflows/sdk-tests.yml @@ -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 \ No newline at end of file + run: yarn test:${{ matrix.test }} \ No newline at end of file diff --git a/jsr.json b/jsr.json index 8ed6f03..5d5d953 100644 --- a/jsr.json +++ b/jsr.json @@ -1,5 +1,5 @@ { "name": "@jigsawstack/jigsawstack", - "version": "0.3.8", + "version": "0.4.0", "exports": "./index.ts" -} \ No newline at end of file +} diff --git a/package.json b/package.json index 119e744..fb8db97 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", @@ -58,4 +54,4 @@ "tsx": "^4.16.4", "typescript": "^5.5.4" } -} \ No newline at end of file +} diff --git a/src/general/interfaces.ts b/src/general/interfaces.ts index 384207b..c79566f 100644 --- a/src/general/interfaces.ts +++ b/src/general/interfaces.ts @@ -59,6 +59,7 @@ export interface TranslateParams { export type TranslateImageParams = { url?: string; + file_store_key?: string; target_language: string; return_type?: "url" | "binary" | "base64"; }; @@ -99,8 +100,7 @@ export interface PredictionParams { value: number | string; date: string; }>; - - steps: number; + steps?: number; } export interface PredictionResponse extends BaseResponse { @@ -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; } diff --git a/src/prompt_engine/interfaces.ts b/src/prompt_engine/interfaces.ts index bb450f9..d810b8d 100644 --- a/src/prompt_engine/interfaces.ts +++ b/src/prompt_engine/interfaces.ts @@ -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; inputs?: Array<{ diff --git a/src/vision/interfaces.ts b/src/vision/interfaces.ts index 285ac7a..bf4b8a2 100644 --- a/src/vision/interfaces.ts +++ b/src/vision/interfaces.ts @@ -5,6 +5,8 @@ export type VOCRParams = { url?: string; file_store_key?: string; page_range?: Array; + /** High fidelity word-level bounding boxes within complex documents. Default: false. */ + fine_grained?: boolean; }; export interface VOCRResponse extends BaseResponse { diff --git a/src/web/interfaces/scrape.ts b/src/web/interfaces/scrape.ts index bbdc51d..fd7d3b8 100644 --- a/src/web/interfaces/scrape.ts +++ b/src/web/interfaces/scrape.ts @@ -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 | null; root_element_selector?: string; page_position?: number; } diff --git a/tests/vision.test.ts b/tests/vision.test.ts index 562a576..940f442 100644 --- a/tests/vision.test.ts +++ b/tests/vision.test.ts @@ -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", }; @@ -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, }); diff --git a/tests/web.test.ts b/tests/web.test.ts index fe39409..e94b175 100644 --- a/tests/web.test.ts +++ b/tests/web.test.ts @@ -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 () => { @@ -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({