jigsawstack 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/PKG-INFO +1 -1
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/__init__.py +2 -2
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/audio.py +58 -7
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/embedding.py +58 -7
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/helpers.py +1 -1
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/store.py +11 -3
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/translate.py +64 -32
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/validate.py +41 -18
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack.egg-info/PKG-INFO +1 -1
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/setup.py +1 -1
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/README.md +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/_client.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/_config.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/async_request.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/custom_typing.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/exceptions.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/geo.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/image_generation.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/prediction.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/prompt_engine.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/request.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/search.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/sentiment.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/sql.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/summary.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/version.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/vision.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack/web.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack.egg-info/SOURCES.txt +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack.egg-info/dependency_links.txt +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack.egg-info/not-zip-safe +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack.egg-info/requires.txt +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/jigsawstack.egg-info/top_level.txt +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/setup.cfg +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_async_web.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_audio.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_embedding_async.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_geo.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_prompt_engine.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_search.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_sentiment.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_store.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_validate.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_vision.py +0 -0
- {jigsawstack-0.2.0 → jigsawstack-0.2.2}/tests/test_web.py +0 -0
|
@@ -100,7 +100,7 @@ class JigsawStack:
|
|
|
100
100
|
api_key=api_key,
|
|
101
101
|
api_url=api_url,
|
|
102
102
|
disable_request_logging=disable_request_logging,
|
|
103
|
-
)
|
|
103
|
+
)
|
|
104
104
|
|
|
105
105
|
self.prompt_engine = PromptEngine(
|
|
106
106
|
api_key=api_key,
|
|
@@ -209,7 +209,7 @@ class AsyncJigsawStack:
|
|
|
209
209
|
api_key=api_key,
|
|
210
210
|
api_url=api_url,
|
|
211
211
|
disable_request_logging=disable_request_logging,
|
|
212
|
-
)
|
|
212
|
+
)
|
|
213
213
|
|
|
214
214
|
self.prompt_engine = AsyncPromptEngine(
|
|
215
215
|
api_key=api_key,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Dict, List, cast, Union, Optional
|
|
1
|
+
from typing import Any, Dict, List, cast, Union, Optional, overload
|
|
2
2
|
from typing_extensions import NotRequired, TypedDict
|
|
3
3
|
from .request import Request, RequestConfig
|
|
4
4
|
from .async_request import AsyncRequest, AsyncRequestConfig
|
|
@@ -6,6 +6,7 @@ from ._config import ClientConfig
|
|
|
6
6
|
from typing import Any, Dict, List, cast
|
|
7
7
|
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
from .custom_typing import SupportedAccents
|
|
9
|
+
from .helpers import build_path
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class TextToSpeechParams(TypedDict):
|
|
@@ -29,6 +30,7 @@ class SpeechToTextParams(TypedDict):
|
|
|
29
30
|
by_speaker: NotRequired[bool]
|
|
30
31
|
webhook_url: NotRequired[str]
|
|
31
32
|
batch_size: NotRequired[int]
|
|
33
|
+
chunk_duration: NotRequired[int]
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
class ChunkParams(TypedDict):
|
|
@@ -63,16 +65,41 @@ class Audio(ClientConfig):
|
|
|
63
65
|
disable_request_logging=disable_request_logging,
|
|
64
66
|
)
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
@overload
|
|
69
|
+
def speech_to_text(self, params: SpeechToTextParams) -> SpeechToTextResponse: ...
|
|
70
|
+
@overload
|
|
71
|
+
def speech_to_text(self, file: bytes, options: Optional[SpeechToTextParams] = None) -> SpeechToTextResponse: ...
|
|
72
|
+
|
|
73
|
+
def speech_to_text(
|
|
74
|
+
self,
|
|
75
|
+
blob: Union[SpeechToTextParams, bytes],
|
|
76
|
+
options: Optional[SpeechToTextParams] = None,
|
|
77
|
+
) -> SpeechToTextResponse:
|
|
78
|
+
if isinstance(blob, dict): # If params is provided as a dict, we assume it's the first argument
|
|
79
|
+
resp = Request(
|
|
80
|
+
config=self.config,
|
|
81
|
+
path="/ai/transcribe",
|
|
82
|
+
params=cast(Dict[Any, Any], blob),
|
|
83
|
+
verb="post",
|
|
84
|
+
).perform_with_content()
|
|
85
|
+
return resp
|
|
86
|
+
|
|
87
|
+
options = options or {}
|
|
88
|
+
path = build_path(base_path="/ai/transcribe", params=options)
|
|
89
|
+
content_type = options.get("content_type", "application/octet-stream")
|
|
90
|
+
headers = {"Content-Type": content_type}
|
|
91
|
+
|
|
68
92
|
resp = Request(
|
|
69
93
|
config=self.config,
|
|
70
94
|
path=path,
|
|
71
|
-
params=
|
|
95
|
+
params=options,
|
|
96
|
+
data=blob,
|
|
97
|
+
headers=headers,
|
|
72
98
|
verb="post",
|
|
73
99
|
).perform_with_content()
|
|
74
100
|
return resp
|
|
75
101
|
|
|
102
|
+
|
|
76
103
|
def text_to_speech(self, params: TextToSpeechParams) -> TextToSpeechResponse:
|
|
77
104
|
path = "/ai/tts"
|
|
78
105
|
resp = Request(
|
|
@@ -110,12 +137,36 @@ class AsyncAudio(ClientConfig):
|
|
|
110
137
|
disable_request_logging=disable_request_logging,
|
|
111
138
|
)
|
|
112
139
|
|
|
113
|
-
|
|
114
|
-
|
|
140
|
+
@overload
|
|
141
|
+
async def speech_to_text(self, params: SpeechToTextParams) -> SpeechToTextResponse: ...
|
|
142
|
+
@overload
|
|
143
|
+
async def speech_to_text(self, file: bytes, options: Optional[SpeechToTextParams] = None) -> SpeechToTextResponse: ...
|
|
144
|
+
|
|
145
|
+
async def speech_to_text(
|
|
146
|
+
self,
|
|
147
|
+
blob: Union[SpeechToTextParams, bytes],
|
|
148
|
+
options: Optional[SpeechToTextParams] = None,
|
|
149
|
+
) -> SpeechToTextResponse:
|
|
150
|
+
if isinstance(blob, dict):
|
|
151
|
+
resp = await AsyncRequest(
|
|
152
|
+
config=self.config,
|
|
153
|
+
path="/ai/transcribe",
|
|
154
|
+
params=cast(Dict[Any, Any], blob),
|
|
155
|
+
verb="post",
|
|
156
|
+
).perform_with_content()
|
|
157
|
+
return resp
|
|
158
|
+
|
|
159
|
+
options = options or {}
|
|
160
|
+
path = build_path(base_path="/ai/transcribe", params=options)
|
|
161
|
+
content_type = options.get("content_type", "application/octet-stream")
|
|
162
|
+
headers = {"Content-Type": content_type}
|
|
163
|
+
|
|
115
164
|
resp = await AsyncRequest(
|
|
116
165
|
config=self.config,
|
|
117
166
|
path=path,
|
|
118
|
-
params=
|
|
167
|
+
params=options,
|
|
168
|
+
data=blob,
|
|
169
|
+
headers=headers,
|
|
119
170
|
verb="post",
|
|
120
171
|
).perform_with_content()
|
|
121
172
|
return resp
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Union, cast, Literal
|
|
1
|
+
from typing import Any, Dict, List, Union, cast, Literal, overload
|
|
2
2
|
from typing_extensions import NotRequired, TypedDict
|
|
3
3
|
from .request import Request, RequestConfig
|
|
4
4
|
from .async_request import AsyncRequest
|
|
5
5
|
from typing import List, Union
|
|
6
6
|
from ._config import ClientConfig
|
|
7
|
+
from .helpers import build_path
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
class EmbeddingParams(TypedDict):
|
|
@@ -38,12 +39,37 @@ class Embedding(ClientConfig):
|
|
|
38
39
|
disable_request_logging=disable_request_logging,
|
|
39
40
|
)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
@overload
|
|
43
|
+
def execute(self, params: EmbeddingParams) -> EmbeddingResponse: ...
|
|
44
|
+
@overload
|
|
45
|
+
def execute(self, file: bytes, options: EmbeddingParams = None) -> EmbeddingResponse: ...
|
|
46
|
+
|
|
47
|
+
def execute(
|
|
48
|
+
self,
|
|
49
|
+
blob: Union[EmbeddingParams, bytes],
|
|
50
|
+
options: EmbeddingParams = None,
|
|
51
|
+
) -> EmbeddingResponse:
|
|
52
|
+
path="/embedding"
|
|
53
|
+
if isinstance(blob, dict):
|
|
54
|
+
resp = Request(
|
|
55
|
+
config=self.config,
|
|
56
|
+
path=path,
|
|
57
|
+
params=cast(Dict[Any, Any], blob),
|
|
58
|
+
verb="post",
|
|
59
|
+
).perform_with_content()
|
|
60
|
+
return resp
|
|
61
|
+
|
|
62
|
+
options = options or {}
|
|
63
|
+
path = build_path(base_path=path, params=options)
|
|
64
|
+
content_type = options.get("content_type", "application/octet-stream")
|
|
65
|
+
_headers = {"Content-Type": content_type}
|
|
66
|
+
|
|
43
67
|
resp = Request(
|
|
44
68
|
config=self.config,
|
|
45
69
|
path=path,
|
|
46
|
-
params=
|
|
70
|
+
params=options,
|
|
71
|
+
data=blob,
|
|
72
|
+
headers=_headers,
|
|
47
73
|
verb="post",
|
|
48
74
|
).perform_with_content()
|
|
49
75
|
return resp
|
|
@@ -66,12 +92,37 @@ class AsyncEmbedding(ClientConfig):
|
|
|
66
92
|
disable_request_logging=disable_request_logging,
|
|
67
93
|
)
|
|
68
94
|
|
|
69
|
-
|
|
70
|
-
|
|
95
|
+
@overload
|
|
96
|
+
async def execute(self, params: EmbeddingParams) -> EmbeddingResponse: ...
|
|
97
|
+
@overload
|
|
98
|
+
async def execute(self, file: bytes, options: EmbeddingParams = None) -> EmbeddingResponse: ...
|
|
99
|
+
|
|
100
|
+
async def execute(
|
|
101
|
+
self,
|
|
102
|
+
blob: Union[EmbeddingParams, bytes],
|
|
103
|
+
options: EmbeddingParams = None,
|
|
104
|
+
) -> EmbeddingResponse:
|
|
105
|
+
path="/embedding"
|
|
106
|
+
if isinstance(blob, dict):
|
|
107
|
+
resp = await AsyncRequest(
|
|
108
|
+
config=self.config,
|
|
109
|
+
path=path,
|
|
110
|
+
params=cast(Dict[Any, Any], blob),
|
|
111
|
+
verb="post",
|
|
112
|
+
).perform_with_content()
|
|
113
|
+
return resp
|
|
114
|
+
|
|
115
|
+
options = options or {}
|
|
116
|
+
path = build_path(base_path=path, params=options)
|
|
117
|
+
content_type = options.get("content_type", "application/octet-stream")
|
|
118
|
+
_headers = {"Content-Type": content_type}
|
|
119
|
+
|
|
71
120
|
resp = await AsyncRequest(
|
|
72
121
|
config=self.config,
|
|
73
122
|
path=path,
|
|
74
|
-
params=
|
|
123
|
+
params=options,
|
|
124
|
+
data=blob,
|
|
125
|
+
headers=_headers,
|
|
75
126
|
verb="post",
|
|
76
127
|
).perform_with_content()
|
|
77
128
|
return resp
|
|
@@ -17,7 +17,7 @@ def build_path(base_path: str, params: Optional[Dict[str, Union[str, int, bool]]
|
|
|
17
17
|
return base_path
|
|
18
18
|
|
|
19
19
|
#remove None values from the parameters
|
|
20
|
-
filtered_params = {k: v for k, v in params.items() if v is not None}
|
|
20
|
+
filtered_params = { k: str(v).lower() if isinstance(v, bool) else v for k, v in params.items() if v is not None}
|
|
21
21
|
|
|
22
22
|
#encode the parameters
|
|
23
23
|
return f"{base_path}?{urlencode(filtered_params)}" if filtered_params else base_path
|
|
@@ -10,8 +10,16 @@ class FileDeleteResponse(TypedDict):
|
|
|
10
10
|
|
|
11
11
|
class FileUploadParams(TypedDict):
|
|
12
12
|
overwrite: NotRequired[bool]
|
|
13
|
-
|
|
13
|
+
key: NotRequired[str]
|
|
14
14
|
content_type: NotRequired[str]
|
|
15
|
+
temp_public_url: NotRequired[bool]
|
|
16
|
+
|
|
17
|
+
class FileUploadResponse(TypedDict):
|
|
18
|
+
key: str
|
|
19
|
+
url: str
|
|
20
|
+
size: int
|
|
21
|
+
temp_public_url: NotRequired[str] # Optional, only if temp_public_url is set to True in params
|
|
22
|
+
|
|
15
23
|
|
|
16
24
|
class Store(ClientConfig):
|
|
17
25
|
|
|
@@ -30,7 +38,7 @@ class Store(ClientConfig):
|
|
|
30
38
|
disable_request_logging=disable_request_logging,
|
|
31
39
|
)
|
|
32
40
|
|
|
33
|
-
def upload(self, file: bytes, options: Union[FileUploadParams, None] = None) ->
|
|
41
|
+
def upload(self, file: bytes, options: Union[FileUploadParams, None] = None) -> FileUploadResponse:
|
|
34
42
|
if options is None:
|
|
35
43
|
options = {}
|
|
36
44
|
|
|
@@ -87,7 +95,7 @@ class AsyncStore(ClientConfig):
|
|
|
87
95
|
)
|
|
88
96
|
|
|
89
97
|
|
|
90
|
-
async def upload(self, file: bytes, options: Union[FileUploadParams, None] = None) ->
|
|
98
|
+
async def upload(self, file: bytes, options: Union[FileUploadParams, None] = None) -> FileUploadResponse:
|
|
91
99
|
if options is None:
|
|
92
100
|
options = {}
|
|
93
101
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Union, cast
|
|
1
|
+
from typing import Any, Dict, List, Union, cast, overload
|
|
2
2
|
from typing_extensions import NotRequired, TypedDict
|
|
3
3
|
from .request import Request, RequestConfig
|
|
4
4
|
from .async_request import AsyncRequest
|
|
5
5
|
from typing import List, Union
|
|
6
6
|
from ._config import ClientConfig
|
|
7
|
-
|
|
7
|
+
from .helpers import build_path
|
|
8
8
|
|
|
9
9
|
class TranslateImageParams(TypedDict):
|
|
10
10
|
target_language: str
|
|
11
11
|
"""
|
|
12
12
|
Target langauge to translate to.
|
|
13
13
|
"""
|
|
14
|
-
url: str
|
|
14
|
+
url: NotRequired[str]
|
|
15
15
|
"""
|
|
16
16
|
The URL of the image to translate.
|
|
17
17
|
"""
|
|
@@ -82,7 +82,7 @@ class Translate(ClientConfig):
|
|
|
82
82
|
disable_request_logging=disable_request_logging,
|
|
83
83
|
)
|
|
84
84
|
|
|
85
|
-
def
|
|
85
|
+
def text(
|
|
86
86
|
self, params: TranslateParams
|
|
87
87
|
) -> Union[TranslateResponse, TranslateListResponse]:
|
|
88
88
|
resp = Request(
|
|
@@ -92,25 +92,41 @@ class Translate(ClientConfig):
|
|
|
92
92
|
verb="post",
|
|
93
93
|
).perform()
|
|
94
94
|
return resp
|
|
95
|
+
|
|
96
|
+
@overload
|
|
97
|
+
def image(self, params: TranslateImageParams) -> TranslateImageResponse: ...
|
|
98
|
+
@overload
|
|
99
|
+
def image(self, file: bytes, options: TranslateImageParams = None) -> TranslateImageParams: ...
|
|
100
|
+
|
|
101
|
+
def image(
|
|
102
|
+
self,
|
|
103
|
+
blob: Union[TranslateImageParams, bytes],
|
|
104
|
+
options: TranslateImageParams = None,
|
|
105
|
+
) -> TranslateImageResponse:
|
|
106
|
+
if isinstance(blob, dict): # If params is provided as a dict, we assume it's the first argument
|
|
107
|
+
resp = Request(
|
|
108
|
+
config=self.config,
|
|
109
|
+
path="/ai/translate/image",
|
|
110
|
+
params=cast(Dict[Any, Any], blob),
|
|
111
|
+
verb="post",
|
|
112
|
+
).perform_with_content()
|
|
113
|
+
return resp
|
|
114
|
+
|
|
115
|
+
options = options or {}
|
|
116
|
+
path = build_path(base_path="/ai/translate/image", params=options)
|
|
117
|
+
content_type = options.get("content_type", "application/octet-stream")
|
|
118
|
+
headers = {"Content-Type": content_type}
|
|
95
119
|
|
|
96
|
-
def translate_image(
|
|
97
|
-
self, params: TranslateImageParams
|
|
98
|
-
) -> TranslateImageResponse:
|
|
99
120
|
resp = Request(
|
|
100
121
|
config=self.config,
|
|
101
|
-
path=
|
|
102
|
-
params=
|
|
122
|
+
path=path,
|
|
123
|
+
params=options,
|
|
124
|
+
data=blob,
|
|
125
|
+
headers=headers,
|
|
103
126
|
verb="post",
|
|
104
|
-
).
|
|
127
|
+
).perform_with_content()
|
|
105
128
|
return resp
|
|
106
129
|
|
|
107
|
-
def translate(
|
|
108
|
-
self, params: Union[TranslateParams, TranslateImageParams]
|
|
109
|
-
) -> Union[TranslateResponse, TranslateListResponse, TranslateImageResponse]:
|
|
110
|
-
if "url" in params or "file_store_key" in params:
|
|
111
|
-
return self.translate_image(params)
|
|
112
|
-
return self.translate_text(params)
|
|
113
|
-
|
|
114
130
|
|
|
115
131
|
class AsyncTranslate(ClientConfig):
|
|
116
132
|
config: RequestConfig
|
|
@@ -128,7 +144,7 @@ class AsyncTranslate(ClientConfig):
|
|
|
128
144
|
disable_request_logging=disable_request_logging,
|
|
129
145
|
)
|
|
130
146
|
|
|
131
|
-
async def
|
|
147
|
+
async def text(
|
|
132
148
|
self, params: TranslateParams
|
|
133
149
|
) -> Union[TranslateResponse, TranslateListResponse]:
|
|
134
150
|
resp = await AsyncRequest(
|
|
@@ -138,21 +154,37 @@ class AsyncTranslate(ClientConfig):
|
|
|
138
154
|
verb="post",
|
|
139
155
|
).perform()
|
|
140
156
|
return resp
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
|
|
158
|
+
@overload
|
|
159
|
+
async def image(self, params: TranslateImageParams) -> TranslateImageResponse: ...
|
|
160
|
+
@overload
|
|
161
|
+
async def image(self, file: bytes, options: TranslateImageParams = None) -> TranslateImageParams: ...
|
|
162
|
+
|
|
163
|
+
async def image(
|
|
164
|
+
self,
|
|
165
|
+
blob: Union[TranslateImageParams, bytes],
|
|
166
|
+
options: TranslateImageParams = None,
|
|
144
167
|
) -> TranslateImageResponse:
|
|
168
|
+
if isinstance(blob, dict):
|
|
169
|
+
resp = await AsyncRequest(
|
|
170
|
+
config=self.config,
|
|
171
|
+
path="/ai/translate/image",
|
|
172
|
+
params=cast(Dict[Any, Any], blob),
|
|
173
|
+
verb="post",
|
|
174
|
+
).perform_with_content()
|
|
175
|
+
return resp
|
|
176
|
+
|
|
177
|
+
options = options or {}
|
|
178
|
+
path = build_path(base_path="/ai/translate/image", params=options)
|
|
179
|
+
content_type = options.get("content_type", "application/octet-stream")
|
|
180
|
+
headers = {"Content-Type": content_type}
|
|
181
|
+
|
|
145
182
|
resp = await AsyncRequest(
|
|
146
183
|
config=self.config,
|
|
147
|
-
path=
|
|
148
|
-
params=
|
|
184
|
+
path=path,
|
|
185
|
+
params=options,
|
|
186
|
+
data=blob,
|
|
187
|
+
headers=headers,
|
|
149
188
|
verb="post",
|
|
150
|
-
).
|
|
151
|
-
return resp
|
|
152
|
-
|
|
153
|
-
async def translate(
|
|
154
|
-
self, params: Union[TranslateParams, TranslateImageParams]
|
|
155
|
-
) -> Union[TranslateResponse, TranslateListResponse, TranslateImageResponse]:
|
|
156
|
-
if "url" in params or "file_store_key" in params:
|
|
157
|
-
return await self.translate_image(params)
|
|
158
|
-
return await self.translate_text(params)
|
|
189
|
+
).perform_with_content()
|
|
190
|
+
return resp
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Union, cast
|
|
1
|
+
from typing import Any, Dict, List, Union, cast, overload
|
|
2
2
|
from typing_extensions import NotRequired, TypedDict
|
|
3
3
|
from .request import Request, RequestConfig
|
|
4
4
|
from .async_request import AsyncRequest, AsyncRequestConfig
|
|
5
5
|
from ._config import ClientConfig
|
|
6
6
|
from typing import Any, Dict, List, cast
|
|
7
|
-
from typing_extensions import NotRequired, TypedDict
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict, Union, Optional
|
|
8
8
|
from .helpers import build_path
|
|
9
9
|
|
|
10
10
|
|
|
@@ -46,7 +46,9 @@ class ProfanityResponse(TypedDict):
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
class NSFWParams(TypedDict):
|
|
49
|
-
url: str
|
|
49
|
+
url: NotRequired[str]
|
|
50
|
+
file_store_key: NotRequired[str]
|
|
51
|
+
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
class NSFWResponse(TypedDict):
|
|
@@ -99,16 +101,25 @@ class Validate(ClientConfig):
|
|
|
99
101
|
verb="get",
|
|
100
102
|
).perform_with_content()
|
|
101
103
|
return resp
|
|
102
|
-
|
|
103
|
-
def nsfw(self, params: NSFWParams) -> NSFWResponse:
|
|
104
|
-
path
|
|
104
|
+
|
|
105
|
+
def nsfw(self, params: Union[NSFWParams, bytes]) -> NSFWResponse:
|
|
106
|
+
path="/validate/nsfw"
|
|
107
|
+
if isinstance(params, dict):
|
|
108
|
+
resp = Request(
|
|
109
|
+
config=self.config,
|
|
110
|
+
path=path,
|
|
111
|
+
params=cast(Dict[Any, Any], params),
|
|
112
|
+
verb="post",
|
|
113
|
+
).perform_with_content()
|
|
114
|
+
return resp
|
|
115
|
+
|
|
116
|
+
_headers = {"Content-Type": "application/octet-stream"}
|
|
105
117
|
resp = Request(
|
|
106
118
|
config=self.config,
|
|
107
119
|
path=path,
|
|
108
|
-
params=
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
),
|
|
120
|
+
params={}, #since we're already passing data.
|
|
121
|
+
data=params,
|
|
122
|
+
headers=_headers,
|
|
112
123
|
verb="post",
|
|
113
124
|
).perform_with_content()
|
|
114
125
|
return resp
|
|
@@ -170,7 +181,10 @@ class AsyncValidate(ClientConfig):
|
|
|
170
181
|
)
|
|
171
182
|
|
|
172
183
|
async def email(self, params: EmailValidationParams) -> EmailValidationResponse:
|
|
173
|
-
path =
|
|
184
|
+
path = build_path(
|
|
185
|
+
base_path="/validate/email",
|
|
186
|
+
params=params,
|
|
187
|
+
)
|
|
174
188
|
resp = await AsyncRequest(
|
|
175
189
|
config=self.config,
|
|
176
190
|
path=path,
|
|
@@ -178,16 +192,25 @@ class AsyncValidate(ClientConfig):
|
|
|
178
192
|
verb="get",
|
|
179
193
|
).perform_with_content()
|
|
180
194
|
return resp
|
|
181
|
-
|
|
182
|
-
async def nsfw(self, params: NSFWParams) -> NSFWResponse:
|
|
183
|
-
path
|
|
195
|
+
|
|
196
|
+
async def nsfw(self, params: Union[NSFWParams, bytes]) -> NSFWResponse:
|
|
197
|
+
path="/validate/nsfw"
|
|
198
|
+
if isinstance(params, dict):
|
|
199
|
+
resp = await AsyncRequest(
|
|
200
|
+
config=self.config,
|
|
201
|
+
path=path,
|
|
202
|
+
params=cast(Dict[Any, Any], params),
|
|
203
|
+
verb="post",
|
|
204
|
+
).perform_with_content()
|
|
205
|
+
return resp
|
|
206
|
+
|
|
207
|
+
_headers = {"Content-Type": "application/octet-stream"}
|
|
184
208
|
resp = await AsyncRequest(
|
|
185
209
|
config=self.config,
|
|
186
210
|
path=path,
|
|
187
|
-
params=
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
),
|
|
211
|
+
params={},
|
|
212
|
+
data=params,
|
|
213
|
+
headers=_headers,
|
|
191
214
|
verb="post",
|
|
192
215
|
).perform_with_content()
|
|
193
216
|
return resp
|
|
@@ -6,7 +6,7 @@ install_requires = open("requirements.txt").readlines()
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="jigsawstack",
|
|
9
|
-
version="0.2.
|
|
9
|
+
version="0.2.2",
|
|
10
10
|
description="JigsawStack - The AI SDK for Python",
|
|
11
11
|
long_description=open("README.md", encoding="utf8").read(),
|
|
12
12
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|