Gathering detailed insights and metrics for @langchain/google-genai
Gathering detailed insights and metrics for @langchain/google-genai
🦜🔗 Build context-aware reasoning applications 🦜🔗
npm install @langchain/google-genai
Typescript
Module System
Min. Node Version
Node Version
NPM Version
59.2
Supply Chain
97.7
Quality
95.9
Maintenance
100
Vulnerability
100
License
TypeScript (86.37%)
Jupyter Notebook (6.15%)
HTML (4.33%)
JavaScript (2.73%)
Shell (0.19%)
MDX (0.14%)
CSS (0.09%)
Python (0.01%)
Total Downloads
1,912,251
Last Day
6,637
Last Week
46,006
Last Month
280,941
Last Year
1,897,344
13,074 Stars
5,164 Commits
2,259 Forks
84 Watching
20 Branches
820 Contributors
Latest Version
0.1.6
Package Id
@langchain/google-genai@0.1.6
Unpacked Size
141.96 kB
Size
31.37 kB
File Count
31
NPM Version
10.9.0
Node Version
23.3.0
Publised On
19 Dec 2024
Cumulative downloads
Total Downloads
Last day
-21.9%
6,637
Compared to previous day
Last week
-28.8%
46,006
Compared to previous week
Last month
-14.7%
280,941
Compared to previous month
Last year
12,627.9%
1,897,344
Compared to previous year
2
1
26
This package contains the LangChain.js integrations for Gemini through their generative-ai SDK.
1npm install @langchain/google-genai @langchain/core
This package, along with the main LangChain package, depends on @langchain/core
.
If you are using this package with other LangChain packages, you should make sure that all of the packages depend on the same instance of @langchain/core.
You can do so by adding appropriate field to your project's package.json
like this:
1{ 2 "name": "your-project", 3 "version": "0.0.0", 4 "dependencies": { 5 "@langchain/core": "^0.3.0", 6 "@langchain/google-genai": "^0.0.0" 7 }, 8 "resolutions": { 9 "@langchain/core": "^0.3.0" 10 }, 11 "overrides": { 12 "@langchain/core": "^0.3.0" 13 }, 14 "pnpm": { 15 "overrides": { 16 "@langchain/core": "^0.3.0" 17 } 18 } 19}
The field you need depends on the package manager you're using, but we recommend adding a field for the common yarn
, npm
, and pnpm
to maximize compatibility.
This package contains the ChatGoogleGenerativeAI
class, which is the recommended way to interface with the Google Gemini series of models.
To use, install the requirements, and configure your environment.
1export GOOGLE_API_KEY=your-api-key
Then initialize
1import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; 2 3const model = new ChatGoogleGenerativeAI({ 4 modelName: "gemini-pro", 5 maxOutputTokens: 2048, 6}); 7const response = await model.invoke(new HumanMessage("Hello world!"));
Gemini vision model supports image inputs when providing a single chat message. Example:
1npm install @langchain/core
1import fs from "fs"; 2import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; 3import { HumanMessage } from "@langchain/core/messages"; 4 5const vision = new ChatGoogleGenerativeAI({ 6 modelName: "gemini-pro-vision", 7 maxOutputTokens: 2048, 8}); 9const image = fs.readFileSync("./hotdog.jpg").toString("base64"); 10const input = [ 11 new HumanMessage({ 12 content: [ 13 { 14 type: "text", 15 text: "Describe the following image.", 16 }, 17 { 18 type: "image_url", 19 image_url: `data:image/png;base64,${image}`, 20 }, 21 ], 22 }), 23]; 24 25const res = await vision.invoke(input);
The value of image_url
can be any of the following:
data:image/png;base64,abcd124
)This package also adds support for google's embeddings models.
1import { GoogleGenerativeAIEmbeddings } from "@langchain/google-genai"; 2import { TaskType } from "@google/generative-ai"; 3 4const embeddings = new GoogleGenerativeAIEmbeddings({ 5 modelName: "embedding-001", // 768 dimensions 6 taskType: TaskType.RETRIEVAL_DOCUMENT, 7 title: "Document title", 8}); 9 10const res = await embeddings.embedQuery("OK Google");
To develop the Google GenAI package, you'll need to follow these instructions:
1yarn install
1yarn build
Or from the repo root:
1yarn build --filter=@langchain/google-genai
Test files should live within a tests/
file in the src/
folder. Unit tests should end in .test.ts
and integration tests should
end in .int.test.ts
:
1$ yarn test 2$ yarn test:int
Run the linter & formatter to ensure your code is up to standard:
1yarn lint && yarn format
If you add a new file to be exported, either import & re-export from src/index.ts
, or add it to the entrypoints
field in the config
variable located inside langchain.config.js
and run yarn build
to generate the new entrypoint.
No vulnerabilities found.
No security vulnerabilities found.