Google PaLM
danger
The Google PaLM API is deprecated and will be removed in 0.3.0. Please use the Google GenAI integration instead.
note
This integration does not support embeddings-*
model. Check Google GenAI embeddings.
The Google PaLM API can be integrated by first installing the required packages:
- npm
- Yarn
- pnpm
npm install google-auth-library @google-ai/generativelanguage @langchain/community
yarn add google-auth-library @google-ai/generativelanguage @langchain/community
pnpm add google-auth-library @google-ai/generativelanguage @langchain/community
Create an API key from Google MakerSuite. You can then set
the key as GOOGLE_PALM_API_KEY
environment variable or pass it as apiKey
parameter while instantiating
the model.
import { GooglePaLMEmbeddings } from "@langchain/community/embeddings/googlepalm";
const model = new GooglePaLMEmbeddings({
apiKey: "<YOUR API KEY>", // or set it in environment variable as `GOOGLE_PALM_API_KEY`
model: "models/embedding-gecko-001", // OPTIONAL
});
/* Embed queries */
const res = await model.embedQuery(
"What would be a good company name for a company that makes colorful socks?"
);
console.log({ res });
/* Embed documents */
const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });
API Reference:
- GooglePaLMEmbeddings from
@langchain/community/embeddings/googlepalm
Related
- Embedding model conceptual guide
- Embedding model how-to guides