Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion linkup/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.6"
__version__ = "0.2.7"
26 changes: 22 additions & 4 deletions linkup/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def search(
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: Union[Type[BaseModel], str, None] = None,
include_images: bool = False,
exclude_domains: Union[list[str], None] = None,
include_domains: Union[list[str], None] = None,
from_date: Union[date, None] = None,
to_date: Union[date, None] = None,
) -> Any:
Expand All @@ -72,6 +74,8 @@ def search(
valid object JSON schema.
include_images: If output_type is "searchResults", specifies if the response can include
images. Default to False.
exclude_domains: If you want to exclude specific domains from your search.
include_domains: If you want the search to only return results from certain domains.
from_date: The date from which the search results should be considered. If None, the
search results will not be filtered by date.
to_date: The date until which the search results should be considered. If None, the
Expand All @@ -93,12 +97,14 @@ def search(
LinkupInsufficientCreditError: If you have run out of credit.
LinkupNoResultError: If the search query did not yield any result.
"""
params: Dict[str, Union[str, bool]] = self._get_search_params(
params: Dict[str, Union[str, bool, list[str]]] = self._get_search_params(
query=query,
depth=depth,
output_type=output_type,
structured_output_schema=structured_output_schema,
include_images=include_images,
exclude_domains=exclude_domains,
include_domains=include_domains,
from_date=from_date,
to_date=to_date,
)
Expand All @@ -125,6 +131,8 @@ async def async_search(
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: Union[Type[BaseModel], str, None] = None,
include_images: bool = False,
exclude_domains: Union[list[str], None] = None,
include_domains: Union[list[str], None] = None,
from_date: Union[date, None] = None,
to_date: Union[date, None] = None,
) -> Any:
Expand All @@ -144,6 +152,8 @@ async def async_search(
valid object JSON schema.
include_images: If output_type is "searchResults", specifies if the response can include
images. Default to False
exclude_domains: If you want to exclude specific domains from your search.
include_domains: If you want the search to only return results from certain domains.
from_date: The date from which the search results should be considered. If None, the
search results will not be filtered by date.
to_date: The date until which the search results should be considered. If None, the
Expand All @@ -164,12 +174,14 @@ async def async_search(
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
available.
"""
params: Dict[str, Union[str, bool]] = self._get_search_params(
params: Dict[str, Union[str, bool, list[str]]] = self._get_search_params(
query=query,
depth=depth,
output_type=output_type,
structured_output_schema=structured_output_schema,
include_images=include_images,
exclude_domains=exclude_domains,
include_domains=include_domains,
from_date=from_date,
to_date=to_date,
)
Expand Down Expand Up @@ -303,9 +315,11 @@ def _get_search_params(
structured_output_schema: Union[Type[BaseModel], str, None],
include_images: bool,
from_date: Union[date, None],
include_domains: Union[list[str], None],
exclude_domains: Union[list[str], None],
to_date: Union[date, None],
) -> Dict[str, Union[str, bool]]:
params: Dict[str, Union[str, bool]] = dict(
) -> Dict[str, Union[str, bool, list[str]]]:
params: Dict[str, Union[str, bool, list[str]]] = dict(
q=query,
depth=depth,
outputType=output_type,
Expand All @@ -324,6 +338,10 @@ def _get_search_params(
)
if from_date is not None:
params["fromDate"] = from_date.isoformat()
if exclude_domains is not None:
params["excludeDomains"] = exclude_domains
if include_domains is not None:
params["includeDomains"] = include_domains
if to_date is not None:
params["toDate"] = to_date.isoformat()

Expand Down