跳到主要內容

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 參考:NucliaDB

使用本地實例

注意:預設情況下,backend 設定為 https://127.0.0.1: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)

這個頁面有幫助嗎?