@langchain/google-common
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -10,2 +10,3 @@ import { isModelGemini, validateGeminiParams } from "./gemini.js"; | ||
model ?? options?.modelName ?? params?.modelName ?? target.modelName; | ||
ret.model = model; | ||
ret.temperature = | ||
@@ -12,0 +13,0 @@ options?.temperature ?? params?.temperature ?? target.temperature; |
@@ -5,2 +5,11 @@ import { v4 as uuidv4 } from "uuid"; | ||
import { GoogleAISafetyError } from "./safety.js"; | ||
const extractMimeType = (str) => { | ||
if (str.startsWith("data:")) { | ||
return { | ||
mimeType: str.split(":")[1].split(";")[0], | ||
data: str.split(",")[1], | ||
}; | ||
} | ||
return null; | ||
}; | ||
function messageContentText(content) { | ||
@@ -23,8 +32,6 @@ if (content?.text && content?.text.length > 0) { | ||
} | ||
if (url.startsWith("data:")) { | ||
const mineTypeAndData = extractMimeType(url); | ||
if (mineTypeAndData) { | ||
return { | ||
inlineData: { | ||
mimeType: url.split(":")[1].split(";")[0], | ||
data: url.split(",")[1], | ||
}, | ||
inlineData: mineTypeAndData, | ||
}; | ||
@@ -42,2 +49,23 @@ } | ||
} | ||
function messageContentMedia( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
content) { | ||
if ("mimeType" in content && "data" in content) { | ||
return { | ||
inlineData: { | ||
mimeType: content.mimeType, | ||
data: content.data, | ||
}, | ||
}; | ||
} | ||
else if ("mimeType" in content && "fileUri" in content) { | ||
return { | ||
fileData: { | ||
mimeType: content.mimeType, | ||
fileUri: content.fileUri, | ||
}, | ||
}; | ||
} | ||
throw new Error("Invalid media content"); | ||
} | ||
export function messageContentToParts(content) { | ||
@@ -68,2 +96,4 @@ // Convert a string to a text type MessageContent if needed | ||
break; | ||
case "media": | ||
return messageContentMedia(content); | ||
default: | ||
@@ -70,0 +100,0 @@ throw new Error(`Unsupported type received while converting message to message parts`); |
{ | ||
"name": "@langchain/google-common", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Core types and classes for Google services.", | ||
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175173
4671