-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated outputs and langsmith urls, use hotdog img for multimodal exa…
…mple
- Loading branch information
1 parent
d72d535
commit 07d3b6c
Showing
6 changed files
with
53 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 26 additions & 7 deletions
33
examples/src/models/chat/integration_googlevertexai-multimodal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
import { ChatPromptTemplate } from "@langchain/core/prompts"; | ||
import { ChatVertexAI } from "@langchain/google-vertexai"; | ||
import fs from "node:fs"; | ||
|
||
const model = new ChatVertexAI({ | ||
model: "gemini-pro-vision", | ||
model: "gemini-pro-vision", | ||
temperature: 0.7, | ||
}); | ||
|
||
const imageURL = "imageURL"; // Replace with your image URL | ||
|
||
const response = await model.invoke([ | ||
{ type: "text", text: "Describe what you see in this image." }, | ||
{ type: "image_url", image_url: { url: imageURL } }, | ||
const image = fs.readFileSync("./hotdog.jpg").toString("base64"); | ||
const prompt = ChatPromptTemplate.fromMessages([ | ||
[ | ||
"human", | ||
[ | ||
{ | ||
type: "text", | ||
text: "Describe the following image.", | ||
}, | ||
{ | ||
type: "image_url", | ||
image_url: "data:image/png;base64,{image_base64}", | ||
}, | ||
], | ||
], | ||
]); | ||
|
||
console.log(response.content); // Extract the text content from the response | ||
const response = await prompt.pipe(model).invoke({ | ||
image_base64: image, | ||
}); | ||
|
||
console.log(response.content); | ||
/* | ||
This is an image of a hot dog. The hot dog is on a white background. The hot dog is a grilled sausage in a bun. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters