@ai-sdk/google
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -265,3 +265,4 @@ "use strict"; | ||
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(responseSchema), | ||
abortSignal: options.abortSignal | ||
abortSignal: options.abortSignal, | ||
fetch: this.config.fetch | ||
}); | ||
@@ -299,3 +300,4 @@ const { contents: rawPrompt, ...rawSettings } = args; | ||
successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(chunkSchema), | ||
abortSignal: options.abortSignal | ||
abortSignal: options.abortSignal, | ||
fetch: this.config.fetch | ||
}); | ||
@@ -308,3 +310,3 @@ const { contents: rawPrompt, ...rawSettings } = args; | ||
}; | ||
const generateId2 = this.config.generateId; | ||
const generateId3 = this.config.generateId; | ||
let hasToolCalls = false; | ||
@@ -348,3 +350,3 @@ return { | ||
parts: content.parts, | ||
generateId: generateId2 | ||
generateId: generateId3 | ||
}); | ||
@@ -384,3 +386,3 @@ if (toolCallDeltas != null) { | ||
parts, | ||
generateId: generateId2 | ||
generateId: generateId3 | ||
}) { | ||
@@ -392,3 +394,3 @@ const functionCallParts = parts.filter( | ||
toolCallType: "function", | ||
toolCallId: generateId2(), | ||
toolCallId: generateId3(), | ||
toolName: part.functionCall.name, | ||
@@ -555,4 +557,24 @@ args: JSON.stringify(part.functionCall.args) | ||
// src/google-provider.ts | ||
var import_provider_utils5 = require("@ai-sdk/provider-utils"); | ||
function createGoogleGenerativeAI(options = {}) { | ||
const google2 = new Google(options); | ||
var _a, _b; | ||
const baseURL = (_b = (0, import_provider_utils5.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : options.baseUrl)) != null ? _b : "https://generativelanguage.googleapis.com/v1beta"; | ||
const getHeaders = () => ({ | ||
"x-goog-api-key": (0, import_provider_utils5.loadApiKey)({ | ||
apiKey: options.apiKey, | ||
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY", | ||
description: "Google Generative AI" | ||
}), | ||
...options.headers | ||
}); | ||
const createChatModel = (modelId, settings = {}) => { | ||
var _a2; | ||
return new GoogleGenerativeAILanguageModel(modelId, settings, { | ||
provider: "google.generative-ai", | ||
baseURL, | ||
headers: getHeaders, | ||
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils5.generateId, | ||
fetch: options.fetch | ||
}); | ||
}; | ||
const provider = function(modelId, settings) { | ||
@@ -564,6 +586,7 @@ if (new.target) { | ||
} | ||
return google2.chat(modelId, settings); | ||
return createChatModel(modelId, settings); | ||
}; | ||
provider.chat = google2.chat.bind(google2); | ||
provider.generativeAI = google2.generativeAI.bind(google2); | ||
provider.languageModel = createChatModel; | ||
provider.chat = createChatModel; | ||
provider.generativeAI = createChatModel; | ||
return provider; | ||
@@ -570,0 +593,0 @@ } |
@@ -27,2 +27,3 @@ import { LanguageModelV1 } from '@ai-sdk/provider'; | ||
generateId: () => string; | ||
fetch?: typeof fetch; | ||
}; | ||
@@ -44,2 +45,3 @@ declare class GoogleGenerativeAILanguageModel implements LanguageModelV1 { | ||
(modelId: GoogleGenerativeAIModelId, settings?: GoogleGenerativeAISettings): GoogleGenerativeAILanguageModel; | ||
languageModel(modelId: GoogleGenerativeAIModelId, settings?: GoogleGenerativeAISettings): GoogleGenerativeAILanguageModel; | ||
chat(modelId: GoogleGenerativeAIModelId, settings?: GoogleGenerativeAISettings): GoogleGenerativeAILanguageModel; | ||
@@ -70,2 +72,7 @@ /** | ||
headers?: Record<string, string>; | ||
/** | ||
Custom fetch implementation. You can use it as a middleware to intercept requests, | ||
or to provide a custom fetch implementation for e.g. testing. | ||
*/ | ||
fetch?: typeof fetch; | ||
generateId?: () => string; | ||
@@ -72,0 +79,0 @@ } |
@@ -265,3 +265,4 @@ "use strict"; | ||
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(responseSchema), | ||
abortSignal: options.abortSignal | ||
abortSignal: options.abortSignal, | ||
fetch: this.config.fetch | ||
}); | ||
@@ -299,3 +300,4 @@ const { contents: rawPrompt, ...rawSettings } = args; | ||
successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(chunkSchema), | ||
abortSignal: options.abortSignal | ||
abortSignal: options.abortSignal, | ||
fetch: this.config.fetch | ||
}); | ||
@@ -308,3 +310,3 @@ const { contents: rawPrompt, ...rawSettings } = args; | ||
}; | ||
const generateId2 = this.config.generateId; | ||
const generateId3 = this.config.generateId; | ||
let hasToolCalls = false; | ||
@@ -348,3 +350,3 @@ return { | ||
parts: content.parts, | ||
generateId: generateId2 | ||
generateId: generateId3 | ||
}); | ||
@@ -384,3 +386,3 @@ if (toolCallDeltas != null) { | ||
parts, | ||
generateId: generateId2 | ||
generateId: generateId3 | ||
}) { | ||
@@ -392,3 +394,3 @@ const functionCallParts = parts.filter( | ||
toolCallType: "function", | ||
toolCallId: generateId2(), | ||
toolCallId: generateId3(), | ||
toolName: part.functionCall.name, | ||
@@ -555,4 +557,24 @@ args: JSON.stringify(part.functionCall.args) | ||
// src/google-provider.ts | ||
var import_provider_utils5 = require("@ai-sdk/provider-utils"); | ||
function createGoogleGenerativeAI(options = {}) { | ||
const google2 = new Google(options); | ||
var _a, _b; | ||
const baseURL = (_b = (0, import_provider_utils5.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : options.baseUrl)) != null ? _b : "https://generativelanguage.googleapis.com/v1beta"; | ||
const getHeaders = () => ({ | ||
"x-goog-api-key": (0, import_provider_utils5.loadApiKey)({ | ||
apiKey: options.apiKey, | ||
environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY", | ||
description: "Google Generative AI" | ||
}), | ||
...options.headers | ||
}); | ||
const createChatModel = (modelId, settings = {}) => { | ||
var _a2; | ||
return new GoogleGenerativeAILanguageModel(modelId, settings, { | ||
provider: "google.generative-ai", | ||
baseURL, | ||
headers: getHeaders, | ||
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils5.generateId, | ||
fetch: options.fetch | ||
}); | ||
}; | ||
const provider = function(modelId, settings) { | ||
@@ -564,6 +586,7 @@ if (new.target) { | ||
} | ||
return google2.chat(modelId, settings); | ||
return createChatModel(modelId, settings); | ||
}; | ||
provider.chat = google2.chat.bind(google2); | ||
provider.generativeAI = google2.generativeAI.bind(google2); | ||
provider.languageModel = createChatModel; | ||
provider.chat = createChatModel; | ||
provider.generativeAI = createChatModel; | ||
return provider; | ||
@@ -570,0 +593,0 @@ } |
{ | ||
"name": "@ai-sdk/google", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"license": "Apache-2.0", | ||
@@ -22,3 +22,3 @@ "sideEffects": false, | ||
"@ai-sdk/provider": "0.0.10", | ||
"@ai-sdk/provider-utils": "0.0.13" | ||
"@ai-sdk/provider-utils": "0.0.14" | ||
}, | ||
@@ -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
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
133655
1839
+ Added@ai-sdk/provider-utils@0.0.14(transitive)
- Removed@ai-sdk/provider-utils@0.0.13(transitive)