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 1.0.0-canary.3 to 1.0.0-canary.4

73

./dist/index.js

@@ -23,3 +23,2 @@ "use strict";

__export(src_exports, {
Google: () => Google,
createGoogleGenerativeAI: () => createGoogleGenerativeAI,

@@ -30,4 +29,4 @@ google: () => google

// src/google-facade.ts
var import_provider_utils4 = require("@ai-sdk/provider-utils");
// src/google-provider.ts
var import_provider_utils5 = require("@ai-sdk/provider-utils");

@@ -384,3 +383,3 @@ // src/google-generative-ai-language-model.ts

temperature,
topK: topK != null ? topK : this.settings.topK,
topK,
topP,

@@ -522,3 +521,3 @@ frequencyPenalty,

};
const generateId3 = this.config.generateId;
const generateId2 = this.config.generateId;
let hasToolCalls = false;

@@ -562,3 +561,3 @@ return {

parts: content.parts,
generateId: generateId3
generateId: generateId2
});

@@ -599,3 +598,3 @@ if (toolCallDeltas != null) {

parts,
generateId: generateId3
generateId: generateId2
}) {

@@ -607,3 +606,3 @@ const functionCallParts = parts.filter(

toolCallType: "function",
toolCallId: generateId3(),
toolCallId: generateId2(),
toolName: part.functionCall.name,

@@ -660,48 +659,5 @@ args: JSON.stringify(part.functionCall.args)

// src/google-facade.ts
var Google = class {
/**
* Creates a new Google provider instance.
*/
constructor(options = {}) {
var _a, _b;
this.baseURL = (_a = (0, import_provider_utils4.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
this.apiKey = options.apiKey;
this.headers = options.headers;
this.generateId = (_b = options.generateId) != null ? _b : import_provider_utils4.generateId;
}
get baseConfig() {
return {
baseURL: this.baseURL,
headers: () => ({
"x-goog-api-key": (0, import_provider_utils4.loadApiKey)({
apiKey: this.apiKey,
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
description: "Google Generative AI"
}),
...this.headers
})
};
}
/**
* @deprecated Use `chat()` instead.
*/
generativeAI(modelId, settings = {}) {
return this.chat(modelId, settings);
}
chat(modelId, settings = {}) {
return new GoogleGenerativeAILanguageModel(modelId, settings, {
provider: "google.generative-ai",
...this.baseConfig,
generateId: this.generateId
});
}
};
// src/google-provider.ts
var import_provider_utils6 = require("@ai-sdk/provider-utils");
// src/google-generative-ai-embedding-model.ts
var import_provider3 = require("@ai-sdk/provider");
var import_provider_utils5 = require("@ai-sdk/provider-utils");
var import_provider_utils4 = require("@ai-sdk/provider-utils");
var import_zod3 = require("zod");

@@ -737,5 +693,5 @@ var GoogleGenerativeAIEmbeddingModel = class {

}
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), headers),
headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
body: {

@@ -749,3 +705,3 @@ requests: values.map((value) => ({

failedResponseHandler: googleFailedResponseHandler,
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
googleGenerativeAITextEmbeddingResponseSchema

@@ -770,5 +726,5 @@ ),

var _a;
const baseURL = (_a = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
const baseURL = (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
const getHeaders = () => ({
"x-goog-api-key": (0, import_provider_utils6.loadApiKey)({
"x-goog-api-key": (0, import_provider_utils5.loadApiKey)({
apiKey: options.apiKey,

@@ -786,3 +742,3 @@ environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",

headers: getHeaders,
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils6.generateId,
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils5.generateId,
fetch: options.fetch

@@ -816,3 +772,2 @@ });

0 && (module.exports = {
Google,
createGoogleGenerativeAI,

@@ -819,0 +774,0 @@ google

7

CHANGELOG.md
# @ai-sdk/google
## 1.0.0-canary.4
### Major Changes
- 36b03b0: chore (provider/google): remove topK model setting
- 277fc6b: chore (provider/google): remove facade
## 1.0.0-canary.3

@@ -4,0 +11,0 @@

@@ -1,3 +0,3 @@

import { LanguageModelV1, ProviderV1, EmbeddingModelV1 } from '@ai-sdk/provider';
import { FetchFunction } from '@ai-sdk/provider-utils';
import { ProviderV1, LanguageModelV1, EmbeddingModelV1 } from '@ai-sdk/provider';

@@ -7,12 +7,2 @@ type GoogleGenerativeAIModelId = 'gemini-1.5-flash-latest' | 'gemini-1.5-flash' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro' | 'gemini-pro' | (string & {});

/**
Optional. The maximum number of tokens to consider when sampling.
Models use nucleus sampling or combined Top-k and nucleus sampling.
Top-k sampling considers the set of topK most probable tokens.
Models running with nucleus sampling don't allow topK setting.
@deprecated use the topK setting on the request instead.
*/
topK?: number;
/**
Optional.

@@ -41,25 +31,2 @@ The name of the cached content used as context to serve the prediction.

type GoogleGenerativeAIConfig = {
provider: string;
baseURL: string;
headers: () => Record<string, string | undefined>;
generateId: () => string;
fetch?: FetchFunction;
};
declare class GoogleGenerativeAILanguageModel implements LanguageModelV1 {
readonly specificationVersion = "v1";
readonly defaultObjectGenerationMode = "json";
readonly supportsImageUrls = false;
get supportsObjectGeneration(): boolean;
readonly modelId: GoogleGenerativeAIModelId;
readonly settings: GoogleGenerativeAISettings;
private readonly config;
constructor(modelId: GoogleGenerativeAIModelId, settings: GoogleGenerativeAISettings, config: GoogleGenerativeAIConfig);
get provider(): string;
private getArgs;
supportsUrl(url: URL): boolean;
doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
}
type GoogleGenerativeAIEmbeddingModelId = 'text-embedding-004' | (string & {});

@@ -123,25 +90,2 @@ interface GoogleGenerativeAIEmbeddingSettings {

/**
* @deprecated Use `createGoogleGenerativeAI` instead.
*/
declare class Google {
/**
* Base URL for the Google API calls.
*/
readonly baseURL: string;
readonly apiKey?: string;
readonly headers?: Record<string, string>;
private readonly generateId;
/**
* Creates a new Google provider instance.
*/
constructor(options?: GoogleGenerativeAIProviderSettings);
private get baseConfig();
/**
* @deprecated Use `chat()` instead.
*/
generativeAI(modelId: GoogleGenerativeAIModelId, settings?: GoogleGenerativeAISettings): GoogleGenerativeAILanguageModel;
chat(modelId: GoogleGenerativeAIModelId, settings?: GoogleGenerativeAISettings): GoogleGenerativeAILanguageModel;
}
export { Google, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };
export { type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderSettings, createGoogleGenerativeAI, google };

@@ -23,3 +23,2 @@ "use strict";

__export(src_exports, {
Google: () => Google,
createGoogleGenerativeAI: () => createGoogleGenerativeAI,

@@ -30,4 +29,4 @@ google: () => google

// src/google-facade.ts
var import_provider_utils4 = require("@ai-sdk/provider-utils");
// src/google-provider.ts
var import_provider_utils5 = require("@ai-sdk/provider-utils");

@@ -384,3 +383,3 @@ // src/google-generative-ai-language-model.ts

temperature,
topK: topK != null ? topK : this.settings.topK,
topK,
topP,

@@ -522,3 +521,3 @@ frequencyPenalty,

};
const generateId3 = this.config.generateId;
const generateId2 = this.config.generateId;
let hasToolCalls = false;

@@ -562,3 +561,3 @@ return {

parts: content.parts,
generateId: generateId3
generateId: generateId2
});

@@ -599,3 +598,3 @@ if (toolCallDeltas != null) {

parts,
generateId: generateId3
generateId: generateId2
}) {

@@ -607,3 +606,3 @@ const functionCallParts = parts.filter(

toolCallType: "function",
toolCallId: generateId3(),
toolCallId: generateId2(),
toolName: part.functionCall.name,

@@ -660,48 +659,5 @@ args: JSON.stringify(part.functionCall.args)

// src/google-facade.ts
var Google = class {
/**
* Creates a new Google provider instance.
*/
constructor(options = {}) {
var _a, _b;
this.baseURL = (_a = (0, import_provider_utils4.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
this.apiKey = options.apiKey;
this.headers = options.headers;
this.generateId = (_b = options.generateId) != null ? _b : import_provider_utils4.generateId;
}
get baseConfig() {
return {
baseURL: this.baseURL,
headers: () => ({
"x-goog-api-key": (0, import_provider_utils4.loadApiKey)({
apiKey: this.apiKey,
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
description: "Google Generative AI"
}),
...this.headers
})
};
}
/**
* @deprecated Use `chat()` instead.
*/
generativeAI(modelId, settings = {}) {
return this.chat(modelId, settings);
}
chat(modelId, settings = {}) {
return new GoogleGenerativeAILanguageModel(modelId, settings, {
provider: "google.generative-ai",
...this.baseConfig,
generateId: this.generateId
});
}
};
// src/google-provider.ts
var import_provider_utils6 = require("@ai-sdk/provider-utils");
// src/google-generative-ai-embedding-model.ts
var import_provider3 = require("@ai-sdk/provider");
var import_provider_utils5 = require("@ai-sdk/provider-utils");
var import_provider_utils4 = require("@ai-sdk/provider-utils");
var import_zod3 = require("zod");

@@ -737,5 +693,5 @@ var GoogleGenerativeAIEmbeddingModel = class {

}
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), headers),
headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
body: {

@@ -749,3 +705,3 @@ requests: values.map((value) => ({

failedResponseHandler: googleFailedResponseHandler,
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
googleGenerativeAITextEmbeddingResponseSchema

@@ -770,5 +726,5 @@ ),

var _a;
const baseURL = (_a = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
const baseURL = (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://generativelanguage.googleapis.com/v1beta";
const getHeaders = () => ({
"x-goog-api-key": (0, import_provider_utils6.loadApiKey)({
"x-goog-api-key": (0, import_provider_utils5.loadApiKey)({
apiKey: options.apiKey,

@@ -786,3 +742,3 @@ environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",

headers: getHeaders,
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils6.generateId,
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils5.generateId,
fetch: options.fetch

@@ -816,3 +772,2 @@ });

0 && (module.exports = {
Google,
createGoogleGenerativeAI,

@@ -819,0 +774,0 @@ google

{
"name": "@ai-sdk/google",
"version": "1.0.0-canary.3",
"version": "1.0.0-canary.4",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "sideEffects": false,

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

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