diff --git a/langchain_linkup/search_retriever.py b/langchain_linkup/search_retriever.py index bd4d9a2..3440f52 100644 --- a/langchain_linkup/search_retriever.py +++ b/langchain_linkup/search_retriever.py @@ -1,3 +1,4 @@ +from datetime import date from typing import Literal, Optional, cast from langchain_core.callbacks import ( @@ -31,6 +32,18 @@ class LinkupSearchRetriever(BaseRetriever): linkup_api_key: Optional[str] = None The API key for the Linkup API. If None (the default), the API key will be read from the environment variable `LINKUP_API_KEY`. + from_date: Optional[date] = None + The start date for the search + in datetime.date object, e.g. date(2025, 01, 01). + to_date: Optional[date] = None + The end date for the search + in datetime.date object, e.g. date(2025, 01, 01). + include_domains: Optional[list[str]] = None + The list of domains to search on (only those domains). + exclude_domains: Optional[list[str]] = None + The list of domains to exclude from the search. + include_image: bool = False + If set to True, image results will be included alongside text results. Instantiate: @@ -117,6 +130,18 @@ def format_docs(docs): linkup_api_key: Optional[str] = None """The API key for the Linkup API. If None, the API key will be read from the environment variable `LINKUP_API_KEY`.""" + from_date: Optional[date] = None + """The start date for the search + in datetime.date object, e.g. date(2025, 01, 01).""" + to_date: Optional[date] = None + """The end date for the search + in datetime.date object, e.g. date(2025, 01, 01).""" + include_domains: Optional[list[str]] = None + """The list of domains to search on (only those domains).""" + exclude_domains: Optional[list[str]] = None + """The list of domains to exclude from the search.""" + include_image: bool = False + """If set to True, image results will be included alongside text results.""" def _get_relevant_documents( self, @@ -129,7 +154,11 @@ def _get_relevant_documents( query=query, depth=self.depth, output_type="searchResults", - include_images=False, + include_images=self.include_image, + from_date=self.from_date, + to_date=self.to_date, + include_domains=self.include_domains, + exclude_domains=self.exclude_domains, ) return [ @@ -154,7 +183,11 @@ async def _aget_relevant_documents( query=query, depth=self.depth, output_type="searchResults", - include_images=False, + include_images=self.include_image, + from_date=self.from_date, + to_date=self.to_date, + include_domains=self.include_domains, + exclude_domains=self.exclude_domains, ) return [ diff --git a/langchain_linkup/search_tool.py b/langchain_linkup/search_tool.py index d1571fc..36c35f5 100644 --- a/langchain_linkup/search_tool.py +++ b/langchain_linkup/search_tool.py @@ -1,3 +1,4 @@ +from datetime import date from typing import Any, Literal, Optional, Type, Union from langchain_core.callbacks import ( @@ -43,6 +44,18 @@ class LinkupSearchTool(BaseTool): structured_output_schema: Union[Type[BaseModel], str, None] = None If output_type is "structured", specify the schema of the output. Supported formats are a pydantic.BaseModel or a string representing a valid object JSON schema. + from_date: Optional[date] = None + The start date for the search + in datetime.date object, e.g. date(2025, 01, 01). + to_date: Optional[date] = None + The end date for the search + in datetime.date object, e.g. date(2025, 01, 01). + include_domains: Optional[list[str]] = None + The list of domains to search on (only those domains). + exclude_domains: Optional[list[str]] = None + The list of domains to exclude from the search. + include_image: bool = False + If set to True, image results will be included alongside text results. Instantiate: .. code-block:: python @@ -120,6 +133,18 @@ class LinkupSearchTool(BaseTool): """If output_type is "structured", specify the schema of the output. Supported formats are a pydantic.BaseModel or a string representing a valid object JSON schema.""" + from_date: Optional[date] = None + """The start date for the search + in datetime.date object, e.g. date(2025, 01, 01).""" + to_date: Optional[date] = None + """The end date for the search + in datetime.date object, e.g. date(2025, 01, 01).""" + include_domains: Optional[list[str]] = None + """The list of domains to search on (only those domains).""" + exclude_domains: Optional[list[str]] = None + """The list of domains to exclude from the search.""" + include_image: bool = False + """If set to True, image results will be included alongside text results.""" # Fields used by the agent to describe how to use the tool under the hood name: str = "linkup" @@ -141,6 +166,11 @@ def _run( depth=self.depth, output_type=self.output_type, structured_output_schema=self.structured_output_schema, + from_date=self.from_date, + to_date=self.to_date, + include_domains=self.include_domains, + exclude_domains=self.exclude_domains, + include_images=self.include_image, ) async def _arun( @@ -154,4 +184,9 @@ async def _arun( depth=self.depth, output_type=self.output_type, structured_output_schema=self.structured_output_schema, + from_date=self.from_date, + to_date=self.to_date, + include_domains=self.include_domains, + exclude_domains=self.exclude_domains, + include_images=self.include_image, )