@ai-sdk/google 3.0.75 → 3.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +39 -12
- package/dist/index.d.ts +39 -12
- package/dist/index.js +215 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -69
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -2
- package/dist/internal/index.d.ts +1 -2
- package/dist/internal/index.js +97 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +97 -59
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +1 -0
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +104 -56
- package/src/google-generative-ai-options.ts +24 -8
- package/src/google-provider.ts +9 -4
- package/src/interactions/google-interactions-agent.ts +6 -7
- package/src/interactions/google-interactions-language-model-options.ts +65 -0
- package/src/interactions/google-interactions-language-model.ts +73 -22
- package/src/interactions/google-interactions-prompt.ts +50 -0
- package/src/interactions/stream-google-interactions.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.77" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -851,17 +851,32 @@ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
|
|
|
851
851
|
*/
|
|
852
852
|
streamFunctionCallArguments: import_v44.z.boolean().optional(),
|
|
853
853
|
/**
|
|
854
|
-
* Optional. The service tier to use for the request.
|
|
854
|
+
* Optional. The service tier to use for the request. Sent as the
|
|
855
|
+
* `serviceTier` body field. Gemini API only.
|
|
855
856
|
*/
|
|
856
|
-
serviceTier: import_v44.z.enum(["standard", "flex", "priority"]).optional()
|
|
857
|
+
serviceTier: import_v44.z.enum(["standard", "flex", "priority"]).optional(),
|
|
858
|
+
/**
|
|
859
|
+
* Optional. Vertex AI only. Sent as the
|
|
860
|
+
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
861
|
+
* shared (PayGo) tier. With Provisioned Throughput allocated and
|
|
862
|
+
* `requestType` unset, the request falls back to this tier only if
|
|
863
|
+
* PT capacity is exhausted.
|
|
864
|
+
*
|
|
865
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
866
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
867
|
+
*/
|
|
868
|
+
sharedRequestType: import_v44.z.enum(["priority", "flex", "standard"]).optional(),
|
|
869
|
+
/**
|
|
870
|
+
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
871
|
+
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
872
|
+
* to bypass Provisioned Throughput entirely.
|
|
873
|
+
*
|
|
874
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
875
|
+
*/
|
|
876
|
+
requestType: import_v44.z.enum(["shared"]).optional()
|
|
857
877
|
})
|
|
858
878
|
)
|
|
859
879
|
);
|
|
860
|
-
var VertexServiceTierMap = {
|
|
861
|
-
standard: "SERVICE_TIER_STANDARD",
|
|
862
|
-
flex: "SERVICE_TIER_FLEX",
|
|
863
|
-
priority: "SERVICE_TIER_PRIORITY"
|
|
864
|
-
};
|
|
865
880
|
|
|
866
881
|
// src/google-prepare-tools.ts
|
|
867
882
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -1426,10 +1441,27 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1426
1441
|
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
1427
1442
|
});
|
|
1428
1443
|
}
|
|
1429
|
-
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1430
1444
|
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
1431
|
-
|
|
1445
|
+
warnings.push({
|
|
1446
|
+
type: "other",
|
|
1447
|
+
message: "'serviceTier' is a Gemini API option and is not supported on Vertex AI. Use 'sharedRequestType' (and optionally 'requestType') instead. See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo"
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
|
|
1451
|
+
warnings.push({
|
|
1452
|
+
type: "other",
|
|
1453
|
+
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
|
|
1454
|
+
});
|
|
1432
1455
|
}
|
|
1456
|
+
const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
|
|
1457
|
+
...googleOptions.sharedRequestType && {
|
|
1458
|
+
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
1459
|
+
},
|
|
1460
|
+
...googleOptions.requestType && {
|
|
1461
|
+
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
1462
|
+
}
|
|
1463
|
+
} : void 0;
|
|
1464
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1433
1465
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1434
1466
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1435
1467
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
@@ -1501,18 +1533,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1501
1533
|
toolConfig,
|
|
1502
1534
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1503
1535
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1504
|
-
serviceTier:
|
|
1536
|
+
serviceTier: bodyServiceTier
|
|
1505
1537
|
},
|
|
1506
1538
|
warnings: [...warnings, ...toolWarnings],
|
|
1507
|
-
providerOptionsName
|
|
1539
|
+
providerOptionsName,
|
|
1540
|
+
extraHeaders: vertexPaygoHeaders
|
|
1508
1541
|
};
|
|
1509
1542
|
}
|
|
1510
1543
|
async doGenerate(options) {
|
|
1511
1544
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1512
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1545
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1513
1546
|
const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
|
|
1514
1547
|
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
1515
|
-
options.headers
|
|
1548
|
+
options.headers,
|
|
1549
|
+
extraHeaders
|
|
1516
1550
|
);
|
|
1517
1551
|
const {
|
|
1518
1552
|
responseHeaders,
|
|
@@ -1677,7 +1711,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1677
1711
|
safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
|
|
1678
1712
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1679
1713
|
finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
|
|
1680
|
-
serviceTier: (_r =
|
|
1714
|
+
serviceTier: (_r = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _r : null
|
|
1681
1715
|
}
|
|
1682
1716
|
},
|
|
1683
1717
|
request: { body: args },
|
|
@@ -1689,13 +1723,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1689
1723
|
};
|
|
1690
1724
|
}
|
|
1691
1725
|
async doStream(options) {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
{ isStreaming: true }
|
|
1695
|
-
);
|
|
1726
|
+
var _a;
|
|
1727
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1696
1728
|
const headers = (0, import_provider_utils6.combineHeaders)(
|
|
1697
1729
|
await (0, import_provider_utils6.resolve)(this.config.headers),
|
|
1698
|
-
options.headers
|
|
1730
|
+
options.headers,
|
|
1731
|
+
extraHeaders
|
|
1699
1732
|
);
|
|
1700
1733
|
const { responseHeaders, value: response } = await (0, import_provider_utils6.postJsonToApi)({
|
|
1701
1734
|
url: `${this.config.baseURL}/${getModelPath(
|
|
@@ -1716,7 +1749,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1716
1749
|
let providerMetadata = void 0;
|
|
1717
1750
|
let lastGroundingMetadata = null;
|
|
1718
1751
|
let lastUrlContextMetadata = null;
|
|
1719
|
-
|
|
1752
|
+
const serviceTier = (_a = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _a : null;
|
|
1720
1753
|
const generateId3 = this.config.generateId;
|
|
1721
1754
|
let hasToolCalls = false;
|
|
1722
1755
|
let currentTextBlockId = null;
|
|
@@ -1726,6 +1759,34 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1726
1759
|
let lastCodeExecutionToolCallId;
|
|
1727
1760
|
let lastServerToolCallId;
|
|
1728
1761
|
const activeStreamingToolCalls = [];
|
|
1762
|
+
const finishActiveStreamingToolCall = (controller) => {
|
|
1763
|
+
const active = activeStreamingToolCalls.pop();
|
|
1764
|
+
if (active == null) {
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1768
|
+
if (closingDelta.length > 0) {
|
|
1769
|
+
controller.enqueue({
|
|
1770
|
+
type: "tool-input-delta",
|
|
1771
|
+
id: active.toolCallId,
|
|
1772
|
+
delta: closingDelta,
|
|
1773
|
+
providerMetadata: active.providerMetadata
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
controller.enqueue({
|
|
1777
|
+
type: "tool-input-end",
|
|
1778
|
+
id: active.toolCallId,
|
|
1779
|
+
providerMetadata: active.providerMetadata
|
|
1780
|
+
});
|
|
1781
|
+
controller.enqueue({
|
|
1782
|
+
type: "tool-call",
|
|
1783
|
+
toolCallId: active.toolCallId,
|
|
1784
|
+
toolName: active.toolName,
|
|
1785
|
+
input: finalJSON,
|
|
1786
|
+
providerMetadata: active.providerMetadata
|
|
1787
|
+
});
|
|
1788
|
+
hasToolCalls = true;
|
|
1789
|
+
};
|
|
1729
1790
|
return {
|
|
1730
1791
|
stream: response.pipeThrough(
|
|
1731
1792
|
new TransformStream({
|
|
@@ -1733,7 +1794,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1733
1794
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1734
1795
|
},
|
|
1735
1796
|
transform(chunk, controller) {
|
|
1736
|
-
var
|
|
1797
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1737
1798
|
if (options.includeRawChunks) {
|
|
1738
1799
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1739
1800
|
}
|
|
@@ -1746,10 +1807,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1746
1807
|
if (usageMetadata != null) {
|
|
1747
1808
|
usage = usageMetadata;
|
|
1748
1809
|
}
|
|
1749
|
-
|
|
1750
|
-
serviceTier = value.serviceTier;
|
|
1751
|
-
}
|
|
1752
|
-
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1810
|
+
const candidate = (_a2 = value.candidates) == null ? void 0 : _a2[0];
|
|
1753
1811
|
if (candidate == null) {
|
|
1754
1812
|
return;
|
|
1755
1813
|
}
|
|
@@ -1938,7 +1996,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1938
1996
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1939
1997
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
1940
1998
|
if (isStreamingChunk) {
|
|
1941
|
-
if (part.functionCall.name != null
|
|
1999
|
+
if (part.functionCall.name != null) {
|
|
1942
2000
|
const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
|
|
1943
2001
|
const accumulator = new GoogleJSONAccumulator();
|
|
1944
2002
|
activeStreamingToolCalls.push({
|
|
@@ -1954,9 +2012,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1954
2012
|
providerMetadata: providerMeta
|
|
1955
2013
|
});
|
|
1956
2014
|
if (part.functionCall.partialArgs != null) {
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1959
|
-
);
|
|
2015
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2016
|
+
const { textDelta } = accumulator.processPartialArgs(partialArgs);
|
|
1960
2017
|
if (textDelta.length > 0) {
|
|
1961
2018
|
controller.enqueue({
|
|
1962
2019
|
type: "tool-input-delta",
|
|
@@ -1965,12 +2022,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1965
2022
|
providerMetadata: providerMeta
|
|
1966
2023
|
});
|
|
1967
2024
|
}
|
|
2025
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2026
|
+
finishActiveStreamingToolCall(controller);
|
|
2027
|
+
}
|
|
1968
2028
|
}
|
|
1969
2029
|
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
1970
2030
|
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
1971
|
-
const
|
|
1972
|
-
|
|
1973
|
-
);
|
|
2031
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2032
|
+
const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
|
|
1974
2033
|
if (textDelta.length > 0) {
|
|
1975
2034
|
controller.enqueue({
|
|
1976
2035
|
type: "tool-input-delta",
|
|
@@ -1979,31 +2038,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1979
2038
|
providerMetadata: providerMeta
|
|
1980
2039
|
});
|
|
1981
2040
|
}
|
|
2041
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2042
|
+
finishActiveStreamingToolCall(controller);
|
|
2043
|
+
}
|
|
1982
2044
|
}
|
|
1983
2045
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
1984
|
-
|
|
1985
|
-
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1986
|
-
if (closingDelta.length > 0) {
|
|
1987
|
-
controller.enqueue({
|
|
1988
|
-
type: "tool-input-delta",
|
|
1989
|
-
id: active.toolCallId,
|
|
1990
|
-
delta: closingDelta,
|
|
1991
|
-
providerMetadata: active.providerMetadata
|
|
1992
|
-
});
|
|
1993
|
-
}
|
|
1994
|
-
controller.enqueue({
|
|
1995
|
-
type: "tool-input-end",
|
|
1996
|
-
id: active.toolCallId,
|
|
1997
|
-
providerMetadata: active.providerMetadata
|
|
1998
|
-
});
|
|
1999
|
-
controller.enqueue({
|
|
2000
|
-
type: "tool-call",
|
|
2001
|
-
toolCallId: active.toolCallId,
|
|
2002
|
-
toolName: active.toolName,
|
|
2003
|
-
input: finalJSON,
|
|
2004
|
-
providerMetadata: active.providerMetadata
|
|
2005
|
-
});
|
|
2006
|
-
hasToolCalls = true;
|
|
2046
|
+
finishActiveStreamingToolCall(controller);
|
|
2007
2047
|
} else if (isCompleteCall) {
|
|
2008
2048
|
const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
|
|
2009
2049
|
const toolName = part.functionCall.name;
|
|
@@ -2362,8 +2402,7 @@ var responseSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
2362
2402
|
promptFeedback: import_v45.z.object({
|
|
2363
2403
|
blockReason: import_v45.z.string().nullish(),
|
|
2364
2404
|
safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
|
|
2365
|
-
}).nullish()
|
|
2366
|
-
serviceTier: import_v45.z.string().nullish()
|
|
2405
|
+
}).nullish()
|
|
2367
2406
|
})
|
|
2368
2407
|
)
|
|
2369
2408
|
);
|
|
@@ -2384,8 +2423,7 @@ var chunkSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
2384
2423
|
promptFeedback: import_v45.z.object({
|
|
2385
2424
|
blockReason: import_v45.z.string().nullish(),
|
|
2386
2425
|
safetyRatings: import_v45.z.array(getSafetyRatingSchema()).nullish()
|
|
2387
|
-
}).nullish()
|
|
2388
|
-
serviceTier: import_v45.z.string().nullish()
|
|
2426
|
+
}).nullish()
|
|
2389
2427
|
})
|
|
2390
2428
|
)
|
|
2391
2429
|
);
|
|
@@ -4601,7 +4639,61 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils18.lazySch
|
|
|
4601
4639
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
4602
4640
|
* such as deep research can take tens of minutes — increase if needed.
|
|
4603
4641
|
*/
|
|
4604
|
-
pollingTimeoutMs: import_v416.z.number().int().positive().nullish()
|
|
4642
|
+
pollingTimeoutMs: import_v416.z.number().int().positive().nullish(),
|
|
4643
|
+
/**
|
|
4644
|
+
* Run the interaction in the background. Required for agents whose
|
|
4645
|
+
* server-side workflow cannot complete within a single request/response.
|
|
4646
|
+
* When `true`, the POST returns with a non-terminal status and the SDK
|
|
4647
|
+
* polls `GET /interactions/{id}` until the work completes. Some agents
|
|
4648
|
+
* reject `true`; see the agent's documentation for which mode it
|
|
4649
|
+
* requires.
|
|
4650
|
+
*/
|
|
4651
|
+
background: import_v416.z.boolean().nullish(),
|
|
4652
|
+
/**
|
|
4653
|
+
* Environment configuration for the agent sandbox. Only applies to agent
|
|
4654
|
+
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
4655
|
+
*
|
|
4656
|
+
* - `"remote"`: provision a fresh sandbox for this call.
|
|
4657
|
+
* - any other string: an existing `environment_id` to reuse.
|
|
4658
|
+
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
4659
|
+
* and/or constrain outbound traffic via `network`.
|
|
4660
|
+
*/
|
|
4661
|
+
environment: import_v416.z.union([
|
|
4662
|
+
import_v416.z.string(),
|
|
4663
|
+
import_v416.z.object({
|
|
4664
|
+
type: import_v416.z.literal("remote"),
|
|
4665
|
+
sources: import_v416.z.array(
|
|
4666
|
+
import_v416.z.union([
|
|
4667
|
+
import_v416.z.object({
|
|
4668
|
+
type: import_v416.z.literal("gcs"),
|
|
4669
|
+
source: import_v416.z.string(),
|
|
4670
|
+
target: import_v416.z.string().nullish()
|
|
4671
|
+
}),
|
|
4672
|
+
import_v416.z.object({
|
|
4673
|
+
type: import_v416.z.literal("repository"),
|
|
4674
|
+
source: import_v416.z.string(),
|
|
4675
|
+
target: import_v416.z.string().nullish()
|
|
4676
|
+
}),
|
|
4677
|
+
import_v416.z.object({
|
|
4678
|
+
type: import_v416.z.literal("inline"),
|
|
4679
|
+
content: import_v416.z.string(),
|
|
4680
|
+
target: import_v416.z.string()
|
|
4681
|
+
})
|
|
4682
|
+
])
|
|
4683
|
+
).nullish(),
|
|
4684
|
+
network: import_v416.z.union([
|
|
4685
|
+
import_v416.z.literal("disabled"),
|
|
4686
|
+
import_v416.z.object({
|
|
4687
|
+
allowlist: import_v416.z.array(
|
|
4688
|
+
import_v416.z.object({
|
|
4689
|
+
domain: import_v416.z.string(),
|
|
4690
|
+
transform: import_v416.z.array(import_v416.z.record(import_v416.z.string(), import_v416.z.string())).nullish()
|
|
4691
|
+
})
|
|
4692
|
+
)
|
|
4693
|
+
})
|
|
4694
|
+
]).nullish()
|
|
4695
|
+
})
|
|
4696
|
+
]).nullish()
|
|
4605
4697
|
})
|
|
4606
4698
|
)
|
|
4607
4699
|
);
|
|
@@ -5329,6 +5421,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5329
5421
|
if (typeof modelOrAgent === "string") {
|
|
5330
5422
|
this.modelId = modelOrAgent;
|
|
5331
5423
|
this.agent = void 0;
|
|
5424
|
+
} else if ("managedAgent" in modelOrAgent) {
|
|
5425
|
+
this.modelId = modelOrAgent.managedAgent;
|
|
5426
|
+
this.agent = modelOrAgent.managedAgent;
|
|
5332
5427
|
} else {
|
|
5333
5428
|
this.modelId = modelOrAgent.agent;
|
|
5334
5429
|
this.agent = modelOrAgent.agent;
|
|
@@ -5354,7 +5449,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5354
5449
|
};
|
|
5355
5450
|
}
|
|
5356
5451
|
async getArgs(options) {
|
|
5357
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
5452
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
5358
5453
|
const warnings = [];
|
|
5359
5454
|
const opts = await (0, import_provider_utils22.parseProviderOptions)({
|
|
5360
5455
|
provider: "google",
|
|
@@ -5511,6 +5606,55 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5511
5606
|
agentConfig = { type: "dynamic" };
|
|
5512
5607
|
}
|
|
5513
5608
|
}
|
|
5609
|
+
let environment;
|
|
5610
|
+
if ((opts == null ? void 0 : opts.environment) != null) {
|
|
5611
|
+
if (!isAgent) {
|
|
5612
|
+
warnings.push({
|
|
5613
|
+
type: "other",
|
|
5614
|
+
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
5615
|
+
});
|
|
5616
|
+
} else if (typeof opts.environment === "string") {
|
|
5617
|
+
environment = opts.environment;
|
|
5618
|
+
} else {
|
|
5619
|
+
const env = opts.environment;
|
|
5620
|
+
const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
|
|
5621
|
+
var _a2;
|
|
5622
|
+
if (s.type === "inline") {
|
|
5623
|
+
return {
|
|
5624
|
+
type: "inline",
|
|
5625
|
+
content: s.content,
|
|
5626
|
+
target: s.target
|
|
5627
|
+
};
|
|
5628
|
+
}
|
|
5629
|
+
return pruneUndefined({
|
|
5630
|
+
type: s.type,
|
|
5631
|
+
source: s.source,
|
|
5632
|
+
target: (_a2 = s.target) != null ? _a2 : void 0
|
|
5633
|
+
});
|
|
5634
|
+
});
|
|
5635
|
+
let network;
|
|
5636
|
+
if (env.network === "disabled") {
|
|
5637
|
+
network = "disabled";
|
|
5638
|
+
} else if (env.network != null) {
|
|
5639
|
+
network = {
|
|
5640
|
+
allowlist: env.network.allowlist.map(
|
|
5641
|
+
(entry) => {
|
|
5642
|
+
var _a2;
|
|
5643
|
+
return pruneUndefined({
|
|
5644
|
+
domain: entry.domain,
|
|
5645
|
+
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
5646
|
+
});
|
|
5647
|
+
}
|
|
5648
|
+
)
|
|
5649
|
+
};
|
|
5650
|
+
}
|
|
5651
|
+
environment = pruneUndefined({
|
|
5652
|
+
type: "remote",
|
|
5653
|
+
sources: sources != null && sources.length > 0 ? sources : void 0,
|
|
5654
|
+
network
|
|
5655
|
+
});
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5514
5658
|
const args = pruneUndefined({
|
|
5515
5659
|
...isAgent ? { agent: this.agent } : { model: this.modelId },
|
|
5516
5660
|
input,
|
|
@@ -5518,18 +5662,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5518
5662
|
tools: toolsForBody,
|
|
5519
5663
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5520
5664
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5521
|
-
previous_interaction_id: (
|
|
5522
|
-
service_tier: (
|
|
5523
|
-
store: (
|
|
5665
|
+
previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
|
|
5666
|
+
service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
|
|
5667
|
+
store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
|
|
5524
5668
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5525
5669
|
agent_config: agentConfig,
|
|
5526
|
-
|
|
5670
|
+
environment,
|
|
5671
|
+
background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
|
|
5527
5672
|
});
|
|
5528
5673
|
return {
|
|
5529
5674
|
args,
|
|
5530
5675
|
warnings,
|
|
5531
5676
|
isAgent,
|
|
5532
|
-
|
|
5677
|
+
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
5678
|
+
pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
|
|
5533
5679
|
};
|
|
5534
5680
|
}
|
|
5535
5681
|
async doGenerate(options) {
|
|
@@ -5615,14 +5761,14 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5615
5761
|
}
|
|
5616
5762
|
async doStream(options) {
|
|
5617
5763
|
var _a;
|
|
5618
|
-
const { args, warnings,
|
|
5764
|
+
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
5619
5765
|
const url = `${this.config.baseURL}/interactions`;
|
|
5620
5766
|
const mergedHeaders = (0, import_provider_utils22.combineHeaders)(
|
|
5621
5767
|
INTERACTIONS_API_REVISION_HEADER,
|
|
5622
5768
|
this.config.headers ? await (0, import_provider_utils22.resolve)(this.config.headers) : void 0,
|
|
5623
5769
|
options.headers
|
|
5624
5770
|
);
|
|
5625
|
-
if (
|
|
5771
|
+
if (isBackground) {
|
|
5626
5772
|
return this.doStreamBackground({
|
|
5627
5773
|
args,
|
|
5628
5774
|
warnings,
|