Skip to main content

Alchemyst AI 检索器

Alchemyst AI 检索器 使您的生成式 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 文档,您将在那里找到最新的联系方式和社区信息。