Skip to main content
Open In ColabOpen on GitHub

NucliaDB

您可以使用本地的 NucliaDB 实例,或使用 Nuclia Cloud

使用本地实例时,您需要一个 Nuclia 理解 API 密钥,以便正确地对您的文本进行向量化和索引。您可以通过在 https://nuclia.cloud 创建一个免费账户,然后创建一个 NUA 密钥来获取密钥。

%pip install --upgrade --quiet  langchain langchain-community nuclia

使用 nuclia.cloud

from langchain_community.vectorstores.nucliadb import NucliaDB

API_KEY = "YOUR_API_KEY"

ndb = NucliaDB(knowledge_box="YOUR_KB_ID", local=False, api_key=API_KEY)
API 参考:NucliaDB

使用本地实例

注意:默认情况下,backend 被设置为 http://localhost:8080

from langchain_community.vectorstores.nucliadb import NucliaDB

ndb = NucliaDB(knowledge_box="YOUR_KB_ID", local=True, backend="http://my-local-server")
API 参考:NucliaDB

向您的知识库中添加和删除文本

ids = ndb.add_texts(["This is a new test", "This is a second test"])
ndb.delete(ids=ids)

在您的知识库中搜索

results = ndb.similarity_search("Who was inspired by Ada Lovelace?")
print(results[0].page_content)