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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ classifiers = [

dependencies = [
"langchain-core",
"linkup-sdk>=0.2.8",
"linkup-sdk>=0.11.0",
]

[dependency-groups]
Expand Down
29 changes: 29 additions & 0 deletions src/langchain_linkup/search_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ class LinkupSearchRetriever(BaseRetriever):
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.
max_results: Optional[int] = None
The maximum number of results to return.
include_inline_citations: Optional[bool] = None
If output_type is "sourcedAnswer", indicate whether the answer should include inline
citations.
include_sources: Optional[bool] = None
If output_type is "structured", indicate whether the answer should include sources.
This will modify the schema of the structured response.
timeout: Optional[float] = None
The timeout for the HTTP request, in seconds. If None, the request will have
no timeout.

Instantiate:
.. code-block:: python
Expand Down Expand Up @@ -137,6 +148,16 @@ def format_docs(docs):
"""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."""
max_results: Optional[int] = None
"""The maximum number of results to return."""
include_inline_citations: Optional[bool] = None
"""If output_type is "sourcedAnswer", indicate whether the answer should include inline
citations."""
include_sources: Optional[bool] = None
"""If output_type is "structured", indicate whether the answer should include sources. This
will modify the schema of the structured response."""
timeout: Optional[float] = None
"""The timeout for the HTTP request, in seconds. If None, the request will have no timeout."""

def _get_relevant_documents(
self,
Expand All @@ -154,6 +175,10 @@ def _get_relevant_documents(
include_domains=self.include_domains,
exclude_domains=self.exclude_domains,
include_images=self.include_image,
max_results=self.max_results,
include_inline_citations=self.include_inline_citations,
include_sources=self.include_sources,
timeout=self.timeout,
)

return [
Expand Down Expand Up @@ -183,6 +208,10 @@ async def _aget_relevant_documents(
include_domains=self.include_domains,
exclude_domains=self.exclude_domains,
include_images=self.include_image,
max_results=self.max_results,
include_inline_citations=self.include_inline_citations,
include_sources=self.include_sources,
timeout=self.timeout,
)

return [
Expand Down
33 changes: 33 additions & 0 deletions src/langchain_linkup/search_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ class LinkupSearchTool(BaseTool):
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.
max_results: Optional[int] = None
The maximum number of results to return.
include_inline_citations: Optional[bool] = None
If output_type is "sourcedAnswer", indicate whether the answer should include inline
citations.
include_sources: Optional[bool] = None
If output_type is "structured", indicate whether the answer should include sources.
This will modify the schema of the structured response.
timeout: Optional[float] = None
The timeout for the HTTP request, in seconds. If None, the request will have
no timeout.

Instantiate:
.. code-block:: python
Expand All @@ -67,6 +78,10 @@ class LinkupSearchTool(BaseTool):
include_domains=None,
exclude_domains=None,
include_image=False,
max_results=None,
include_inline_citations=None,
include_sources=None,
timeout=None,
)

Usage:
Expand Down Expand Up @@ -143,6 +158,16 @@ class LinkupSearchTool(BaseTool):
"""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."""
max_results: Optional[int] = None
"""The maximum number of results to return."""
include_inline_citations: Optional[bool] = None
"""If output_type is "sourcedAnswer", indicate whether the answer should include inline
citations."""
include_sources: Optional[bool] = None
"""If output_type is "structured", indicate whether the answer should include sources. This
will modify the schema of the structured response."""
timeout: Optional[float] = None
"""The timeout for the HTTP request, in seconds. If None, the request will have no timeout."""

# Fields used by the agent to describe how to use the tool under the hood
name: str = "linkup"
Expand All @@ -169,6 +194,10 @@ def _run(
include_domains=self.include_domains,
exclude_domains=self.exclude_domains,
include_images=self.include_image,
max_results=self.max_results,
include_inline_citations=self.include_inline_citations,
include_sources=self.include_sources,
timeout=self.timeout,
)

async def _arun(
Expand All @@ -187,4 +216,8 @@ async def _arun(
include_domains=self.include_domains,
exclude_domains=self.exclude_domains,
include_images=self.include_image,
max_results=self.max_results,
include_inline_citations=self.include_inline_citations,
include_sources=self.include_sources,
timeout=self.timeout,
)
4 changes: 2 additions & 2 deletions tests/unit_tests/test_search_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def test_get_relevant_document(mocker: MockerFixture, linkup_api_key: str) -> None:
mocker.patch(
"linkup.client.LinkupClient._request",
"linkup.LinkupClient._request",
return_value=Response(
status_code=200,
content=b"""
Expand Down Expand Up @@ -41,7 +41,7 @@ def test_get_relevant_document(mocker: MockerFixture, linkup_api_key: str) -> No
@pytest.mark.asyncio
async def test_aget_relevant_documents(mocker: MockerFixture, linkup_api_key: str) -> None:
mocker.patch(
"linkup.client.LinkupClient._async_request",
"linkup.LinkupClient._async_request",
return_value=Response(
status_code=200,
content=b"""
Expand Down
42 changes: 33 additions & 9 deletions uv.lock

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