Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/google

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/google - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

70

./dist/index.js

@@ -33,3 +33,3 @@ "use strict";

// src/google-generative-ai-language-model.ts
var import_provider2 = require("@ai-sdk/provider");
var import_provider = require("@ai-sdk/provider");
var import_provider_utils3 = require("@ai-sdk/provider-utils");

@@ -39,5 +39,7 @@ var import_zod2 = require("zod");

// src/convert-to-google-generative-ai-messages.ts
var import_provider = require("@ai-sdk/provider");
var import_provider_utils = require("@ai-sdk/provider-utils");
function convertToGoogleGenerativeAIMessages(prompt) {
async function convertToGoogleGenerativeAIMessages({
prompt,
downloadImplementation = import_provider_utils.download
}) {
const messages = [];

@@ -52,27 +54,33 @@ for (const { role, content } of prompt) {

case "user": {
messages.push({
role: "user",
parts: content.map((part) => {
var _a;
switch (part.type) {
case "text": {
return { text: part.text };
const parts = [];
for (const part of content) {
switch (part.type) {
case "text": {
parts.push({ text: part.text });
break;
}
case "image": {
let data;
let mimeType;
if (part.image instanceof URL) {
const downloadResult = await downloadImplementation({
url: part.image
});
data = downloadResult.data;
mimeType = downloadResult.mimeType;
} else {
data = part.image;
mimeType = part.mimeType;
}
case "image": {
if (part.image instanceof URL) {
throw new import_provider.UnsupportedFunctionalityError({
functionality: "URL image parts"
});
} else {
return {
inlineData: {
mimeType: (_a = part.mimeType) != null ? _a : "image/jpeg",
data: (0, import_provider_utils.convertUint8ArrayToBase64)(part.image)
}
};
parts.push({
inlineData: {
mimeType: mimeType != null ? mimeType : "image/jpeg",
data: (0, import_provider_utils.convertUint8ArrayToBase64)(data)
}
}
});
break;
}
})
});
}
}
messages.push({ role: "user", parts });
break;

@@ -171,3 +179,3 @@ }

}
getArgs({
async getArgs({
mode,

@@ -210,3 +218,3 @@ prompt,

};
const contents = convertToGoogleGenerativeAIMessages(prompt);
const contents = await convertToGoogleGenerativeAIMessages({ prompt });
switch (type) {

@@ -238,3 +246,3 @@ case "regular": {

case "object-tool": {
throw new import_provider2.UnsupportedFunctionalityError({
throw new import_provider.UnsupportedFunctionalityError({
functionality: "object-tool mode"

@@ -244,3 +252,3 @@ });

case "object-grammar": {
throw new import_provider2.UnsupportedFunctionalityError({
throw new import_provider.UnsupportedFunctionalityError({
functionality: "object-grammar mode"

@@ -257,3 +265,3 @@ });

var _a, _b;
const { args, warnings } = this.getArgs(options);
const { args, warnings } = await this.getArgs(options);
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({

@@ -291,3 +299,3 @@ url: `${this.config.baseURL}/${this.modelId}:generateContent`,

async doStream(options) {
const { args, warnings } = this.getArgs(options);
const { args, warnings } = await this.getArgs(options);
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({

@@ -294,0 +302,0 @@ url: `${this.config.baseURL}/${this.modelId}:streamGenerateContent?alt=sse`,

@@ -33,3 +33,3 @@ "use strict";

// src/google-generative-ai-language-model.ts
var import_provider2 = require("@ai-sdk/provider");
var import_provider = require("@ai-sdk/provider");
var import_provider_utils3 = require("@ai-sdk/provider-utils");

@@ -39,5 +39,7 @@ var import_zod2 = require("zod");

// src/convert-to-google-generative-ai-messages.ts
var import_provider = require("@ai-sdk/provider");
var import_provider_utils = require("@ai-sdk/provider-utils");
function convertToGoogleGenerativeAIMessages(prompt) {
async function convertToGoogleGenerativeAIMessages({
prompt,
downloadImplementation = import_provider_utils.download
}) {
const messages = [];

@@ -52,27 +54,33 @@ for (const { role, content } of prompt) {

case "user": {
messages.push({
role: "user",
parts: content.map((part) => {
var _a;
switch (part.type) {
case "text": {
return { text: part.text };
const parts = [];
for (const part of content) {
switch (part.type) {
case "text": {
parts.push({ text: part.text });
break;
}
case "image": {
let data;
let mimeType;
if (part.image instanceof URL) {
const downloadResult = await downloadImplementation({
url: part.image
});
data = downloadResult.data;
mimeType = downloadResult.mimeType;
} else {
data = part.image;
mimeType = part.mimeType;
}
case "image": {
if (part.image instanceof URL) {
throw new import_provider.UnsupportedFunctionalityError({
functionality: "URL image parts"
});
} else {
return {
inlineData: {
mimeType: (_a = part.mimeType) != null ? _a : "image/jpeg",
data: (0, import_provider_utils.convertUint8ArrayToBase64)(part.image)
}
};
parts.push({
inlineData: {
mimeType: mimeType != null ? mimeType : "image/jpeg",
data: (0, import_provider_utils.convertUint8ArrayToBase64)(data)
}
}
});
break;
}
})
});
}
}
messages.push({ role: "user", parts });
break;

@@ -171,3 +179,3 @@ }

}
getArgs({
async getArgs({
mode,

@@ -210,3 +218,3 @@ prompt,

};
const contents = convertToGoogleGenerativeAIMessages(prompt);
const contents = await convertToGoogleGenerativeAIMessages({ prompt });
switch (type) {

@@ -238,3 +246,3 @@ case "regular": {

case "object-tool": {
throw new import_provider2.UnsupportedFunctionalityError({
throw new import_provider.UnsupportedFunctionalityError({
functionality: "object-tool mode"

@@ -244,3 +252,3 @@ });

case "object-grammar": {
throw new import_provider2.UnsupportedFunctionalityError({
throw new import_provider.UnsupportedFunctionalityError({
functionality: "object-grammar mode"

@@ -257,3 +265,3 @@ });

var _a, _b;
const { args, warnings } = this.getArgs(options);
const { args, warnings } = await this.getArgs(options);
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({

@@ -291,3 +299,3 @@ url: `${this.config.baseURL}/${this.modelId}:generateContent`,

async doStream(options) {
const { args, warnings } = this.getArgs(options);
const { args, warnings } = await this.getArgs(options);
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({

@@ -294,0 +302,0 @@ url: `${this.config.baseURL}/${this.modelId}:streamGenerateContent?alt=sse`,

{
"name": "@ai-sdk/google",
"version": "0.0.18",
"version": "0.0.19",
"license": "Apache-2.0",

@@ -21,4 +21,4 @@ "sideEffects": false,

"dependencies": {
"@ai-sdk/provider": "0.0.8",
"@ai-sdk/provider-utils": "0.0.11"
"@ai-sdk/provider": "0.0.9",
"@ai-sdk/provider-utils": "0.0.12"
},

@@ -25,0 +25,0 @@ "devDependencies": {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc