Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
398690f
feat: update object detection test cases.
Khurdhula-Harshavardhan Sep 11, 2025
fc18d4e
feat: updating testcases for file_store api.
Khurdhula-Harshavardhan Sep 11, 2025
7792bb1
test: dropping test cases for geo service (merged/deprecated with v3 …
Khurdhula-Harshavardhan Sep 11, 2025
c570913
refactor: del custom_types dot py, utlized by text to speech.
Khurdhula-Harshavardhan Sep 11, 2025
43fc3c5
fix: updating response types, and formatting for image_generation end…
Khurdhula-Harshavardhan Sep 11, 2025
3421bf4
test: updating testcases for image-generation service.
Khurdhula-Harshavardhan Sep 11, 2025
2b7f91e
test: adding new test cases for STT.
Khurdhula-Harshavardhan Sep 11, 2025
17eb2de
fix: formatting, unused imports and param encoding.
Khurdhula-Harshavardhan Sep 11, 2025
8838891
fix: form requests for multipart blob + params async req.
Khurdhula-Harshavardhan Sep 11, 2025
05dcdc9
fix: param encoding for vision endpoints.
Khurdhula-Harshavardhan Sep 11, 2025
6819aed
test: defining test cases for STT with format changes.
Khurdhula-Harshavardhan Sep 11, 2025
7c8c467
test: defining test cases for classification endpoint.
Khurdhula-Harshavardhan Sep 11, 2025
199eb27
tests: formatting previously defined test cases.
Khurdhula-Harshavardhan Sep 11, 2025
b695d36
chore: clean up redudant test file, actual store test file is test_fi…
Khurdhula-Harshavardhan Sep 11, 2025
621d7ba
fix: naming convention and drop deprecated overflow mode chunk.
Khurdhula-Harshavardhan Sep 11, 2025
91f8e0f
test: defining test cases for embedding v1 & v2
Khurdhula-Harshavardhan Sep 11, 2025
a629fa2
feat: format fixes and new testcases for sentiment.
Khurdhula-Harshavardhan Sep 11, 2025
5ea1c3d
chore: deleting outdated vision test file.
Khurdhula-Harshavardhan Sep 11, 2025
0e8bdb3
feat: updated formating for JigsawStack module.
Khurdhula-Harshavardhan Sep 11, 2025
24fc791
feat: updated formatting for async_request.py
Khurdhula-Harshavardhan Sep 11, 2025
b7bc5be
chore: deleting outdated async test cases for embedding.
Khurdhula-Harshavardhan Sep 11, 2025
3974f32
feat: updating demo url across jigsawstack-python.
Khurdhula-Harshavardhan Sep 11, 2025
efcff9c
feat: updating type to accept float for prediciton, introducing new t…
Khurdhula-Harshavardhan Sep 12, 2025
2a47fd0
test: defining new test cases for summary endpoint.
Khurdhula-Harshavardhan Sep 12, 2025
7771416
feat: defining version for requirements.txt
Khurdhula-Harshavardhan Sep 12, 2025
27cb92d
test: defining test cases for text_2_sql service.
Khurdhula-Harshavardhan Sep 12, 2025
974f46f
feat: updating formating for sql dot py
Khurdhula-Harshavardhan Sep 12, 2025
c1b6df1
test: defining test cases for validation services.
Khurdhula-Harshavardhan Sep 12, 2025
0a71df1
feat: formatting validate dot py.
Khurdhula-Harshavardhan Sep 12, 2025
ba568f0
feat: formatting search dot py
Khurdhula-Harshavardhan Sep 12, 2025
b5e2577
test:defining new test cases for web search.
Khurdhula-Harshavardhan Sep 12, 2025
7b213f4
fix: update type for image translation.
Khurdhula-Harshavardhan Sep 12, 2025
b9d2ac1
fix: formatting for translate
Khurdhula-Harshavardhan Sep 12, 2025
33c895e
test: defining test cases for text and image translation.
Khurdhula-Harshavardhan Sep 12, 2025
b121578
fix: update type for image translation.
Khurdhula-Harshavardhan Sep 12, 2025
1f743da
fix: formatting for the files.
Khurdhula-Harshavardhan Sep 12, 2025
6706742
fix: dropping url used for local testing.
Khurdhula-Harshavardhan Sep 12, 2025
408afeb
fix: formatting for test cases.
Khurdhula-Harshavardhan Sep 12, 2025
7de3549
chore: rebase linter to ruff
Khurdhula-Harshavardhan Sep 12, 2025
3f920f8
chore: setting up ci for formatting checks and testing.
Khurdhula-Harshavardhan Sep 12, 2025
592c564
chore: track success count for ci/cd merge.
Khurdhula-Harshavardhan Sep 12, 2025
083874a
chore: loosen ruff constraints.
Khurdhula-Harshavardhan Sep 12, 2025
302d7ad
fix: artifacts to use v4 since v3 upload and download artifacts were …
Khurdhula-Harshavardhan Sep 12, 2025
be5c5a7
fix: formatting with ruff.
Khurdhula-Harshavardhan Sep 12, 2025
5ac3679
fix: formatting errors and improper initializations.
Khurdhula-Harshavardhan Sep 12, 2025
dfe3154
chore: update string max lenght
Khurdhula-Harshavardhan Sep 12, 2025
a76d141
chore: update ruff toml
Khurdhula-Harshavardhan Sep 12, 2025
026c3d9
feat: update CI ruff config.
Khurdhula-Harshavardhan Sep 12, 2025
af5c927
fix: avoid re-formmating gracefully fail for the dev to fix the forma…
Khurdhula-Harshavardhan Sep 12, 2025
700d8ed
fix: missing package in ci
Khurdhula-Harshavardhan Sep 12, 2025
519f831
fix: drop non-existent-previously-deleted test cases.
Khurdhula-Harshavardhan Sep 12, 2025
c3c2541
fix: formatting for ruff.
Khurdhula-Harshavardhan Sep 12, 2025
ba56ab1
feat: seperating test cases for deepresearch and ai_scrape.
Khurdhula-Harshavardhan Sep 12, 2025
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
16 changes: 16 additions & 0 deletions .github/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ruff configuration for CI/CD
line-length = 100
target-version = "py37"

[lint]
select = [
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
]
ignore = [
"B008", # do not perform function calls in argument defaults
]
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
ruff-format-check:
name: Ruff Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install ruff
run: pip install ruff

- name: Check all files with ruff
run: |
ruff check jigsawstack/ --config .github/ruff.toml
ruff format --check jigsawstack/ --config .github/ruff.toml

test:
name: Test - ${{ matrix.test-file }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-file:
- test_audio.py
- test_classification.py
- test_embedding.py
- test_file_store.py
- test_image_generation.py
- test_object_detection.py
- test_prediction.py
- test_sentiment.py
- test_sql.py
- test_summary.py
- test_translate.py
- test_validate.py
- test_web.py
- test_deep_research.py
- test_ai_scrape.py
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-cov python-dotenv
pip install -e .

- name: Run test ${{ matrix.test-file }}
env:
JIGSAWSTACK_API_KEY: ${{ secrets.JIGSAWSTACK_API_KEY }}
run: |
pytest tests/${{ matrix.test-file }} -v

all-checks-passed:
name: All Checks Passed
needs: [ruff-format-check, test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Verify all checks passed
run: |
echo "Ruff Format Check: ${{ needs.ruff-format-check.result }}"
echo "Tests: ${{ needs.test.result }}"

if [[ "${{ needs.ruff-format-check.result }}" != "success" ]]; then
echo "❌ Ruff format check failed"
exit 1
fi

if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "❌ Tests failed"
exit 1
fi

echo "✅ All checks passed successfully!"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ VOCR:

```py
params = {
"url": "https://rogilvkqloanxtvjfrkm.supabase.co/storage/v1/object/public/demo/Collabo%201080x842.jpg?t=2024-03-22T09%3A22%3A48.442Z"
"url": "https://images.unsplash.com/photo-1542931287-023b922fa89b?q=80&w=2574&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D?t=2024-03-22T09%3A22%3A48.442Z"
}
result = jigsaw.vision.vocr(params)
```
Expand Down
37 changes: 0 additions & 37 deletions biome.json

This file was deleted.

37 changes: 19 additions & 18 deletions jigsawstack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
from typing import Union, Dict
import os
from .audio import Audio, AsyncAudio
from .vision import Vision, AsyncVision
from typing import Dict, Union

from .audio import AsyncAudio, Audio
from .classification import AsyncClassification, Classification
from .embedding import AsyncEmbedding, Embedding
from .embedding_v2 import AsyncEmbeddingV2, EmbeddingV2
from .exceptions import JigsawStackError
from .image_generation import AsyncImageGeneration, ImageGeneration
from .prediction import AsyncPrediction, Prediction
from .prompt_engine import AsyncPromptEngine, PromptEngine
from .search import Search
from .prediction import Prediction, AsyncPrediction
from .sentiment import AsyncSentiment, Sentiment
from .sql import SQL, AsyncSQL
from .store import Store, AsyncStore
from .translate import Translate, AsyncTranslate
from .web import Web, AsyncWeb
from .sentiment import Sentiment, AsyncSentiment
from .validate import Validate, AsyncValidate
from .summary import Summary, AsyncSummary
from .embedding import Embedding, AsyncEmbedding
from .exceptions import JigsawStackError
from .image_generation import ImageGeneration, AsyncImageGeneration
from .classification import Classification, AsyncClassification
from .prompt_engine import PromptEngine, AsyncPromptEngine
from .embeddingV2 import EmbeddingV2, AsyncEmbeddingV2
from .store import AsyncStore, Store
from .summary import AsyncSummary, Summary
from .translate import AsyncTranslate, Translate
from .validate import AsyncValidate, Validate
from .vision import AsyncVision, Vision
from .web import AsyncWeb, Web


class JigsawStack:
Expand Down Expand Up @@ -51,7 +52,7 @@ def __init__(
if api_url is None:
api_url = os.environ.get("JIGSAWSTACK_API_URL")
if api_url is None:
api_url = f"https://api.jigsawstack.com/"
api_url = "https://api.jigsawstack.com/"

self.api_key = api_key
self.api_url = api_url
Expand Down Expand Up @@ -171,7 +172,7 @@ def __init__(
if api_url is None:
api_url = os.environ.get("JIGSAWSTACK_API_URL")
if api_url is None:
api_url = f"https://api.jigsawstack.com/"
api_url = "https://api.jigsawstack.com/"

self.api_key = api_key
self.api_url = api_url
Expand Down
32 changes: 25 additions & 7 deletions jigsawstack/async_request.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from typing import Any, Dict, Generic, List, Union, cast, TypedDict, AsyncGenerator
import json
from io import BytesIO
from typing import Any, AsyncGenerator, Dict, Generic, List, TypedDict, Union, cast

import aiohttp
from typing_extensions import Literal, TypeVar

from .exceptions import NoContentError, raise_for_code_and_type
import json

RequestVerb = Literal["get", "post", "put", "patch", "delete"]

Expand All @@ -22,7 +25,7 @@ def __init__(
path: str,
params: Union[Dict[Any, Any], List[Dict[Any, Any]]],
verb: RequestVerb,
headers: Dict[str, str] = {"Content-Type": "application/json"},
headers: Dict[str, str] = None,
data: Union[bytes, None] = None,
stream: Union[bool, None] = False,
):
Expand All @@ -32,7 +35,7 @@ def __init__(
self.api_url = config.get("api_url")
self.api_key = config.get("api_key")
self.data = data
self.headers = headers
self.headers = headers or {"Content-Type": "application/json"}
self.disable_request_logging = config.get("disable_request_logging")
self.stream = stream

Expand Down Expand Up @@ -243,12 +246,27 @@ async def make_request(
)
else:
if data is not None:
form_data = aiohttp.FormData()
form_data.add_field(
"file",
BytesIO(data),
content_type=headers.get("Content-Type", "application/octet-stream"),
filename="file",
)

if self.params and isinstance(self.params, dict):
form_data.add_field(
"body", json.dumps(self.params), content_type="application/json"
)

multipart_headers = headers.copy()
multipart_headers.pop("Content-Type", None)

return await session.request(
verb,
url,
data=data,
params=converted_params, # Use converted params
headers=headers,
data=form_data,
headers=multipart_headers,
)
else:
return await session.request(
Expand Down
36 changes: 16 additions & 20 deletions jigsawstack/audio.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import Any, Dict, List, cast, Union, Optional, overload
from typing_extensions import NotRequired, TypedDict
from .request import Request, RequestConfig
from .async_request import AsyncRequest, AsyncRequestConfig
from typing import Any, Dict, List, Optional, Union, cast, overload

from typing_extensions import Literal, NotRequired, TypedDict

from ._config import ClientConfig
from typing import Any, Dict, List, cast
from typing_extensions import NotRequired, TypedDict, Literal
from .custom_typing import SupportedAccents
from .helpers import build_path
from ._types import BaseResponse
from .async_request import AsyncRequest, AsyncRequestConfig
from .request import Request, RequestConfig


class SpeechToTextParams(TypedDict):
Expand Down Expand Up @@ -80,22 +78,21 @@ def speech_to_text(
blob: Union[SpeechToTextParams, bytes],
options: Optional[SpeechToTextParams] = None,
) -> Union[SpeechToTextResponse, SpeechToTextWebhookResponse]:
options = options or {}
path = "/ai/transcribe"
content_type = options.get("content_type", "application/octet-stream")
headers = {"Content-Type": content_type}
if isinstance(
blob, dict
): # If params is provided as a dict, we assume it's the first argument
resp = Request(
config=self.config,
path="/ai/transcribe",
path=path,
params=cast(Dict[Any, Any], blob),
verb="post",
).perform_with_content()
return resp

options = options or {}
path = build_path(base_path="/ai/transcribe", params=options)
content_type = options.get("content_type", "application/octet-stream")
headers = {"Content-Type": content_type}

resp = Request(
config=self.config,
path=path,
Expand Down Expand Up @@ -137,20 +134,19 @@ async def speech_to_text(
blob: Union[SpeechToTextParams, bytes],
options: Optional[SpeechToTextParams] = None,
) -> Union[SpeechToTextResponse, SpeechToTextWebhookResponse]:
options = options or {}
path = "/ai/transcribe"
content_type = options.get("content_type", "application/octet-stream")
headers = {"Content-Type": content_type}
if isinstance(blob, dict):
resp = await AsyncRequest(
config=self.config,
path="/ai/transcribe",
path=path,
params=cast(Dict[Any, Any], blob),
verb="post",
).perform_with_content()
return resp

options = options or {}
path = build_path(base_path="/ai/transcribe", params=options)
content_type = options.get("content_type", "application/octet-stream")
headers = {"Content-Type": content_type}

resp = await AsyncRequest(
config=self.config,
path=path,
Expand Down
8 changes: 5 additions & 3 deletions jigsawstack/classification.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import Any, Dict, List, Union, cast
from typing_extensions import NotRequired, TypedDict, Literal
from .request import Request, RequestConfig
from .async_request import AsyncRequest, AsyncRequestConfig

from typing_extensions import Literal, NotRequired, TypedDict

from ._config import ClientConfig
from ._types import BaseResponse
from .async_request import AsyncRequest, AsyncRequestConfig
from .request import Request, RequestConfig


class DatasetItem(TypedDict):
Expand Down
Loading