@ai-sdk/google 3.0.75 → 3.0.78
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 +25 -0
- package/dist/index.d.mts +40 -12
- package/dist/index.d.ts +40 -12
- package/dist/index.js +214 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -69
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -2
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +96 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +96 -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/convert-google-generative-ai-usage.ts +1 -0
- package/src/google-generative-ai-language-model.ts +104 -57
- 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.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.78" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -860,17 +860,32 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
860
860
|
*/
|
|
861
861
|
streamFunctionCallArguments: z4.boolean().optional(),
|
|
862
862
|
/**
|
|
863
|
-
* Optional. The service tier to use for the request.
|
|
863
|
+
* Optional. The service tier to use for the request. Sent as the
|
|
864
|
+
* `serviceTier` body field. Gemini API only.
|
|
864
865
|
*/
|
|
865
|
-
serviceTier: z4.enum(["standard", "flex", "priority"]).optional()
|
|
866
|
+
serviceTier: z4.enum(["standard", "flex", "priority"]).optional(),
|
|
867
|
+
/**
|
|
868
|
+
* Optional. Vertex AI only. Sent as the
|
|
869
|
+
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
870
|
+
* shared (PayGo) tier. With Provisioned Throughput allocated and
|
|
871
|
+
* `requestType` unset, the request falls back to this tier only if
|
|
872
|
+
* PT capacity is exhausted.
|
|
873
|
+
*
|
|
874
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
875
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
876
|
+
*/
|
|
877
|
+
sharedRequestType: z4.enum(["priority", "flex", "standard"]).optional(),
|
|
878
|
+
/**
|
|
879
|
+
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
880
|
+
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
881
|
+
* to bypass Provisioned Throughput entirely.
|
|
882
|
+
*
|
|
883
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
884
|
+
*/
|
|
885
|
+
requestType: z4.enum(["shared"]).optional()
|
|
866
886
|
})
|
|
867
887
|
)
|
|
868
888
|
);
|
|
869
|
-
var VertexServiceTierMap = {
|
|
870
|
-
standard: "SERVICE_TIER_STANDARD",
|
|
871
|
-
flex: "SERVICE_TIER_FLEX",
|
|
872
|
-
priority: "SERVICE_TIER_PRIORITY"
|
|
873
|
-
};
|
|
874
889
|
|
|
875
890
|
// src/google-prepare-tools.ts
|
|
876
891
|
import {
|
|
@@ -1437,10 +1452,27 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1437
1452
|
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`
|
|
1438
1453
|
});
|
|
1439
1454
|
}
|
|
1440
|
-
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1441
1455
|
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
1442
|
-
|
|
1456
|
+
warnings.push({
|
|
1457
|
+
type: "other",
|
|
1458
|
+
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"
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
|
|
1462
|
+
warnings.push({
|
|
1463
|
+
type: "other",
|
|
1464
|
+
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
|
|
1465
|
+
});
|
|
1443
1466
|
}
|
|
1467
|
+
const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
|
|
1468
|
+
...googleOptions.sharedRequestType && {
|
|
1469
|
+
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
1470
|
+
},
|
|
1471
|
+
...googleOptions.requestType && {
|
|
1472
|
+
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
1473
|
+
}
|
|
1474
|
+
} : void 0;
|
|
1475
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1444
1476
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1445
1477
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1446
1478
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
|
|
@@ -1512,18 +1544,20 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1512
1544
|
toolConfig,
|
|
1513
1545
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1514
1546
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1515
|
-
serviceTier:
|
|
1547
|
+
serviceTier: bodyServiceTier
|
|
1516
1548
|
},
|
|
1517
1549
|
warnings: [...warnings, ...toolWarnings],
|
|
1518
|
-
providerOptionsName
|
|
1550
|
+
providerOptionsName,
|
|
1551
|
+
extraHeaders: vertexPaygoHeaders
|
|
1519
1552
|
};
|
|
1520
1553
|
}
|
|
1521
1554
|
async doGenerate(options) {
|
|
1522
1555
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1523
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
1556
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
1524
1557
|
const mergedHeaders = combineHeaders2(
|
|
1525
1558
|
await resolve2(this.config.headers),
|
|
1526
|
-
options.headers
|
|
1559
|
+
options.headers,
|
|
1560
|
+
extraHeaders
|
|
1527
1561
|
);
|
|
1528
1562
|
const {
|
|
1529
1563
|
responseHeaders,
|
|
@@ -1688,7 +1722,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1688
1722
|
safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
|
|
1689
1723
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1690
1724
|
finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
|
|
1691
|
-
serviceTier: (_r =
|
|
1725
|
+
serviceTier: (_r = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _r : null
|
|
1692
1726
|
}
|
|
1693
1727
|
},
|
|
1694
1728
|
request: { body: args },
|
|
@@ -1700,13 +1734,11 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1700
1734
|
};
|
|
1701
1735
|
}
|
|
1702
1736
|
async doStream(options) {
|
|
1703
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(
|
|
1704
|
-
options,
|
|
1705
|
-
{ isStreaming: true }
|
|
1706
|
-
);
|
|
1737
|
+
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1707
1738
|
const headers = combineHeaders2(
|
|
1708
1739
|
await resolve2(this.config.headers),
|
|
1709
|
-
options.headers
|
|
1740
|
+
options.headers,
|
|
1741
|
+
extraHeaders
|
|
1710
1742
|
);
|
|
1711
1743
|
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
1712
1744
|
url: `${this.config.baseURL}/${getModelPath(
|
|
@@ -1727,7 +1759,6 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1727
1759
|
let providerMetadata = void 0;
|
|
1728
1760
|
let lastGroundingMetadata = null;
|
|
1729
1761
|
let lastUrlContextMetadata = null;
|
|
1730
|
-
let serviceTier = null;
|
|
1731
1762
|
const generateId3 = this.config.generateId;
|
|
1732
1763
|
let hasToolCalls = false;
|
|
1733
1764
|
let currentTextBlockId = null;
|
|
@@ -1737,6 +1768,34 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1737
1768
|
let lastCodeExecutionToolCallId;
|
|
1738
1769
|
let lastServerToolCallId;
|
|
1739
1770
|
const activeStreamingToolCalls = [];
|
|
1771
|
+
const finishActiveStreamingToolCall = (controller) => {
|
|
1772
|
+
const active = activeStreamingToolCalls.pop();
|
|
1773
|
+
if (active == null) {
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1777
|
+
if (closingDelta.length > 0) {
|
|
1778
|
+
controller.enqueue({
|
|
1779
|
+
type: "tool-input-delta",
|
|
1780
|
+
id: active.toolCallId,
|
|
1781
|
+
delta: closingDelta,
|
|
1782
|
+
providerMetadata: active.providerMetadata
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
controller.enqueue({
|
|
1786
|
+
type: "tool-input-end",
|
|
1787
|
+
id: active.toolCallId,
|
|
1788
|
+
providerMetadata: active.providerMetadata
|
|
1789
|
+
});
|
|
1790
|
+
controller.enqueue({
|
|
1791
|
+
type: "tool-call",
|
|
1792
|
+
toolCallId: active.toolCallId,
|
|
1793
|
+
toolName: active.toolName,
|
|
1794
|
+
input: finalJSON,
|
|
1795
|
+
providerMetadata: active.providerMetadata
|
|
1796
|
+
});
|
|
1797
|
+
hasToolCalls = true;
|
|
1798
|
+
};
|
|
1740
1799
|
return {
|
|
1741
1800
|
stream: response.pipeThrough(
|
|
1742
1801
|
new TransformStream({
|
|
@@ -1744,7 +1803,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1744
1803
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1745
1804
|
},
|
|
1746
1805
|
transform(chunk, controller) {
|
|
1747
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1806
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1748
1807
|
if (options.includeRawChunks) {
|
|
1749
1808
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1750
1809
|
}
|
|
@@ -1757,9 +1816,6 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1757
1816
|
if (usageMetadata != null) {
|
|
1758
1817
|
usage = usageMetadata;
|
|
1759
1818
|
}
|
|
1760
|
-
if (value.serviceTier != null) {
|
|
1761
|
-
serviceTier = value.serviceTier;
|
|
1762
|
-
}
|
|
1763
1819
|
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1764
1820
|
if (candidate == null) {
|
|
1765
1821
|
return;
|
|
@@ -1949,7 +2005,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1949
2005
|
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
1950
2006
|
const isNoArgsCompleteCall = part.functionCall.name != null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue !== true;
|
|
1951
2007
|
if (isStreamingChunk) {
|
|
1952
|
-
if (part.functionCall.name != null
|
|
2008
|
+
if (part.functionCall.name != null) {
|
|
1953
2009
|
const toolCallId = (_i = part.functionCall.id) != null ? _i : generateId3();
|
|
1954
2010
|
const accumulator = new GoogleJSONAccumulator();
|
|
1955
2011
|
activeStreamingToolCalls.push({
|
|
@@ -1965,9 +2021,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1965
2021
|
providerMetadata: providerMeta
|
|
1966
2022
|
});
|
|
1967
2023
|
if (part.functionCall.partialArgs != null) {
|
|
1968
|
-
const
|
|
1969
|
-
|
|
1970
|
-
);
|
|
2024
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2025
|
+
const { textDelta } = accumulator.processPartialArgs(partialArgs);
|
|
1971
2026
|
if (textDelta.length > 0) {
|
|
1972
2027
|
controller.enqueue({
|
|
1973
2028
|
type: "tool-input-delta",
|
|
@@ -1976,12 +2031,14 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1976
2031
|
providerMetadata: providerMeta
|
|
1977
2032
|
});
|
|
1978
2033
|
}
|
|
2034
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2035
|
+
finishActiveStreamingToolCall(controller);
|
|
2036
|
+
}
|
|
1979
2037
|
}
|
|
1980
2038
|
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
1981
2039
|
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
);
|
|
2040
|
+
const partialArgs = part.functionCall.partialArgs;
|
|
2041
|
+
const { textDelta } = active.accumulator.processPartialArgs(partialArgs);
|
|
1985
2042
|
if (textDelta.length > 0) {
|
|
1986
2043
|
controller.enqueue({
|
|
1987
2044
|
type: "tool-input-delta",
|
|
@@ -1990,31 +2047,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1990
2047
|
providerMetadata: providerMeta
|
|
1991
2048
|
});
|
|
1992
2049
|
}
|
|
2050
|
+
if (part.functionCall.willContinue !== true && partialArgs.every((arg) => arg.willContinue !== true)) {
|
|
2051
|
+
finishActiveStreamingToolCall(controller);
|
|
2052
|
+
}
|
|
1993
2053
|
}
|
|
1994
2054
|
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
1995
|
-
|
|
1996
|
-
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
1997
|
-
if (closingDelta.length > 0) {
|
|
1998
|
-
controller.enqueue({
|
|
1999
|
-
type: "tool-input-delta",
|
|
2000
|
-
id: active.toolCallId,
|
|
2001
|
-
delta: closingDelta,
|
|
2002
|
-
providerMetadata: active.providerMetadata
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
controller.enqueue({
|
|
2006
|
-
type: "tool-input-end",
|
|
2007
|
-
id: active.toolCallId,
|
|
2008
|
-
providerMetadata: active.providerMetadata
|
|
2009
|
-
});
|
|
2010
|
-
controller.enqueue({
|
|
2011
|
-
type: "tool-call",
|
|
2012
|
-
toolCallId: active.toolCallId,
|
|
2013
|
-
toolName: active.toolName,
|
|
2014
|
-
input: finalJSON,
|
|
2015
|
-
providerMetadata: active.providerMetadata
|
|
2016
|
-
});
|
|
2017
|
-
hasToolCalls = true;
|
|
2055
|
+
finishActiveStreamingToolCall(controller);
|
|
2018
2056
|
} else if (isCompleteCall) {
|
|
2019
2057
|
const toolCallId = (_j = part.functionCall.id) != null ? _j : generateId3();
|
|
2020
2058
|
const toolName = part.functionCall.name;
|
|
@@ -2085,7 +2123,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2085
2123
|
safetyRatings: (_n = candidate.safetyRatings) != null ? _n : null,
|
|
2086
2124
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2087
2125
|
finishMessage: (_o = candidate.finishMessage) != null ? _o : null,
|
|
2088
|
-
serviceTier
|
|
2126
|
+
serviceTier: (_p = usage == null ? void 0 : usage.serviceTier) != null ? _p : null
|
|
2089
2127
|
}
|
|
2090
2128
|
};
|
|
2091
2129
|
}
|
|
@@ -2344,6 +2382,7 @@ var usageSchema = z5.object({
|
|
|
2344
2382
|
totalTokenCount: z5.number().nullish(),
|
|
2345
2383
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2346
2384
|
trafficType: z5.string().nullish(),
|
|
2385
|
+
serviceTier: z5.string().nullish(),
|
|
2347
2386
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2348
2387
|
promptTokensDetails: tokenDetailsSchema,
|
|
2349
2388
|
candidatesTokensDetails: tokenDetailsSchema
|
|
@@ -2373,8 +2412,7 @@ var responseSchema = lazySchema5(
|
|
|
2373
2412
|
promptFeedback: z5.object({
|
|
2374
2413
|
blockReason: z5.string().nullish(),
|
|
2375
2414
|
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
|
2376
|
-
}).nullish()
|
|
2377
|
-
serviceTier: z5.string().nullish()
|
|
2415
|
+
}).nullish()
|
|
2378
2416
|
})
|
|
2379
2417
|
)
|
|
2380
2418
|
);
|
|
@@ -2395,8 +2433,7 @@ var chunkSchema = lazySchema5(
|
|
|
2395
2433
|
promptFeedback: z5.object({
|
|
2396
2434
|
blockReason: z5.string().nullish(),
|
|
2397
2435
|
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
|
2398
|
-
}).nullish()
|
|
2399
|
-
serviceTier: z5.string().nullish()
|
|
2436
|
+
}).nullish()
|
|
2400
2437
|
})
|
|
2401
2438
|
)
|
|
2402
2439
|
);
|
|
@@ -4669,7 +4706,61 @@ var googleInteractionsLanguageModelOptions = lazySchema14(
|
|
|
4669
4706
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
4670
4707
|
* such as deep research can take tens of minutes — increase if needed.
|
|
4671
4708
|
*/
|
|
4672
|
-
pollingTimeoutMs: z16.number().int().positive().nullish()
|
|
4709
|
+
pollingTimeoutMs: z16.number().int().positive().nullish(),
|
|
4710
|
+
/**
|
|
4711
|
+
* Run the interaction in the background. Required for agents whose
|
|
4712
|
+
* server-side workflow cannot complete within a single request/response.
|
|
4713
|
+
* When `true`, the POST returns with a non-terminal status and the SDK
|
|
4714
|
+
* polls `GET /interactions/{id}` until the work completes. Some agents
|
|
4715
|
+
* reject `true`; see the agent's documentation for which mode it
|
|
4716
|
+
* requires.
|
|
4717
|
+
*/
|
|
4718
|
+
background: z16.boolean().nullish(),
|
|
4719
|
+
/**
|
|
4720
|
+
* Environment configuration for the agent sandbox. Only applies to agent
|
|
4721
|
+
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
4722
|
+
*
|
|
4723
|
+
* - `"remote"`: provision a fresh sandbox for this call.
|
|
4724
|
+
* - any other string: an existing `environment_id` to reuse.
|
|
4725
|
+
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
4726
|
+
* and/or constrain outbound traffic via `network`.
|
|
4727
|
+
*/
|
|
4728
|
+
environment: z16.union([
|
|
4729
|
+
z16.string(),
|
|
4730
|
+
z16.object({
|
|
4731
|
+
type: z16.literal("remote"),
|
|
4732
|
+
sources: z16.array(
|
|
4733
|
+
z16.union([
|
|
4734
|
+
z16.object({
|
|
4735
|
+
type: z16.literal("gcs"),
|
|
4736
|
+
source: z16.string(),
|
|
4737
|
+
target: z16.string().nullish()
|
|
4738
|
+
}),
|
|
4739
|
+
z16.object({
|
|
4740
|
+
type: z16.literal("repository"),
|
|
4741
|
+
source: z16.string(),
|
|
4742
|
+
target: z16.string().nullish()
|
|
4743
|
+
}),
|
|
4744
|
+
z16.object({
|
|
4745
|
+
type: z16.literal("inline"),
|
|
4746
|
+
content: z16.string(),
|
|
4747
|
+
target: z16.string()
|
|
4748
|
+
})
|
|
4749
|
+
])
|
|
4750
|
+
).nullish(),
|
|
4751
|
+
network: z16.union([
|
|
4752
|
+
z16.literal("disabled"),
|
|
4753
|
+
z16.object({
|
|
4754
|
+
allowlist: z16.array(
|
|
4755
|
+
z16.object({
|
|
4756
|
+
domain: z16.string(),
|
|
4757
|
+
transform: z16.array(z16.record(z16.string(), z16.string())).nullish()
|
|
4758
|
+
})
|
|
4759
|
+
)
|
|
4760
|
+
})
|
|
4761
|
+
]).nullish()
|
|
4762
|
+
})
|
|
4763
|
+
]).nullish()
|
|
4673
4764
|
})
|
|
4674
4765
|
)
|
|
4675
4766
|
);
|
|
@@ -5411,6 +5502,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5411
5502
|
if (typeof modelOrAgent === "string") {
|
|
5412
5503
|
this.modelId = modelOrAgent;
|
|
5413
5504
|
this.agent = void 0;
|
|
5505
|
+
} else if ("managedAgent" in modelOrAgent) {
|
|
5506
|
+
this.modelId = modelOrAgent.managedAgent;
|
|
5507
|
+
this.agent = modelOrAgent.managedAgent;
|
|
5414
5508
|
} else {
|
|
5415
5509
|
this.modelId = modelOrAgent.agent;
|
|
5416
5510
|
this.agent = modelOrAgent.agent;
|
|
@@ -5436,7 +5530,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5436
5530
|
};
|
|
5437
5531
|
}
|
|
5438
5532
|
async getArgs(options) {
|
|
5439
|
-
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;
|
|
5533
|
+
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;
|
|
5440
5534
|
const warnings = [];
|
|
5441
5535
|
const opts = await parseProviderOptions5({
|
|
5442
5536
|
provider: "google",
|
|
@@ -5593,6 +5687,55 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5593
5687
|
agentConfig = { type: "dynamic" };
|
|
5594
5688
|
}
|
|
5595
5689
|
}
|
|
5690
|
+
let environment;
|
|
5691
|
+
if ((opts == null ? void 0 : opts.environment) != null) {
|
|
5692
|
+
if (!isAgent) {
|
|
5693
|
+
warnings.push({
|
|
5694
|
+
type: "other",
|
|
5695
|
+
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
5696
|
+
});
|
|
5697
|
+
} else if (typeof opts.environment === "string") {
|
|
5698
|
+
environment = opts.environment;
|
|
5699
|
+
} else {
|
|
5700
|
+
const env = opts.environment;
|
|
5701
|
+
const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
|
|
5702
|
+
var _a2;
|
|
5703
|
+
if (s.type === "inline") {
|
|
5704
|
+
return {
|
|
5705
|
+
type: "inline",
|
|
5706
|
+
content: s.content,
|
|
5707
|
+
target: s.target
|
|
5708
|
+
};
|
|
5709
|
+
}
|
|
5710
|
+
return pruneUndefined({
|
|
5711
|
+
type: s.type,
|
|
5712
|
+
source: s.source,
|
|
5713
|
+
target: (_a2 = s.target) != null ? _a2 : void 0
|
|
5714
|
+
});
|
|
5715
|
+
});
|
|
5716
|
+
let network;
|
|
5717
|
+
if (env.network === "disabled") {
|
|
5718
|
+
network = "disabled";
|
|
5719
|
+
} else if (env.network != null) {
|
|
5720
|
+
network = {
|
|
5721
|
+
allowlist: env.network.allowlist.map(
|
|
5722
|
+
(entry) => {
|
|
5723
|
+
var _a2;
|
|
5724
|
+
return pruneUndefined({
|
|
5725
|
+
domain: entry.domain,
|
|
5726
|
+
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
5727
|
+
});
|
|
5728
|
+
}
|
|
5729
|
+
)
|
|
5730
|
+
};
|
|
5731
|
+
}
|
|
5732
|
+
environment = pruneUndefined({
|
|
5733
|
+
type: "remote",
|
|
5734
|
+
sources: sources != null && sources.length > 0 ? sources : void 0,
|
|
5735
|
+
network
|
|
5736
|
+
});
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5596
5739
|
const args = pruneUndefined({
|
|
5597
5740
|
...isAgent ? { agent: this.agent } : { model: this.modelId },
|
|
5598
5741
|
input,
|
|
@@ -5600,18 +5743,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5600
5743
|
tools: toolsForBody,
|
|
5601
5744
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5602
5745
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5603
|
-
previous_interaction_id: (
|
|
5604
|
-
service_tier: (
|
|
5605
|
-
store: (
|
|
5746
|
+
previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
|
|
5747
|
+
service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
|
|
5748
|
+
store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
|
|
5606
5749
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5607
5750
|
agent_config: agentConfig,
|
|
5608
|
-
|
|
5751
|
+
environment,
|
|
5752
|
+
background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
|
|
5609
5753
|
});
|
|
5610
5754
|
return {
|
|
5611
5755
|
args,
|
|
5612
5756
|
warnings,
|
|
5613
5757
|
isAgent,
|
|
5614
|
-
|
|
5758
|
+
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
5759
|
+
pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
|
|
5615
5760
|
};
|
|
5616
5761
|
}
|
|
5617
5762
|
async doGenerate(options) {
|
|
@@ -5697,14 +5842,14 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5697
5842
|
}
|
|
5698
5843
|
async doStream(options) {
|
|
5699
5844
|
var _a;
|
|
5700
|
-
const { args, warnings,
|
|
5845
|
+
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
5701
5846
|
const url = `${this.config.baseURL}/interactions`;
|
|
5702
5847
|
const mergedHeaders = combineHeaders6(
|
|
5703
5848
|
INTERACTIONS_API_REVISION_HEADER,
|
|
5704
5849
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
5705
5850
|
options.headers
|
|
5706
5851
|
);
|
|
5707
|
-
if (
|
|
5852
|
+
if (isBackground) {
|
|
5708
5853
|
return this.doStreamBackground({
|
|
5709
5854
|
args,
|
|
5710
5855
|
warnings,
|