mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-17 23:41:46 +00:00
community[minor]: Added integrations for ThirdAI's NeuralDB as a Retriever (#17334)
**Description:** Adds ThirdAI NeuralDB retriever integration. NeuralDB is a CPU-friendly and fine-tunable text retrieval engine. We previously added a vector store integration but we think that it will be easier for our customers if they can also find us under under langchain-community/retrievers. --------- Co-authored-by: kartikTAI <129414343+kartikTAI@users.noreply.github.com> Co-authored-by: Kartik Sarangmath <kartik@thirdai.com>
This commit is contained in:
@@ -86,48 +86,6 @@ class NeuralDBVectorStore(VectorStore):
|
||||
|
||||
return cls(db=ndb.NeuralDB(**model_kwargs)) # type: ignore[call-arg]
|
||||
|
||||
@classmethod
|
||||
def from_bazaar( # type: ignore[no-untyped-def]
|
||||
cls,
|
||||
base: str,
|
||||
bazaar_cache: Optional[str] = None,
|
||||
thirdai_key: Optional[str] = None,
|
||||
):
|
||||
"""
|
||||
Create a NeuralDBVectorStore with a base model from the ThirdAI
|
||||
model bazaar.
|
||||
|
||||
To use, set the ``THIRDAI_KEY`` environment variable with your ThirdAI
|
||||
API key, or pass ``thirdai_key`` as a named parameter.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
from langchain_community.vectorstores import NeuralDBVectorStore
|
||||
|
||||
vectorstore = NeuralDBVectorStore.from_bazaar(
|
||||
base="General QnA",
|
||||
thirdai_key="your-thirdai-key",
|
||||
)
|
||||
|
||||
vectorstore.insert([
|
||||
"/path/to/doc.pdf",
|
||||
"/path/to/doc.docx",
|
||||
"/path/to/doc.csv",
|
||||
])
|
||||
|
||||
documents = vectorstore.similarity_search("AI-driven music therapy")
|
||||
"""
|
||||
NeuralDBVectorStore._verify_thirdai_library(thirdai_key)
|
||||
from thirdai import neural_db as ndb
|
||||
|
||||
cache = bazaar_cache or str(Path(os.getcwd()) / "model_bazaar")
|
||||
if not os.path.exists(cache):
|
||||
os.mkdir(cache)
|
||||
model_bazaar = ndb.Bazaar(cache)
|
||||
model_bazaar.fetch()
|
||||
return cls(db=model_bazaar.get_model(base)) # type: ignore[call-arg]
|
||||
|
||||
@classmethod
|
||||
def from_checkpoint( # type: ignore[no-untyped-def]
|
||||
cls,
|
||||
|
Reference in New Issue
Block a user