@google/generative-ai
Advanced tools
Comparing version 0.17.2 to 0.18.0
@@ -710,3 +710,3 @@ /** | ||
*/ | ||
getGenerativeModelFromCachedContent(cachedContent: CachedContent, requestOptions?: RequestOptions): GenerativeModel; | ||
getGenerativeModelFromCachedContent(cachedContent: CachedContent, modelParams?: Partial<ModelParams>, requestOptions?: RequestOptions): GenerativeModel; | ||
} | ||
@@ -713,0 +713,0 @@ |
@@ -286,3 +286,3 @@ 'use strict'; | ||
*/ | ||
const PACKAGE_VERSION = "0.17.2"; | ||
const PACKAGE_VERSION = "0.18.0"; | ||
const PACKAGE_LOG_HEADER = "genai-js"; | ||
@@ -1409,3 +1409,3 @@ var Task; | ||
*/ | ||
getGenerativeModelFromCachedContent(cachedContent, requestOptions) { | ||
getGenerativeModelFromCachedContent(cachedContent, modelParams, requestOptions) { | ||
if (!cachedContent.name) { | ||
@@ -1417,9 +1417,27 @@ throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `name` field."); | ||
} | ||
const modelParamsFromCache = { | ||
model: cachedContent.model, | ||
tools: cachedContent.tools, | ||
toolConfig: cachedContent.toolConfig, | ||
systemInstruction: cachedContent.systemInstruction, | ||
cachedContent, | ||
}; | ||
/** | ||
* Not checking tools and toolConfig for now as it would require a deep | ||
* equality comparison and isn't likely to be a common case. | ||
*/ | ||
const disallowedDuplicates = ["model", "systemInstruction"]; | ||
for (const key of disallowedDuplicates) { | ||
if ((modelParams === null || modelParams === void 0 ? void 0 : modelParams[key]) && | ||
cachedContent[key] && | ||
(modelParams === null || modelParams === void 0 ? void 0 : modelParams[key]) !== cachedContent[key]) { | ||
if (key === "model") { | ||
const modelParamsComp = modelParams.model.startsWith("models/") | ||
? modelParams.model.replace("models/", "") | ||
: modelParams.model; | ||
const cachedContentComp = cachedContent.model.startsWith("models/") | ||
? cachedContent.model.replace("models/", "") | ||
: cachedContent.model; | ||
if (modelParamsComp === cachedContentComp) { | ||
continue; | ||
} | ||
} | ||
throw new GoogleGenerativeAIRequestInputError(`Different value for "${key}" specified in modelParams` + | ||
` (${modelParams[key]}) and cachedContent (${cachedContent[key]})`); | ||
} | ||
} | ||
const modelParamsFromCache = Object.assign(Object.assign({}, modelParams), { model: cachedContent.model, tools: cachedContent.tools, toolConfig: cachedContent.toolConfig, systemInstruction: cachedContent.systemInstruction, cachedContent }); | ||
return new GenerativeModel(this.apiKey, modelParamsFromCache, requestOptions); | ||
@@ -1426,0 +1444,0 @@ } |
@@ -72,3 +72,3 @@ 'use strict'; | ||
*/ | ||
const PACKAGE_VERSION = "0.17.2"; | ||
const PACKAGE_VERSION = "0.18.0"; | ||
const PACKAGE_LOG_HEADER = "genai-js"; | ||
@@ -75,0 +75,0 @@ var Task; |
@@ -35,3 +35,3 @@ /** | ||
*/ | ||
getGenerativeModelFromCachedContent(cachedContent: CachedContent, requestOptions?: RequestOptions): GenerativeModel; | ||
getGenerativeModelFromCachedContent(cachedContent: CachedContent, modelParams?: Partial<ModelParams>, requestOptions?: RequestOptions): GenerativeModel; | ||
} |
@@ -35,3 +35,3 @@ /** | ||
*/ | ||
getGenerativeModelFromCachedContent(cachedContent: CachedContent, requestOptions?: RequestOptions): GenerativeModel; | ||
getGenerativeModelFromCachedContent(cachedContent: CachedContent, modelParams?: Partial<ModelParams>, requestOptions?: RequestOptions): GenerativeModel; | ||
} |
{ | ||
"name": "@google/generative-ai", | ||
"version": "0.17.2", | ||
"version": "0.18.0", | ||
"description": "Google AI JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
377434
9838