Skip to main content

NucliaDB

你可以使用本地的 NucliaDB 实例,也可以使用Nuclia Cloud

当使用本地实例时,你需要一个 Nuclia Understanding API 密钥,这样你的文本才能被正确向量化和索引。你可以通过在https://nuclia.cloud创建一个免费账户,然后创建一个 NUA 密钥来获取密钥。

%pip install --upgrade --quiet  langchain 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)

在本地实例中使用

注意:默认情况下 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")

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

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)

Was this page helpful?


You can leave detailed feedback on GitHub.