Skip to main content

Dria Retriever

Dria 检索器允许代理在综合知识中心执行基于文本的搜索。

¥The Dria retriever allows an agent to perform a text-based search across a comprehensive knowledge hub.

设置

¥Setup

要使用 Dria Retriever,请先安装 Dria JS 客户端:

¥To use Dria retriever, first install Dria JS client:

npm install dria

你需要向检索器提供两项信息:

¥You need to provide two things to the retriever:

  • API 密钥:你可以在创建账户时在 个人资料页面 上获取你的版本。

    ¥API Key: you can get yours at your profile page when you create an account.

  • 合约 ID:可在查看知识时在页面顶部或其 URL 中访问。例如,比特币白皮书上传到 Dria 的 https://dria.co/knowledge/2KxNbEb040GKQ1DSDNDsA-Fsj_BlQIEAlzBNuiapBR0 上,因此其合约 ID 为 2KxNbEb040GKQ1DSDNDsA-Fsj_BlQIEAlzBNuiapBR0。合约 ID 可以在实例化过程中省略,之后可以通过 dria.contractId = "your-contract" 设置。

    ¥Contract ID: accessible at the top of the page when viewing a knowledge or in its URL. For example, the Bitcoin whitepaper is uploaded on Dria at https://dria.co/knowledge/2KxNbEb040GKQ1DSDNDsA-Fsj_BlQIEAlzBNuiapBR0, so its contract ID is 2KxNbEb040GKQ1DSDNDsA-Fsj_BlQIEAlzBNuiapBR0. Contract ID can be omitted during instantiation, and later be set via dria.contractId = "your-contract"

Dria 检索器也公开了底层 Dria 客户端,请参阅 Dria 文档 了解有关客户端的更多信息。

¥Dria retriever exposes the underlying Dria client as well, refer to the Dria documentation to learn more about the client.

用法

¥Usage

npm install dria @langchain/community @langchain/core
import { DriaRetriever } from "@langchain/community/retrievers/dria";

// contract of TypeScript Handbook v4.9 uploaded to Dria
// https://dria.co/knowledge/-B64DjhUtCwBdXSpsRytlRQCu-bie-vSTvTIT8Ap3g0
const contractId = "-B64DjhUtCwBdXSpsRytlRQCu-bie-vSTvTIT8Ap3g0";

const retriever = new DriaRetriever({
contractId, // a knowledge to connect to
apiKey: "DRIA_API_KEY", // if not provided, will check env for `DRIA_API_KEY`
topK: 15, // optional: default value is 10
});

const docs = await retriever.invoke("What is a union type?");
console.log(docs);

API Reference:

¥Related