Skip to content

Commit 95600bf

Browse files
authored
add obligations and restrictions fields (#29)
* add obligations and restrictions fields * types good * rename
1 parent a524cc4 commit 95600bf

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

linkup/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.6"
1+
__version__ = "0.2.7"

linkup/client.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def search(
5353
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
5454
structured_output_schema: Union[Type[BaseModel], str, None] = None,
5555
include_images: bool = False,
56+
exclude_domains: Union[list[str], None] = None,
57+
include_domains: Union[list[str], None] = None,
5658
from_date: Union[date, None] = None,
5759
to_date: Union[date, None] = None,
5860
) -> Any:
@@ -72,6 +74,8 @@ def search(
7274
valid object JSON schema.
7375
include_images: If output_type is "searchResults", specifies if the response can include
7476
images. Default to False.
77+
exclude_domains: If you want to exclude specific domains from your search.
78+
include_domains: If you want the search to only return results from certain domains.
7579
from_date: The date from which the search results should be considered. If None, the
7680
search results will not be filtered by date.
7781
to_date: The date until which the search results should be considered. If None, the
@@ -93,12 +97,14 @@ def search(
9397
LinkupInsufficientCreditError: If you have run out of credit.
9498
LinkupNoResultError: If the search query did not yield any result.
9599
"""
96-
params: Dict[str, Union[str, bool]] = self._get_search_params(
100+
params: Dict[str, Union[str, bool, list[str]]] = self._get_search_params(
97101
query=query,
98102
depth=depth,
99103
output_type=output_type,
100104
structured_output_schema=structured_output_schema,
101105
include_images=include_images,
106+
exclude_domains=exclude_domains,
107+
include_domains=include_domains,
102108
from_date=from_date,
103109
to_date=to_date,
104110
)
@@ -125,6 +131,8 @@ async def async_search(
125131
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
126132
structured_output_schema: Union[Type[BaseModel], str, None] = None,
127133
include_images: bool = False,
134+
exclude_domains: Union[list[str], None] = None,
135+
include_domains: Union[list[str], None] = None,
128136
from_date: Union[date, None] = None,
129137
to_date: Union[date, None] = None,
130138
) -> Any:
@@ -144,6 +152,8 @@ async def async_search(
144152
valid object JSON schema.
145153
include_images: If output_type is "searchResults", specifies if the response can include
146154
images. Default to False
155+
exclude_domains: If you want to exclude specific domains from your search.
156+
include_domains: If you want the search to only return results from certain domains.
147157
from_date: The date from which the search results should be considered. If None, the
148158
search results will not be filtered by date.
149159
to_date: The date until which the search results should be considered. If None, the
@@ -164,12 +174,14 @@ async def async_search(
164174
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
165175
available.
166176
"""
167-
params: Dict[str, Union[str, bool]] = self._get_search_params(
177+
params: Dict[str, Union[str, bool, list[str]]] = self._get_search_params(
168178
query=query,
169179
depth=depth,
170180
output_type=output_type,
171181
structured_output_schema=structured_output_schema,
172182
include_images=include_images,
183+
exclude_domains=exclude_domains,
184+
include_domains=include_domains,
173185
from_date=from_date,
174186
to_date=to_date,
175187
)
@@ -303,9 +315,11 @@ def _get_search_params(
303315
structured_output_schema: Union[Type[BaseModel], str, None],
304316
include_images: bool,
305317
from_date: Union[date, None],
318+
include_domains: Union[list[str], None],
319+
exclude_domains: Union[list[str], None],
306320
to_date: Union[date, None],
307-
) -> Dict[str, Union[str, bool]]:
308-
params: Dict[str, Union[str, bool]] = dict(
321+
) -> Dict[str, Union[str, bool, list[str]]]:
322+
params: Dict[str, Union[str, bool, list[str]]] = dict(
309323
q=query,
310324
depth=depth,
311325
outputType=output_type,
@@ -324,6 +338,10 @@ def _get_search_params(
324338
)
325339
if from_date is not None:
326340
params["fromDate"] = from_date.isoformat()
341+
if exclude_domains is not None:
342+
params["excludeDomains"] = exclude_domains
343+
if include_domains is not None:
344+
params["includeDomains"] = include_domains
327345
if to_date is not None:
328346
params["toDate"] = to_date.isoformat()
329347

0 commit comments

Comments
 (0)