Skip to content
3 changes: 3 additions & 0 deletions jigsawstack/embedding_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class EmbeddingV2Params(TypedDict):
url: NotRequired[str]
file_store_key: NotRequired[str]
token_overflow_mode: NotRequired[Literal["truncate", "error"]]
dimensions: NotRequired[int]
instruction: NotRequired[str]
query: NotRequired[bool]
speaker_fingerprint: NotRequired[bool]


Expand Down
6 changes: 3 additions & 3 deletions jigsawstack/prediction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Union, cast

from typing_extensions import TypedDict
from typing_extensions import NotRequired, TypedDict

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


Expand Down
1 change: 1 addition & 0 deletions jigsawstack/prompt_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class PromptEngineRunResponse(TypedDict):


class PromptEngineCreateParams(TypedDict):
name: NotRequired[str]
prompt: str
inputs: NotRequired[List[object]]
return_prompt: Union[str, List[object], Dict[str, str]]
Expand Down
28 changes: 26 additions & 2 deletions jigsawstack/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ class SearchParams(TypedDict):
Whether to perform spell checking on the query. Defaults to True.
"""

max_results: NotRequired[int]
"""
Maximum number of search results to return.
"""

safe_search: NotRequired[Literal["strict", "moderate", "off"]]
"""
Safe search filtering level. Can be 'strict', 'moderate', or 'off'
Expand Down Expand Up @@ -241,14 +246,23 @@ def search(self, params: SearchParams) -> SearchResponse:
safe_search = params.get("safe_search", "moderate")
spell_check = params.get("spell_check", "True")

body = {
body: Dict[str, Any] = {
"byo_urls": params.get("byo_urls", []),
"query": query,
"ai_overview": ai_overview,
"safe_search": safe_search,
"spell_check": spell_check,
}

if "max_results" in params:
body["max_results"] = params["max_results"]

if "country_code" in params:
body["country_code"] = params["country_code"]

if "auto_scrape" in params:
body["auto_scrape"] = params["auto_scrape"]

path = "/web/search"
resp = Request(
config=self.config,
Expand Down Expand Up @@ -304,13 +318,23 @@ async def search(self, params: SearchParams) -> SearchResponse:
safe_search = params.get("safe_search", "moderate")
spell_check = params.get("spell_check", "True")

body = {
body: Dict[str, Any] = {
"byo_urls": params.get("byo_urls", []),
"query": query,
"ai_overview": ai_overview,
"safe_search": safe_search,
"spell_check": spell_check,
}

if "max_results" in params:
body["max_results"] = params["max_results"]

if "country_code" in params:
body["country_code"] = params["country_code"]

if "auto_scrape" in params:
body["auto_scrape"] = params["auto_scrape"]

resp = await AsyncRequest(
config=self.config,
path=path,
Expand Down
2 changes: 1 addition & 1 deletion jigsawstack/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.3.9"
__version__ = "0.4.0"


def get_version() -> str:
Expand Down
4 changes: 4 additions & 0 deletions jigsawstack/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ class VOCRParams(TypedDict):
url: NotRequired[str]
file_store_key: NotRequired[str]
page_range: NotRequired[List[int]]
fine_grained: NotRequired[bool]
"""
High fidelity word-level bounding boxes within complex documents. Default: false.
"""


class Word(TypedDict):
Expand Down
6 changes: 5 additions & 1 deletion jigsawstack/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ class BaseAIScrapeParams(TypedDict):


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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="jigsawstack",
version="0.3.9",
version="0.4.0",
description="JigsawStack - The AI SDK for Python",
long_description=open("README.md", encoding="utf8").read(),
long_description_content_type="text/markdown",
Expand Down
20 changes: 10 additions & 10 deletions tests/test_ai_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@
"is_mobile": True,
},
},
{
"name": "scrape_with_cookies",
"params": {
"url": URL,
"element_prompts": ["user data"],
"cookies": [
{"name": "session", "value": "test123", "domain": "example.com"}
],
},
},
# {
# "name": "scrape_with_cookies",
# "params": {
# "url": URL,
# "element_prompts": ["user data"],
# "cookies": [
# {"name": "session", "value": "test123", "domain": "example.com"}
# ],
# },
# },
{
"name": "scrape_with_advance_config",
"params": {
Expand Down