以编程方式使用文档

MinimaxEmbeddings 类使用 Minimax API 为给定文本生成嵌入。

设置

要使用 Minimax 模型,您需要一个 Minimax 账户、一个 API 密钥和一个 Group ID。

用法

  /* Embed queries */
  const embeddings = new MinimaxEmbeddings();
  const res = await embeddings.embedQuery("Hello world");
  console.log(res);
  /* Embed documents */
  const documentRes = await embeddings.embedDocuments([
    "Hello world",
    "Bye bye",
  ]);
  console.log({ documentRes });
};

相关