NucliaDB
您可以使用本地 NucliaDB 实例或使用 Nuclia Cloud。
当使用本地实例时,您需要一个 Nuclia Understanding 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 Reference: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 Reference: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)
Related
- Vector store conceptual guide
- Vector store how-to guides