TencentHunyuan
The TencentHunyuanEmbeddings
class uses the Tencent Hunyuan API to generate embeddings for a given text.
Setupβ
- Sign up for a Tencent Cloud account here.
- Create SecretID & SecretKey here.
- Set SecretID and SecretKey as environment variables named
TENCENT_SECRET_ID
andTENCENT_SECRET_KEY
, respectively.
- npm
- Yarn
- pnpm
npm install @langchain/community
yarn add @langchain/community
pnpm add @langchain/community
If you are using LangChain.js in a browser environment, you'll also need to install the following dependencies:
- npm
- Yarn
- pnpm
npm install crypto-js
yarn add crypto-js
pnpm add crypto-js
And then make sure that you import from the web
as shown below.
Usageβ
Here's an example:
// in nodejs environment
import { TencentHunyuanEmbeddings } from "@langchain/community/embeddings/tencent_hunyuan";
// in browser environment
// import { TencentHunyuanEmbeddings } from "@langchain/community/embeddings/tencent_hunyuan/web";
/* Embed queries */
const embeddings = new TencentHunyuanEmbeddings();
const res = await embeddings.embedQuery("δ½ ε₯½οΌδΈηοΌ");
console.log(res);
/* Embed documents */
const documentRes = await embeddings.embedDocuments(["δ½ ε₯½οΌδΈηοΌ", "εθ§"]);
console.log({ documentRes });
API Reference:
- TencentHunyuanEmbeddings from
@langchain/community/embeddings/tencent_hunyuan
Relatedβ
- Embedding model conceptual guide
- Embedding model how-to guides