From 38ac09baef9b48c40a3d8671adeba62acb69a975 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 30 Jan 2025 23:42:56 +0800 Subject: [PATCH] fix(google-genai): Update fileData & inlineData to kebab case Google Gemini HTTP API requires file_data and inline_data to be in kebab case. This is different to the SDKs which use Snake case. It is possible to use Snake case but with mixed results (e.g. inlineData works, but fileData does not), however officially both should be kebab (see Shell docs): https://ai.google.dev/api/files and have been tested working. --- .../langchain-google-genai/src/utils/common.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/langchain-google-genai/src/utils/common.ts b/libs/langchain-google-genai/src/utils/common.ts index deee3fefbae6..bc0a8cd24e6d 100644 --- a/libs/langchain-google-genai/src/utils/common.ts +++ b/libs/langchain-google-genai/src/utils/common.ts @@ -75,17 +75,17 @@ export function convertAuthorToRole( function messageContentMedia(content: MessageContentComplex): Part { if ("mimeType" in content && "data" in content) { return { - inlineData: { - mimeType: content.mimeType, + inline_data: { + mime_type: content.mimeType, data: content.data, }, }; } if ("mimeType" in content && "fileUri" in content) { return { - fileData: { - mimeType: content.mimeType, - fileUri: content.fileUri, + file_data: { + mime_type: content.mimeType, + file_uri: content.fileUri, }, }; } @@ -164,9 +164,9 @@ export function convertMessageContentToParts( } return { - inlineData: { + inline_data: { data, - mimeType, + mime_type: mimeType, }, }; } else if (c.type === "media") { @@ -186,8 +186,8 @@ export function convertMessageContentToParts( typeof c.data === "string" ) { return { - inlineData: { - mimeType: c.type, + inline_data: { + mime_type: c.type, data: c.data, }, };