Skip to content

Commit 0c0f761

Browse files
committed
chore:Housekeeping
0 parents  commit 0c0f761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1494
-0
lines changed

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy JigsawStack Package to PyPI when a Release is Created
2+
3+
on:
4+
release:
5+
types: [created]
6+
jobs:
7+
pypi-publish:
8+
name: Publish release to PyPI
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: pypi
12+
url: https://pypi.org/p/jigsawstack
13+
permissions:
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.x"
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel
25+
- name: Build package
26+
run: |
27+
python setup.py sdist bdist_wheel
28+
- name: Publish package distributions to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
venv/
2+
.venv/
3+
.pytest_cache/
4+
jigsawstack.egg-info/
5+
6+
.env
7+
build/
8+
dist/

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# JigsawStack Python SDK
2+
3+
## Installation
4+
5+
To install JigsawStack Python SDK, simply execute the following command in a terminal:
6+
7+
```
8+
pip install jigsawstack
9+
```
10+
11+
## Setup
12+
13+
First, you need to get an API key, which is available in the [JigsawStack Dashboard](https://jigsawstack.com).
14+
15+
```py
16+
from jigsawstack from JigsawStack
17+
18+
import os
19+
20+
ai = JigsawStack(api_key="your-api-key")
21+
```
22+
23+
## Example
24+
25+
```py
26+
import os
27+
from jigsawstack from JigsawStack
28+
29+
30+
ai = JigsawStack(api_key="your-api-key")
31+
32+
params = {
33+
"url": "https://rogilvkqloanxtvjfrkm.supabase.co/storage/v1/object/public/demo/Collabo%201080x842.jpg?t=2024-03-22T09%3A22%3A48.442Z"
34+
}
35+
36+
result = ai.vision.vocr(params)
37+
38+
print(result)
39+
```

jigsawstack/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
from ._client import JigsawStack
3+
4+
# Config vars
5+
api_key = os.environ.get("JIGSAWSTACK_API_KEY", "")
6+
api_url = os.environ.get("JIGSAWSTACK_API_URL", "https://api.jigsawstack.com")
7+
8+
9+
# Create a global instance of the Web class
10+
__all__ = ["JigsawStack"]

jigsawstack/_client.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
from . import resources
3+
from typing import Union
4+
from ._config import ClientConfig
5+
import os
6+
7+
8+
class JigsawStack:
9+
audio: resources.Audio
10+
vision : resources.Vision
11+
prediction: resources.Prediction
12+
sql: resources.SQL
13+
file: resources.File
14+
kv: resources.KV
15+
translate: resources.Translate
16+
web: resources.Web
17+
sentiment: resources.Sentiment
18+
validate: resources.Validate
19+
summary: resources.Summary
20+
search: resources.Search
21+
api_key: str
22+
api_url: str
23+
24+
25+
def __init__(self, api_key: Union[str, None] = None, api_url: Union[str, None] = None) -> None:
26+
if api_key is None:
27+
api_key = os.environ.get("JIGSAWSTACK_API_KEY")
28+
29+
if api_key is None:
30+
raise ValueError("The api_key client option must be set either by passing api_key to the client or by setting the JIGSAWSTACK_API_KEY environment variable")
31+
32+
if api_url is None:
33+
api_url = os.environ.get("JIGSAWSTACK_API_URL")
34+
if api_url is None:
35+
api_url = f"https://api.jigsawstack.com/v1"
36+
37+
self.api_key = api_key
38+
self.api_url = api_url
39+
40+
41+
self.audio = resources.Audio(api_key=api_key, api_url=api_url)
42+
self.web = resources.Web(api_key=api_key, api_url=api_url)
43+
self.search = resources.Search(api_key=api_key, api_url=api_url)
44+
self.sentiment = resources.Sentiment(api_key=api_key, api_url=api_url)
45+
self.validate = resources.Validate(api_key=api_key, api_url=api_url)
46+
self.summary = resources.Summary(api_key=api_key, api_url=api_url)
47+
self.vision = resources.Vision(api_key=api_key, api_url=api_url)
48+
self.prediction = resources.Prediction(api_key=api_key, api_url=api_url)
49+
self.sql = resources.SQL(api_key=api_key, api_url=api_url)
50+
self.file = resources.File(api_key=api_key, api_url=api_url)
51+
self.kv = resources.KV(api_key=api_key, api_url=api_url)
52+
self.translate = resources.Translate(api_key=api_key, api_url=api_url)

jigsawstack/_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class ClientConfig:
2+
3+
base_url:str
4+
api_key:str
5+
6+
def __init__(self, api_key: str, api_url: str):
7+
self.api_key = api_key
8+
self.api_url = api_url

jigsawstack/audio/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .audio import Audio
2+
__all__ = ["Audio"]

jigsawstack/audio/_audio.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
from typing import Any, Dict, List, cast
3+
from typing_extensions import NotRequired, TypedDict
4+
5+
6+
7+
class SpeechToTextParams(TypedDict):
8+
url:str
9+
file_store_key : NotRequired[str]
10+
language : NotRequired[str]
11+
translate : NotRequired[bool]
12+
by_speaker : NotRequired[bool]
13+
webhook_url : NotRequired[str]
14+
15+
class SpeechToTextResponse(TypedDict):
16+
success:bool
17+
text : str
18+
chunks : List[object]

jigsawstack/audio/audio.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Any, Dict, List, cast
2+
from typing_extensions import NotRequired, TypedDict
3+
from jigsawstack import request
4+
from ._audio import SpeechToTextParams, SpeechToTextResponse
5+
from .._config import ClientConfig
6+
class Audio(ClientConfig):
7+
8+
def speech_to_text(self, params: SpeechToTextParams) -> SpeechToTextResponse:
9+
path = "/ai/transcribe"
10+
resp = request.Request(
11+
api_key=self.api_key,
12+
api_url=self.api_url,
13+
path=path, params=cast(Dict[Any, Any], params), verb="post"
14+
).perform_with_content()
15+
return resp

0 commit comments

Comments
 (0)