跳到主要内容
本示例展示了如何在检索链中使用 Metal Retriever 从 Metal 索引中检索文档。

设置

有关安装 LangChain 软件包的一般说明,请参阅此部分
npm
npm i @getmetal/metal-sdk @langchain/community @langchain/core

用法

/* eslint-disable @typescript-eslint/no-non-null-assertion */
import Metal from "@getmetal/metal-sdk";
import { MetalRetriever } from "@langchain/community/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.invoke("hello");

  console.log(docs);
};

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.