Skip to main content

Dria Retriever

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

Setup

To use Dria retriever, first install Dria JS client:

npm install dria

You need to provide two things to the retriever:

  • API Key: you can get yours at your profile page when you create an account.
  • 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 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:


Was this page helpful?


You can also leave detailed feedback on GitHub.