Skip to main content

金属检索器

该示例展示了如何在“检索QAChain”中使用金属检索器从金属索引中检索文档。

设置

npm i @getmetal/metal-sdk

用法

/* eslint-disable @typescript-eslint/no-non-null-assertion */
import Metal from "@getmetal/metal-sdk";
import { MetalRetriever } from "langchain/retrievers/metal";

export const run = async () => {
const MetalSDK = Metal;

const client = new MetalSDK(
process.env.METAL_API_KEY!,
process.env.METAL_CLIENT_ID!,
process.env.METAL_INDEX_ID
);
const retriever = new MetalRetriever({ client });

const docs = await retriever.getRelevantDocuments("hello");

console.log(docs);
};