跳到主要内容

Alchemyst AI Retriever

Alchemyst AI Retriever 使您的生成式 AI 应用程序能够检索相关的上下文和知识。它从 Alchemyst 平台获取这些信息。它提供了一个统一的接口,用于访问、搜索和检索数据,以增强 LLM 和代理的响应。

设置

  1. 如果您还没有帐户,请在 Alchemyst 平台注册一个新帐户
  2. 登录后,请前往Alchemyst 平台设置以获取您的 API 密钥。
有关安装 LangChain 软件包的一般说明,请参阅此部分
npm i @alchemystai/langchain-js

用法

import { AlchemystRetriever } from "@alchemystai/langchain-js";
import { RunnableSequence } from "@langchain/core/runnables";
import dotenv from "dotenv";

dotenv.config();

// Instantiate the retriever with your API key and optional config
const retriever = new AlchemystRetriever({
  apiKey: process.env.ALCHEMYST_AI_API_KEY!,
  similarityThreshold: 0.8,
  minimumSimilarityThreshold: 0.5,
  scope: "internal"
});

// Example: Use the retriever in a LangChain pipeline
async function main() {
  // Create a simple pipeline that retrieves documents and outputs their content
  const pipeline = RunnableSequence.from([
    async (input: string) => {
      const docs = await retriever.getRelevantDocuments(input);
      return docs.map(doc => doc.pageContent).join("\n---\n");
    }
  ]);

  const query = "Show me the latest HR policies"; // Put your business/practical query here
  const result = await pipeline.invoke(query);

  console.log("Retrieved Documents:\n", result);
}

main().catch(console.error);

支持与反馈

如需支持、反馈或报告问题,请访问Alchemyst AI 文档,您将在其中找到最新的联系方式和社区信息。
以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.