@langchain/google-genai
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -466,2 +466,43 @@ import { GenerateContentRequest, SafetySetting, Part as GenerativeAIPart, ModelParams, RequestOptions, type CachedContent } from "@google/generative-ai"; | ||
* <br /> | ||
* | ||
* <details> | ||
* <summary><strong>Document Messages</strong></summary> | ||
* | ||
* This example will show you how to pass documents such as PDFs to Google | ||
* Generative AI through messages. | ||
* | ||
* ```typescript | ||
* const pdfPath = "/Users/my_user/Downloads/invoice.pdf"; | ||
* const pdfBase64 = await fs.readFile(pdfPath, "base64"); | ||
* | ||
* const response = await llm.invoke([ | ||
* ["system", "Use the provided documents to answer the question"], | ||
* [ | ||
* "user", | ||
* [ | ||
* { | ||
* type: "application/pdf", // If the `type` field includes a single slash (`/`), it will be treated as inline data. | ||
* data: pdfBase64, | ||
* }, | ||
* { | ||
* type: "text", | ||
* text: "Summarize the contents of this PDF", | ||
* }, | ||
* ], | ||
* ], | ||
* ]); | ||
* | ||
* console.log(response.content); | ||
* ``` | ||
* | ||
* ```txt | ||
* This is a billing invoice from Twitter Developers for X API Basic Access. The transaction date is January 7, 2025, | ||
* and the amount is $194.34, which has been paid. The subscription period is from January 7, 2025 21:02 to February 7, 2025 00:00 (UTC). | ||
* The tax is $0.00, with a tax rate of 0%. The total amount is $194.34. The payment was made using a Visa card ending in 7022, | ||
* expiring in 12/2026. The billing address is Brace Sproul, 1234 Main Street, San Francisco, CA, US 94103. The company being billed is | ||
* X Corp, located at 865 FM 1209 Building 2, Bastrop, TX, US 78602. Terms and conditions apply. | ||
* ``` | ||
* </details> | ||
* | ||
* <br /> | ||
*/ | ||
@@ -468,0 +509,0 @@ export declare class ChatGoogleGenerativeAI extends BaseChatModel<GoogleGenerativeAIChatCallOptions, AIMessageChunk> implements GoogleGenerativeAIChatInput { |
@@ -344,2 +344,43 @@ import { GoogleGenerativeAI as GenerativeAI, } from "@google/generative-ai"; | ||
* <br /> | ||
* | ||
* <details> | ||
* <summary><strong>Document Messages</strong></summary> | ||
* | ||
* This example will show you how to pass documents such as PDFs to Google | ||
* Generative AI through messages. | ||
* | ||
* ```typescript | ||
* const pdfPath = "/Users/my_user/Downloads/invoice.pdf"; | ||
* const pdfBase64 = await fs.readFile(pdfPath, "base64"); | ||
* | ||
* const response = await llm.invoke([ | ||
* ["system", "Use the provided documents to answer the question"], | ||
* [ | ||
* "user", | ||
* [ | ||
* { | ||
* type: "application/pdf", // If the `type` field includes a single slash (`/`), it will be treated as inline data. | ||
* data: pdfBase64, | ||
* }, | ||
* { | ||
* type: "text", | ||
* text: "Summarize the contents of this PDF", | ||
* }, | ||
* ], | ||
* ], | ||
* ]); | ||
* | ||
* console.log(response.content); | ||
* ``` | ||
* | ||
* ```txt | ||
* This is a billing invoice from Twitter Developers for X API Basic Access. The transaction date is January 7, 2025, | ||
* and the amount is $194.34, which has been paid. The subscription period is from January 7, 2025 21:02 to February 7, 2025 00:00 (UTC). | ||
* The tax is $0.00, with a tax rate of 0%. The total amount is $194.34. The payment was made using a Visa card ending in 7022, | ||
* expiring in 12/2026. The billing address is Brace Sproul, 1234 Main Street, San Francisco, CA, US 94103. The company being billed is | ||
* X Corp, located at 865 FM 1209 Building 2, Bastrop, TX, US 78602. Terms and conditions apply. | ||
* ``` | ||
* </details> | ||
* | ||
* <br /> | ||
*/ | ||
@@ -346,0 +387,0 @@ export class ChatGoogleGenerativeAI extends BaseChatModel { |
@@ -137,2 +137,14 @@ import { AIMessage, AIMessageChunk, ChatMessage, isBaseMessage, } from "@langchain/core/messages"; | ||
} | ||
else if (c.type?.includes("/") && | ||
// Ensure it's a single slash. | ||
c.type.split("/").length === 2 && | ||
"data" in c && | ||
typeof c.data === "string") { | ||
return { | ||
inlineData: { | ||
mimeType: c.type, | ||
data: c.data, | ||
}, | ||
}; | ||
} | ||
throw new Error(`Unknown content type ${c.type}`); | ||
@@ -139,0 +151,0 @@ }); |
{ | ||
"name": "@langchain/google-genai", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Google Generative AI integration for LangChain.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
150634
3877