Skip to content

Commit

Permalink
Update fileData & inlineData to kebab case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hongkongkiwi authored Jan 30, 2025
1 parent 05eedae commit 3f5a994
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions libs/langchain-google-genai/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
}
Expand Down Expand Up @@ -164,9 +164,9 @@ export function convertMessageContentToParts(
}

return {
inlineData: {
inline_data: {
data,
mimeType,
mime_type: mimeType,
},
};
} else if (c.type === "media") {
Expand All @@ -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,
},
};
Expand Down

0 comments on commit 3f5a994

Please sign in to comment.