-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from hubkrieb/main
Add LangChain Integration
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
_all__ = [] | ||
|
||
try: | ||
from byaldi.integrations._langchain import ByaldiLangChainRetriever | ||
|
||
_all__.append("ByaldiLangChainRetriever") | ||
except ImportError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Any, List | ||
|
||
from langchain_core.callbacks.manager import CallbackManagerForRetrieverRun | ||
from langchain_core.retrievers import BaseRetriever | ||
|
||
from byaldi.objects import Result | ||
|
||
|
||
class ByaldiLangChainRetriever(BaseRetriever): | ||
model: Any | ||
kwargs: dict = {} | ||
|
||
def _get_relevant_documents( | ||
self, | ||
query: str, | ||
*, | ||
run_manager: CallbackManagerForRetrieverRun, # noqa | ||
) -> List[Result]: | ||
"""Get documents relevant to a query.""" | ||
docs = self.model.search(query, **self.kwargs) | ||
return docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters