From 16be57e8fcc4f2ea11423f0dd60ff90ebe008087 Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Mon, 16 Jun 2025 10:46:43 +0200 Subject: [PATCH 1/3] add obligations and restrictions fields --- linkup/_version.py | 2 +- linkup/client.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/linkup/_version.py b/linkup/_version.py index 01ef120..6cd38b7 100644 --- a/linkup/_version.py +++ b/linkup/_version.py @@ -1 +1 @@ -__version__ = "0.2.6" +__version__ = "0.2.7" diff --git a/linkup/client.py b/linkup/client.py index 7a37980..b37c79b 100644 --- a/linkup/client.py +++ b/linkup/client.py @@ -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, + restrictions: list[str] = None, + obligations: list[str] = None, from_date: Union[date, None] = None, to_date: Union[date, None] = None, ) -> Any: @@ -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. + restrictions: If you want to exclude specific domains from your search. + obligations: 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 @@ -99,6 +103,8 @@ def search( output_type=output_type, structured_output_schema=structured_output_schema, include_images=include_images, + restrictions=restrictions, + obligations=obligations, from_date=from_date, to_date=to_date, ) @@ -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, + restrictions: list[str] = None, + obligations: list[str] = None, from_date: Union[date, None] = None, to_date: Union[date, None] = None, ) -> Any: @@ -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 + restrictions: If you want to exclude specific domains from your search. + obligations: 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 @@ -170,6 +180,8 @@ async def async_search( output_type=output_type, structured_output_schema=structured_output_schema, include_images=include_images, + restrictions=restrictions, + obligations=obligations, from_date=from_date, to_date=to_date, ) @@ -303,6 +315,8 @@ def _get_search_params( structured_output_schema: Union[Type[BaseModel], str, None], include_images: bool, from_date: Union[date, None], + obligations: list[str], + restrictions: list[str], to_date: Union[date, None], ) -> Dict[str, Union[str, bool]]: params: Dict[str, Union[str, bool]] = dict( @@ -324,6 +338,10 @@ def _get_search_params( ) if from_date is not None: params["fromDate"] = from_date.isoformat() + if restrictions is not None: + params["restrictions"] = restrictions + if obligations is not None: + params["obligations"] = obligations if to_date is not None: params["toDate"] = to_date.isoformat() From a1461bb9ed9a1eb5a90c525607ec80fbba2dfd0b Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Mon, 16 Jun 2025 11:12:43 +0200 Subject: [PATCH 2/3] types good --- linkup/client.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/linkup/client.py b/linkup/client.py index b37c79b..c82358a 100644 --- a/linkup/client.py +++ b/linkup/client.py @@ -53,8 +53,8 @@ def search( output_type: Literal["searchResults", "sourcedAnswer", "structured"], structured_output_schema: Union[Type[BaseModel], str, None] = None, include_images: bool = False, - restrictions: list[str] = None, - obligations: list[str] = None, + restrictions: Union[list[str], None] = None, + obligations: Union[list[str], None] = None, from_date: Union[date, None] = None, to_date: Union[date, None] = None, ) -> Any: @@ -97,7 +97,7 @@ 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, @@ -131,8 +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, - restrictions: list[str] = None, - obligations: list[str] = None, + restrictions: Union[list[str], None] = None, + obligations: Union[list[str], None] = None, from_date: Union[date, None] = None, to_date: Union[date, None] = None, ) -> Any: @@ -174,7 +174,7 @@ 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, @@ -315,11 +315,11 @@ def _get_search_params( structured_output_schema: Union[Type[BaseModel], str, None], include_images: bool, from_date: Union[date, None], - obligations: list[str], - restrictions: list[str], + obligations: Union[list[str], None], + restrictions: 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, From 051802e93c567ddee7a2c5c32986f800fc2992b5 Mon Sep 17 00:00:00 2001 From: Juliette0704 Date: Tue, 17 Jun 2025 09:34:00 +0200 Subject: [PATCH 3/3] rename --- linkup/client.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/linkup/client.py b/linkup/client.py index c82358a..26a2663 100644 --- a/linkup/client.py +++ b/linkup/client.py @@ -53,8 +53,8 @@ def search( output_type: Literal["searchResults", "sourcedAnswer", "structured"], structured_output_schema: Union[Type[BaseModel], str, None] = None, include_images: bool = False, - restrictions: Union[list[str], None] = None, - obligations: Union[list[str], None] = None, + 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: @@ -74,8 +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. - restrictions: If you want to exclude specific domains from your search. - obligations: If you want the search to only return results from certain domains. + 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 @@ -103,8 +103,8 @@ def search( output_type=output_type, structured_output_schema=structured_output_schema, include_images=include_images, - restrictions=restrictions, - obligations=obligations, + exclude_domains=exclude_domains, + include_domains=include_domains, from_date=from_date, to_date=to_date, ) @@ -131,8 +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, - restrictions: Union[list[str], None] = None, - obligations: Union[list[str], None] = None, + 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: @@ -152,8 +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 - restrictions: If you want to exclude specific domains from your search. - obligations: If you want the search to only return results from certain domains. + 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 @@ -180,8 +180,8 @@ async def async_search( output_type=output_type, structured_output_schema=structured_output_schema, include_images=include_images, - restrictions=restrictions, - obligations=obligations, + exclude_domains=exclude_domains, + include_domains=include_domains, from_date=from_date, to_date=to_date, ) @@ -315,8 +315,8 @@ def _get_search_params( structured_output_schema: Union[Type[BaseModel], str, None], include_images: bool, from_date: Union[date, None], - obligations: Union[list[str], None], - restrictions: Union[list[str], None], + include_domains: Union[list[str], None], + exclude_domains: Union[list[str], None], to_date: Union[date, None], ) -> Dict[str, Union[str, bool, list[str]]]: params: Dict[str, Union[str, bool, list[str]]] = dict( @@ -338,10 +338,10 @@ def _get_search_params( ) if from_date is not None: params["fromDate"] = from_date.isoformat() - if restrictions is not None: - params["restrictions"] = restrictions - if obligations is not None: - params["obligations"] = obligations + 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()