Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use text search results #4

Merged
merged 1 commit into from
Jan 11, 2025
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install-dev:
test:
@echo "Running tests..."
pre-commit run --all-files
mypy .
mypy langchain_linkup
# Follow the test practices recommanded by LangChain (v0.3)
# See https://python.langchain.com/docs/contributing/how_to/integrations/standard_tests/
pytest --cov=langchain_linkup/ --cov-report term-missing --disable-socket --allow-unix-socket tests/unit_tests
Expand Down
10 changes: 6 additions & 4 deletions langchain_linkup/search_retriever.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Literal, Optional
from typing import Literal, Optional, cast

from langchain_core.callbacks import (
AsyncCallbackManagerForRetrieverRun,
CallbackManagerForRetrieverRun,
)
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever
from linkup import LinkupClient, LinkupSearchResults
from linkup import LinkupClient, LinkupSearchResults, LinkupSearchTextResult


class LinkupSearchRetriever(BaseRetriever):
Expand Down Expand Up @@ -129,11 +129,12 @@ def _get_relevant_documents(
query=query,
depth=self.depth,
output_type="searchResults",
include_images=False,
)

return [
Document(
page_content=result.content,
page_content=cast(LinkupSearchTextResult, result).content,
metadata=dict(
name=result.name,
url=result.url,
Expand All @@ -153,11 +154,12 @@ async def _aget_relevant_documents(
query=query,
depth=self.depth,
output_type="searchResults",
include_images=False,
)

return [
Document(
page_content=result.content,
page_content=cast(LinkupSearchTextResult, result).content,
metadata=dict(
name=result.name,
url=result.url,
Expand Down
Loading