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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LINKUP_API_KEY=
2 changes: 2 additions & 0 deletions examples/1_direct_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
for instance in a RAG system, with the output_type parameter set to "searchResults".
"""

from dotenv import load_dotenv
from rich import print

from linkup import LinkupClient

load_dotenv()
client = LinkupClient()

response = client.search(
Expand Down
2 changes: 2 additions & 0 deletions examples/2_sourced_answer_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
along with the sources supporting it.
"""

from dotenv import load_dotenv
from rich import print

from linkup import LinkupClient

load_dotenv()
client = LinkupClient()

response = client.search(
Expand Down
2 changes: 2 additions & 0 deletions examples/3_structured_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
documented schema to steer the Linkup search in any direction.
"""

from dotenv import load_dotenv
from pydantic import BaseModel, Field
from rich import print

Expand All @@ -19,6 +20,7 @@ class Events(BaseModel):
events: list[Event] = Field(description="The list of events")


load_dotenv()
client = LinkupClient()

response = client.search(
Expand Down
2 changes: 2 additions & 0 deletions examples/4_asynchronous_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import asyncio
import time

from dotenv import load_dotenv
from rich import print

from linkup import LinkupClient

load_dotenv()
client = LinkupClient()

queries: list[str] = [
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dev = [
"pytest-cov>=6.2.1",
"pytest-mock>=3.14.1",
"pytest>=8.4.1",
"python-dotenv>=1.1.1",
"rich>=14.1.0",
]

Expand Down
10 changes: 5 additions & 5 deletions src/linkup/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,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, list[str]]] = self._get_search_params(
params: dict[str, Union[str, bool, list[str], None]] = self._get_search_params(
query=query,
depth=depth,
output_type=output_type,
Expand Down Expand Up @@ -172,7 +172,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, list[str]]] = self._get_search_params(
params: dict[str, Union[str, bool, list[str], None]] = self._get_search_params(
query=query,
depth=depth,
output_type=output_type,
Expand Down Expand Up @@ -316,7 +316,7 @@ def _get_search_params(
include_domains: Union[list[str], None],
from_date: Union[date, None],
to_date: Union[date, None],
) -> dict[str, Union[str, bool, list[str]]]:
) -> dict[str, Union[str, bool, list[str], None]]:
structured_output_schema_param: str = ""
if structured_output_schema is not None:
if isinstance(structured_output_schema, str):
Expand All @@ -337,8 +337,8 @@ def _get_search_params(
includeImages=include_images,
excludeDomains=exclude_domains or [],
includeDomains=include_domains or [],
fromDate=from_date.isoformat() if from_date is not None else "",
toDate=to_date.isoformat() if to_date is not None else "",
fromDate=from_date.isoformat() if from_date is not None else None,
toDate=to_date.isoformat() if to_date is not None else date.today().isoformat(),
)

def _validate_search_response(
Expand Down
18 changes: 10 additions & 8 deletions tests/unit/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Company(BaseModel):
"includeImages": False,
"excludeDomains": [],
"includeDomains": [],
"fromDate": "",
"toDate": "",
"fromDate": None,
"toDate": "2000-01-01",
},
b"""
{
Expand Down Expand Up @@ -109,8 +109,8 @@ class Company(BaseModel):
"includeImages": False,
"excludeDomains": [],
"includeDomains": [],
"fromDate": "",
"toDate": "",
"fromDate": None,
"toDate": "2000-01-01",
},
b"""
{
Expand Down Expand Up @@ -158,8 +158,8 @@ class Company(BaseModel):
"includeImages": False,
"excludeDomains": [],
"includeDomains": [],
"fromDate": "",
"toDate": "",
"fromDate": None,
"toDate": "2000-01-01",
},
b"""
{
Expand Down Expand Up @@ -191,8 +191,8 @@ class Company(BaseModel):
"includeImages": False,
"excludeDomains": [],
"includeDomains": [],
"fromDate": "",
"toDate": "",
"fromDate": None,
"toDate": "2000-01-01",
},
b"""
{
Expand Down Expand Up @@ -225,6 +225,7 @@ def test_search(
mock_request_response_content: bytes,
expected_search_response: Any,
) -> None:
mocker.patch("linkup.client.date").today.return_value = date(2000, 1, 1)
request_mock = mocker.patch(
"linkup.client.LinkupClient._request",
return_value=Response(
Expand Down Expand Up @@ -257,6 +258,7 @@ async def test_async_search(
mock_request_response_content: bytes,
expected_search_response: Any,
) -> None:
mocker.patch("linkup.client.date").today.return_value = date(2000, 1, 1)
request_mock = mocker.patch(
"linkup.client.LinkupClient._async_request",
return_value=Response(
Expand Down
11 changes: 11 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.