Skip to content

Commit ab7cfc0

Browse files
authored
Merge pull request #25 from JigsawStack/update
Update
2 parents 593ad06 + 0321cc7 commit ab7cfc0

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

jigsawstack/store.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class KVAddParams(TypedDict):
2323
key: str
2424
value: str
2525
encrypt: NotRequired[bool]
26+
byo_secret: NotRequired[str]
2627

2728

2829
class KVAddResponse(TypedDict):

jigsawstack/summary.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
from typing import Any, Dict, List, Union, cast
1+
from typing import Any, Dict, List, Union, cast, Literal
22
from typing_extensions import NotRequired, TypedDict
33
from .request import Request, RequestConfig
44
from typing import List, Union
55
from ._config import ClientConfig
66

77

88
class SummaryParams(TypedDict):
9-
text: str
9+
text: NotRequired[str]
1010
"""
1111
The text to summarize.
1212
"""
1313

14-
type: NotRequired[str]
14+
type: NotRequired[Literal["text", "points"]]
1515

1616
"""
1717
The summary result type. Supported values are: text, points
1818
"""
19+
url: NotRequired[str]
20+
file_store_key: NotRequired[str]
21+
max_points: NotRequired[int]
22+
max_characters: NotRequired[int]
1923

2024

2125
class SummaryResponse(TypedDict):
@@ -29,6 +33,17 @@ class SummaryResponse(TypedDict):
2933
"""
3034

3135

36+
class SummaryListResponse(TypedDict):
37+
success: bool
38+
"""
39+
Indicates whether the translation was successful.
40+
"""
41+
summary: List[str]
42+
"""
43+
The summarized text.
44+
"""
45+
46+
3247
class Summary(ClientConfig):
3348

3449
config: RequestConfig
@@ -46,7 +61,9 @@ def __init__(
4661
disable_request_logging=disable_request_logging,
4762
)
4863

49-
def summarize(self, params: SummaryParams) -> SummaryResponse:
64+
def summarize(
65+
self, params: SummaryParams
66+
) -> Union[SummaryResponse, SummaryListResponse]:
5067
path = "/ai/summary"
5168
resp = Request(
5269
config=self.config,

jigsawstack/translate.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TranslateParams(TypedDict):
1414
"""
1515
Language to translate from.
1616
"""
17-
text: str
17+
text: Union[str, list[str]]
1818
"""
1919
The text to translate.
2020
"""
@@ -31,6 +31,17 @@ class TranslateResponse(TypedDict):
3131
"""
3232

3333

34+
class TranslateListResponse(TypedDict):
35+
success: bool
36+
"""
37+
Indicates whether the translation was successful.
38+
"""
39+
translated_text: List[str]
40+
"""
41+
The translated text.
42+
"""
43+
44+
3445
class Translate(ClientConfig):
3546

3647
config: RequestConfig
@@ -48,7 +59,9 @@ def __init__(
4859
disable_request_logging=disable_request_logging,
4960
)
5061

51-
def translate(self, params: TranslateParams) -> TranslateResponse:
62+
def translate(
63+
self, params: TranslateParams
64+
) -> Union[TranslateResponse, TranslateListResponse]:
5265
path = "/ai/translate"
5366
resp = Request(
5467
config=self.config,

jigsawstack/validate.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,29 @@ def email(self, params: EmailValidationParams) -> EmailValidationResponse:
9696
return resp
9797

9898
def nsfw(self, url: str) -> NSFWResponse:
99-
path = f"/validate/nsfw?url={url}"
99+
path = f"/validate/nsfw"
100100
resp = Request(
101101
config=self.config,
102102
path=path,
103-
params=cast(Dict[Any, Any], params={"url": url}),
104-
verb="get",
103+
params=cast(
104+
Dict[Any, Any],
105+
params={"url": url},
106+
),
107+
verb="post",
105108
).perform_with_content()
106109
return resp
107110

108111
def profanity(self, params: ProfanityParams) -> ProfanityResponse:
109112
text = params.get("text")
110113
censor_replacement = params.get("censor_replacement", "*")
111-
path = (
112-
f"/validate/profanity?text={text}&censor_replacement={censor_replacement}"
113-
)
114+
path = f"/validate/profanity"
114115
resp = Request(
115116
config=self.config,
116117
path=path,
117-
params=cast(Dict[Any, Any], params),
118-
verb="get",
118+
params=cast(
119+
Dict[Any, Any], {"text": text, "censor_replacement": censor_replacement}
120+
),
121+
verb="post",
119122
).perform_with_content()
120123
return resp
121124

@@ -127,12 +130,12 @@ def spellcheck(self, params: SpellCheckParams) -> SpellCheckResponse:
127130
config=self.config,
128131
path=path,
129132
params=cast(Dict[Any, Any], params),
130-
verb="get",
133+
verb="post",
131134
).perform_with_content()
132135
return resp
133136

134137
def spamcheck(self, params: SpamCheckParams) -> SpamCheckResponse:
135-
path = "/ai/spamcheck"
138+
path = "/validate/spam_check"
136139
resp = Request(
137140
config=self.config,
138141
path=path,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="jigsawstack",
9-
version="0.1.18",
9+
version="0.1.19",
1010
description="JigsawStack Python SDK",
1111
long_description=open("README.md", encoding="utf8").read(),
1212
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)