Skip to content

Commit 92f18f1

Browse files
Merge pull request #77 from JigsawStack/fix/types
Fix types
2 parents 48ca7dc + 0e690e0 commit 92f18f1

File tree

9 files changed

+54
-18
lines changed

9 files changed

+54
-18
lines changed

jigsawstack/embedding_v2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class EmbeddingV2Params(TypedDict):
1515
url: NotRequired[str]
1616
file_store_key: NotRequired[str]
1717
token_overflow_mode: NotRequired[Literal["truncate", "error"]]
18+
dimensions: NotRequired[int]
19+
instruction: NotRequired[str]
20+
query: NotRequired[bool]
1821
speaker_fingerprint: NotRequired[bool]
1922

2023

jigsawstack/prediction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Dict, List, Union, cast
22

3-
from typing_extensions import TypedDict
3+
from typing_extensions import NotRequired, TypedDict
44

55
from ._config import ClientConfig
66
from ._types import BaseResponse
@@ -25,9 +25,9 @@ class PredictionParams(TypedDict):
2525
"""
2626
The dataset to make predictions on. This is an array of object with keys date and value. See example below for more information.
2727
"""
28-
steps: int
28+
steps: NotRequired[int]
2929
"""
30-
The number of predictions to make. The default is 5.
30+
The number of predictions to make. Min: 1, Max: 500. Default: 5.
3131
"""
3232

3333

jigsawstack/prompt_engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class PromptEngineRunResponse(TypedDict):
4848

4949

5050
class PromptEngineCreateParams(TypedDict):
51+
name: NotRequired[str]
5152
prompt: str
5253
inputs: NotRequired[List[object]]
5354
return_prompt: Union[str, List[object], Dict[str, str]]

jigsawstack/search.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ class SearchParams(TypedDict):
193193
Whether to perform spell checking on the query. Defaults to True.
194194
"""
195195

196+
max_results: NotRequired[int]
197+
"""
198+
Maximum number of search results to return.
199+
"""
200+
196201
safe_search: NotRequired[Literal["strict", "moderate", "off"]]
197202
"""
198203
Safe search filtering level. Can be 'strict', 'moderate', or 'off'
@@ -241,14 +246,23 @@ def search(self, params: SearchParams) -> SearchResponse:
241246
safe_search = params.get("safe_search", "moderate")
242247
spell_check = params.get("spell_check", "True")
243248

244-
body = {
249+
body: Dict[str, Any] = {
245250
"byo_urls": params.get("byo_urls", []),
246251
"query": query,
247252
"ai_overview": ai_overview,
248253
"safe_search": safe_search,
249254
"spell_check": spell_check,
250255
}
251256

257+
if "max_results" in params:
258+
body["max_results"] = params["max_results"]
259+
260+
if "country_code" in params:
261+
body["country_code"] = params["country_code"]
262+
263+
if "auto_scrape" in params:
264+
body["auto_scrape"] = params["auto_scrape"]
265+
252266
path = "/web/search"
253267
resp = Request(
254268
config=self.config,
@@ -304,13 +318,23 @@ async def search(self, params: SearchParams) -> SearchResponse:
304318
safe_search = params.get("safe_search", "moderate")
305319
spell_check = params.get("spell_check", "True")
306320

307-
body = {
321+
body: Dict[str, Any] = {
308322
"byo_urls": params.get("byo_urls", []),
309323
"query": query,
310324
"ai_overview": ai_overview,
311325
"safe_search": safe_search,
312326
"spell_check": spell_check,
313327
}
328+
329+
if "max_results" in params:
330+
body["max_results"] = params["max_results"]
331+
332+
if "country_code" in params:
333+
body["country_code"] = params["country_code"]
334+
335+
if "auto_scrape" in params:
336+
body["auto_scrape"] = params["auto_scrape"]
337+
314338
resp = await AsyncRequest(
315339
config=self.config,
316340
path=path,

jigsawstack/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.3.9"
1+
__version__ = "0.4.0"
22

33

44
def get_version() -> str:

jigsawstack/vision.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ class VOCRParams(TypedDict):
150150
url: NotRequired[str]
151151
file_store_key: NotRequired[str]
152152
page_range: NotRequired[List[int]]
153+
fine_grained: NotRequired[bool]
154+
"""
155+
High fidelity word-level bounding boxes within complex documents. Default: false.
156+
"""
153157

154158

155159
class Word(TypedDict):

jigsawstack/web.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ class BaseAIScrapeParams(TypedDict):
128128

129129

130130
class AIScrapeParams(BaseAIScrapeParams):
131-
element_prompts: NotRequired[List[str]]
131+
element_prompts: NotRequired[Union[List[str], Dict[str, str]]]
132+
"""
133+
List of prompts or a dictionary of key-value prompts for element extraction.
134+
Max 5 items. If dict, max 50 chars per key and max 500 chars per prompt value.
135+
"""
132136
root_element_selector: NotRequired[str]
133137
page_position: NotRequired[int]
134138

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.3.9",
9+
version="0.4.0",
1010
description="JigsawStack - The AI SDK for Python",
1111
long_description=open("README.md", encoding="utf8").read(),
1212
long_description_content_type="text/markdown",

tests/test_ai_scrape.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@
7777
"is_mobile": True,
7878
},
7979
},
80-
{
81-
"name": "scrape_with_cookies",
82-
"params": {
83-
"url": URL,
84-
"element_prompts": ["user data"],
85-
"cookies": [
86-
{"name": "session", "value": "test123", "domain": "example.com"}
87-
],
88-
},
89-
},
80+
# {
81+
# "name": "scrape_with_cookies",
82+
# "params": {
83+
# "url": URL,
84+
# "element_prompts": ["user data"],
85+
# "cookies": [
86+
# {"name": "session", "value": "test123", "domain": "example.com"}
87+
# ],
88+
# },
89+
# },
9090
{
9191
"name": "scrape_with_advance_config",
9292
"params": {

0 commit comments

Comments
 (0)