@ai-sdk/google 4.0.0-canary.68 → 4.0.0-canary.70
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 +12 -0
- package/dist/index.d.ts +37 -10
- package/dist/index.js +175 -39
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +0 -1
- package/dist/internal/index.js +57 -29
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +208 -50
- package/package.json +1 -1
- package/src/google-language-model-options.ts +23 -8
- package/src/google-language-model.ts +45 -18
- 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 +64 -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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.0-canary.70
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- aeea161: feat(google): read `serviceTier` from `x-gemini-service-tier` response header in Gemini API and use PayGo for Vertex
|
|
8
|
+
|
|
9
|
+
## 4.0.0-canary.69
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7f04802: feat(provider/google): add support for managed agents in the Interactions API
|
|
14
|
+
|
|
3
15
|
## 4.0.0-canary.68
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
|
41
41
|
} | undefined;
|
|
42
42
|
streamFunctionCallArguments?: boolean | undefined;
|
|
43
43
|
serviceTier?: "standard" | "flex" | "priority" | undefined;
|
|
44
|
+
sharedRequestType?: "standard" | "flex" | "priority" | undefined;
|
|
45
|
+
requestType?: "shared" | undefined;
|
|
44
46
|
}>;
|
|
45
47
|
type GoogleLanguageModelOptions = InferSchema<typeof googleLanguageModelOptions>;
|
|
46
48
|
|
|
@@ -189,7 +191,6 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
189
191
|
blocked?: boolean | null | undefined;
|
|
190
192
|
}[] | null | undefined;
|
|
191
193
|
} | null | undefined;
|
|
192
|
-
serviceTier?: string | null | undefined;
|
|
193
194
|
}>;
|
|
194
195
|
type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
|
|
195
196
|
type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
|
|
@@ -318,6 +319,29 @@ declare const googleInteractionsLanguageModelOptions: _ai_sdk_provider_utils.Laz
|
|
|
318
319
|
signature?: string | null | undefined;
|
|
319
320
|
interactionId?: string | null | undefined;
|
|
320
321
|
pollingTimeoutMs?: number | null | undefined;
|
|
322
|
+
background?: boolean | null | undefined;
|
|
323
|
+
environment?: string | {
|
|
324
|
+
type: "remote";
|
|
325
|
+
sources?: ({
|
|
326
|
+
type: "gcs";
|
|
327
|
+
source: string;
|
|
328
|
+
target?: string | null | undefined;
|
|
329
|
+
} | {
|
|
330
|
+
type: "repository";
|
|
331
|
+
source: string;
|
|
332
|
+
target?: string | null | undefined;
|
|
333
|
+
} | {
|
|
334
|
+
type: "inline";
|
|
335
|
+
content: string;
|
|
336
|
+
target: string;
|
|
337
|
+
})[] | null | undefined;
|
|
338
|
+
network?: "disabled" | {
|
|
339
|
+
allowlist: {
|
|
340
|
+
domain: string;
|
|
341
|
+
transform?: Record<string, string>[] | null | undefined;
|
|
342
|
+
}[];
|
|
343
|
+
} | null | undefined;
|
|
344
|
+
} | null | undefined;
|
|
321
345
|
}>;
|
|
322
346
|
type GoogleLanguageModelInteractionsOptions = InferSchema<typeof googleInteractionsLanguageModelOptions>;
|
|
323
347
|
|
|
@@ -347,14 +371,12 @@ type GoogleInteractionsProviderMetadata = {
|
|
|
347
371
|
* Type-only module: declares the union of supported Gemini Interactions agent
|
|
348
372
|
* names. Used by the `google.interactions({ agent })` factory branch.
|
|
349
373
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
* passing an unknown agent name is a compile-time error. Add new agents here
|
|
355
|
-
* as Google publishes them.
|
|
374
|
+
* Strict string-literal union: unknown agent names are a compile-time error.
|
|
375
|
+
* User-defined agents (created via the `/agents` endpoint) are addressed by
|
|
376
|
+
* a separate `{ managedAgent: string }` factory shape — see
|
|
377
|
+
* `GoogleInteractionsModelInput`.
|
|
356
378
|
*/
|
|
357
|
-
type GoogleInteractionsAgentName = 'deep-research-pro-preview-12-2025' | 'deep-research-preview-04-2026' | 'deep-research-max-preview-04-2026';
|
|
379
|
+
type GoogleInteractionsAgentName = 'deep-research-pro-preview-12-2025' | 'deep-research-preview-04-2026' | 'deep-research-max-preview-04-2026' | 'antigravity-preview-05-2026';
|
|
358
380
|
|
|
359
381
|
declare const googleTools: {
|
|
360
382
|
/**
|
|
@@ -486,11 +508,16 @@ interface GoogleProvider extends ProviderV4 {
|
|
|
486
508
|
files(): FilesV4;
|
|
487
509
|
/**
|
|
488
510
|
* Creates a language model targeting the Gemini Interactions API
|
|
489
|
-
* (`POST /v1beta/interactions`). Pass
|
|
490
|
-
*
|
|
511
|
+
* (`POST /v1beta/interactions`). Pass:
|
|
512
|
+
* - a model ID (string),
|
|
513
|
+
* - `{ agent: <name> }` to use a known Gemini agent preset, or
|
|
514
|
+
* - `{ managedAgent: <name> }` to use a user-defined agent created via
|
|
515
|
+
* the `/v1beta/agents` endpoint.
|
|
491
516
|
*/
|
|
492
517
|
interactions(modelIdOrAgent: GoogleInteractionsModelId | {
|
|
493
518
|
agent: GoogleInteractionsAgentName;
|
|
519
|
+
} | {
|
|
520
|
+
managedAgent: string;
|
|
494
521
|
}): LanguageModelV4;
|
|
495
522
|
tools: typeof googleTools;
|
|
496
523
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.0-canary.
|
|
10
|
+
var VERSION = true ? "4.0.0-canary.70" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -989,17 +989,32 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
989
989
|
*/
|
|
990
990
|
streamFunctionCallArguments: z4.boolean().optional(),
|
|
991
991
|
/**
|
|
992
|
-
* Optional. The service tier to use for the request.
|
|
992
|
+
* Optional. The service tier to use for the request. Sent as the
|
|
993
|
+
* `serviceTier` body field. Gemini API only.
|
|
993
994
|
*/
|
|
994
|
-
serviceTier: z4.enum(["standard", "flex", "priority"]).optional()
|
|
995
|
+
serviceTier: z4.enum(["standard", "flex", "priority"]).optional(),
|
|
996
|
+
/**
|
|
997
|
+
* Optional. Vertex AI only. Sent as the
|
|
998
|
+
* `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
|
|
999
|
+
* shared (PayGo) tier. With Provisioned Throughput allocated and
|
|
1000
|
+
* `requestType` unset, the request falls back to this tier only if
|
|
1001
|
+
* PT capacity is exhausted.
|
|
1002
|
+
*
|
|
1003
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1004
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
|
|
1005
|
+
*/
|
|
1006
|
+
sharedRequestType: z4.enum(["priority", "flex", "standard"]).optional(),
|
|
1007
|
+
/**
|
|
1008
|
+
* Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
|
|
1009
|
+
* request header. Set to `'shared'` together with `sharedRequestType`
|
|
1010
|
+
* to bypass Provisioned Throughput entirely.
|
|
1011
|
+
*
|
|
1012
|
+
* https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
|
|
1013
|
+
*/
|
|
1014
|
+
requestType: z4.enum(["shared"]).optional()
|
|
995
1015
|
})
|
|
996
1016
|
)
|
|
997
1017
|
);
|
|
998
|
-
var VertexServiceTierMap = {
|
|
999
|
-
standard: "SERVICE_TIER_STANDARD",
|
|
1000
|
-
flex: "SERVICE_TIER_FLEX",
|
|
1001
|
-
priority: "SERVICE_TIER_PRIORITY"
|
|
1002
|
-
};
|
|
1003
1018
|
|
|
1004
1019
|
// src/google-prepare-tools.ts
|
|
1005
1020
|
import {
|
|
@@ -1580,10 +1595,27 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1580
1595
|
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`
|
|
1581
1596
|
});
|
|
1582
1597
|
}
|
|
1583
|
-
let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1584
1598
|
if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
|
|
1585
|
-
|
|
1599
|
+
warnings.push({
|
|
1600
|
+
type: "other",
|
|
1601
|
+
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"
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
if (((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) && !isVertexProvider) {
|
|
1605
|
+
warnings.push({
|
|
1606
|
+
type: "other",
|
|
1607
|
+
message: `'sharedRequestType' and 'requestType' are Vertex AI options and are ignored with the current Google provider (${this.config.provider}).`
|
|
1608
|
+
});
|
|
1586
1609
|
}
|
|
1610
|
+
const vertexPaygoHeaders = isVertexProvider && ((googleOptions == null ? void 0 : googleOptions.sharedRequestType) || (googleOptions == null ? void 0 : googleOptions.requestType)) ? {
|
|
1611
|
+
...googleOptions.sharedRequestType && {
|
|
1612
|
+
"X-Vertex-AI-LLM-Shared-Request-Type": googleOptions.sharedRequestType
|
|
1613
|
+
},
|
|
1614
|
+
...googleOptions.requestType && {
|
|
1615
|
+
"X-Vertex-AI-LLM-Request-Type": googleOptions.requestType
|
|
1616
|
+
}
|
|
1617
|
+
} : void 0;
|
|
1618
|
+
const bodyServiceTier = isVertexProvider ? void 0 : googleOptions == null ? void 0 : googleOptions.serviceTier;
|
|
1587
1619
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1588
1620
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
1589
1621
|
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
@@ -1658,21 +1690,23 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1658
1690
|
toolConfig,
|
|
1659
1691
|
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
1660
1692
|
labels: googleOptions == null ? void 0 : googleOptions.labels,
|
|
1661
|
-
serviceTier:
|
|
1693
|
+
serviceTier: bodyServiceTier
|
|
1662
1694
|
},
|
|
1663
1695
|
warnings: [...warnings, ...toolWarnings],
|
|
1664
|
-
providerOptionsNames
|
|
1696
|
+
providerOptionsNames,
|
|
1697
|
+
extraHeaders: vertexPaygoHeaders
|
|
1665
1698
|
};
|
|
1666
1699
|
}
|
|
1667
1700
|
async doGenerate(options) {
|
|
1668
1701
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
1669
|
-
const { args, warnings, providerOptionsNames } = await this.getArgs(options);
|
|
1702
|
+
const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
|
|
1670
1703
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1671
1704
|
providerOptionsNames.map((name) => [name, payload])
|
|
1672
1705
|
);
|
|
1673
1706
|
const mergedHeaders = combineHeaders2(
|
|
1674
1707
|
this.config.headers ? await resolve2(this.config.headers) : void 0,
|
|
1675
|
-
options.headers
|
|
1708
|
+
options.headers,
|
|
1709
|
+
extraHeaders
|
|
1676
1710
|
);
|
|
1677
1711
|
const {
|
|
1678
1712
|
responseHeaders,
|
|
@@ -1821,7 +1855,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1821
1855
|
safetyRatings: (_p = candidate.safetyRatings) != null ? _p : null,
|
|
1822
1856
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
1823
1857
|
finishMessage: (_q = candidate.finishMessage) != null ? _q : null,
|
|
1824
|
-
serviceTier: (_r =
|
|
1858
|
+
serviceTier: (_r = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _r : null
|
|
1825
1859
|
}),
|
|
1826
1860
|
request: { body: args },
|
|
1827
1861
|
response: {
|
|
@@ -1832,16 +1866,15 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1832
1866
|
};
|
|
1833
1867
|
}
|
|
1834
1868
|
async doStream(options) {
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
{ isStreaming: true }
|
|
1838
|
-
);
|
|
1869
|
+
var _a;
|
|
1870
|
+
const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options, { isStreaming: true });
|
|
1839
1871
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1840
1872
|
providerOptionsNames.map((name) => [name, payload])
|
|
1841
1873
|
);
|
|
1842
1874
|
const headers = combineHeaders2(
|
|
1843
1875
|
this.config.headers ? await resolve2(this.config.headers) : void 0,
|
|
1844
|
-
options.headers
|
|
1876
|
+
options.headers,
|
|
1877
|
+
extraHeaders
|
|
1845
1878
|
);
|
|
1846
1879
|
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
1847
1880
|
url: `${this.config.baseURL}/${getModelPath(
|
|
@@ -1862,7 +1895,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1862
1895
|
let providerMetadata = void 0;
|
|
1863
1896
|
let lastGroundingMetadata = null;
|
|
1864
1897
|
let lastUrlContextMetadata = null;
|
|
1865
|
-
|
|
1898
|
+
const serviceTier = (_a = responseHeaders == null ? void 0 : responseHeaders["x-gemini-service-tier"]) != null ? _a : null;
|
|
1866
1899
|
const generateId3 = this.config.generateId;
|
|
1867
1900
|
let hasToolCalls = false;
|
|
1868
1901
|
let currentTextBlockId = null;
|
|
@@ -1907,7 +1940,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1907
1940
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1908
1941
|
},
|
|
1909
1942
|
transform(chunk, controller) {
|
|
1910
|
-
var
|
|
1943
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1911
1944
|
if (options.includeRawChunks) {
|
|
1912
1945
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1913
1946
|
}
|
|
@@ -1920,10 +1953,7 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1920
1953
|
if (usageMetadata != null) {
|
|
1921
1954
|
usage = usageMetadata;
|
|
1922
1955
|
}
|
|
1923
|
-
|
|
1924
|
-
serviceTier = value.serviceTier;
|
|
1925
|
-
}
|
|
1926
|
-
const candidate = (_a = value.candidates) == null ? void 0 : _a[0];
|
|
1956
|
+
const candidate = (_a2 = value.candidates) == null ? void 0 : _a2[0];
|
|
1927
1957
|
if (candidate == null) {
|
|
1928
1958
|
return;
|
|
1929
1959
|
}
|
|
@@ -2574,8 +2604,7 @@ var responseSchema = lazySchema5(
|
|
|
2574
2604
|
promptFeedback: z5.object({
|
|
2575
2605
|
blockReason: z5.string().nullish(),
|
|
2576
2606
|
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
|
2577
|
-
}).nullish()
|
|
2578
|
-
serviceTier: z5.string().nullish()
|
|
2607
|
+
}).nullish()
|
|
2579
2608
|
})
|
|
2580
2609
|
)
|
|
2581
2610
|
);
|
|
@@ -2596,8 +2625,7 @@ var chunkSchema = lazySchema5(
|
|
|
2596
2625
|
promptFeedback: z5.object({
|
|
2597
2626
|
blockReason: z5.string().nullish(),
|
|
2598
2627
|
safetyRatings: z5.array(getSafetyRatingSchema()).nullish()
|
|
2599
|
-
}).nullish()
|
|
2600
|
-
serviceTier: z5.string().nullish()
|
|
2628
|
+
}).nullish()
|
|
2601
2629
|
})
|
|
2602
2630
|
)
|
|
2603
2631
|
);
|
|
@@ -5049,7 +5077,61 @@ var googleInteractionsLanguageModelOptions = lazySchema17(
|
|
|
5049
5077
|
* call) before giving up. Defaults to 30 minutes. Long-running agents
|
|
5050
5078
|
* such as deep research can take tens of minutes — increase if needed.
|
|
5051
5079
|
*/
|
|
5052
|
-
pollingTimeoutMs: z19.number().int().positive().nullish()
|
|
5080
|
+
pollingTimeoutMs: z19.number().int().positive().nullish(),
|
|
5081
|
+
/**
|
|
5082
|
+
* Run the interaction in the background. Required for agents whose
|
|
5083
|
+
* server-side workflow cannot complete within a single request/response.
|
|
5084
|
+
* When `true`, the POST returns with a non-terminal status and the SDK
|
|
5085
|
+
* polls `GET /interactions/{id}` until the work completes. Some agents
|
|
5086
|
+
* reject `true`; see the agent's documentation for which mode it
|
|
5087
|
+
* requires.
|
|
5088
|
+
*/
|
|
5089
|
+
background: z19.boolean().nullish(),
|
|
5090
|
+
/**
|
|
5091
|
+
* Environment configuration for the agent sandbox. Only applies to agent
|
|
5092
|
+
* calls (`google.interactions({ agent })`); ignored on model-id calls.
|
|
5093
|
+
*
|
|
5094
|
+
* - `"remote"`: provision a fresh sandbox for this call.
|
|
5095
|
+
* - any other string: an existing `environment_id` to reuse.
|
|
5096
|
+
* - object: provision a fresh sandbox and optionally preload `sources`
|
|
5097
|
+
* and/or constrain outbound traffic via `network`.
|
|
5098
|
+
*/
|
|
5099
|
+
environment: z19.union([
|
|
5100
|
+
z19.string(),
|
|
5101
|
+
z19.object({
|
|
5102
|
+
type: z19.literal("remote"),
|
|
5103
|
+
sources: z19.array(
|
|
5104
|
+
z19.union([
|
|
5105
|
+
z19.object({
|
|
5106
|
+
type: z19.literal("gcs"),
|
|
5107
|
+
source: z19.string(),
|
|
5108
|
+
target: z19.string().nullish()
|
|
5109
|
+
}),
|
|
5110
|
+
z19.object({
|
|
5111
|
+
type: z19.literal("repository"),
|
|
5112
|
+
source: z19.string(),
|
|
5113
|
+
target: z19.string().nullish()
|
|
5114
|
+
}),
|
|
5115
|
+
z19.object({
|
|
5116
|
+
type: z19.literal("inline"),
|
|
5117
|
+
content: z19.string(),
|
|
5118
|
+
target: z19.string()
|
|
5119
|
+
})
|
|
5120
|
+
])
|
|
5121
|
+
).nullish(),
|
|
5122
|
+
network: z19.union([
|
|
5123
|
+
z19.literal("disabled"),
|
|
5124
|
+
z19.object({
|
|
5125
|
+
allowlist: z19.array(
|
|
5126
|
+
z19.object({
|
|
5127
|
+
domain: z19.string(),
|
|
5128
|
+
transform: z19.array(z19.record(z19.string(), z19.string())).nullish()
|
|
5129
|
+
})
|
|
5130
|
+
)
|
|
5131
|
+
})
|
|
5132
|
+
]).nullish()
|
|
5133
|
+
})
|
|
5134
|
+
]).nullish()
|
|
5053
5135
|
})
|
|
5054
5136
|
)
|
|
5055
5137
|
);
|
|
@@ -5786,6 +5868,9 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5786
5868
|
if (typeof modelOrAgent === "string") {
|
|
5787
5869
|
this.modelId = modelOrAgent;
|
|
5788
5870
|
this.agent = void 0;
|
|
5871
|
+
} else if ("managedAgent" in modelOrAgent) {
|
|
5872
|
+
this.modelId = modelOrAgent.managedAgent;
|
|
5873
|
+
this.agent = modelOrAgent.managedAgent;
|
|
5789
5874
|
} else {
|
|
5790
5875
|
this.modelId = modelOrAgent.agent;
|
|
5791
5876
|
this.agent = modelOrAgent.agent;
|
|
@@ -5826,7 +5911,7 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5826
5911
|
};
|
|
5827
5912
|
}
|
|
5828
5913
|
async getArgs(options) {
|
|
5829
|
-
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;
|
|
5914
|
+
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;
|
|
5830
5915
|
const warnings = [];
|
|
5831
5916
|
const opts = await parseProviderOptions6({
|
|
5832
5917
|
provider: "google",
|
|
@@ -5983,6 +6068,55 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5983
6068
|
agentConfig = { type: "dynamic" };
|
|
5984
6069
|
}
|
|
5985
6070
|
}
|
|
6071
|
+
let environment;
|
|
6072
|
+
if ((opts == null ? void 0 : opts.environment) != null) {
|
|
6073
|
+
if (!isAgent) {
|
|
6074
|
+
warnings.push({
|
|
6075
|
+
type: "other",
|
|
6076
|
+
message: "google.interactions: environment is only supported when an agent is set; environment will be omitted from the request body."
|
|
6077
|
+
});
|
|
6078
|
+
} else if (typeof opts.environment === "string") {
|
|
6079
|
+
environment = opts.environment;
|
|
6080
|
+
} else {
|
|
6081
|
+
const env = opts.environment;
|
|
6082
|
+
const sources = (_u = env.sources) == null ? void 0 : _u.map((s) => {
|
|
6083
|
+
var _a2;
|
|
6084
|
+
if (s.type === "inline") {
|
|
6085
|
+
return {
|
|
6086
|
+
type: "inline",
|
|
6087
|
+
content: s.content,
|
|
6088
|
+
target: s.target
|
|
6089
|
+
};
|
|
6090
|
+
}
|
|
6091
|
+
return pruneUndefined({
|
|
6092
|
+
type: s.type,
|
|
6093
|
+
source: s.source,
|
|
6094
|
+
target: (_a2 = s.target) != null ? _a2 : void 0
|
|
6095
|
+
});
|
|
6096
|
+
});
|
|
6097
|
+
let network;
|
|
6098
|
+
if (env.network === "disabled") {
|
|
6099
|
+
network = "disabled";
|
|
6100
|
+
} else if (env.network != null) {
|
|
6101
|
+
network = {
|
|
6102
|
+
allowlist: env.network.allowlist.map(
|
|
6103
|
+
(entry) => {
|
|
6104
|
+
var _a2;
|
|
6105
|
+
return pruneUndefined({
|
|
6106
|
+
domain: entry.domain,
|
|
6107
|
+
transform: (_a2 = entry.transform) != null ? _a2 : void 0
|
|
6108
|
+
});
|
|
6109
|
+
}
|
|
6110
|
+
)
|
|
6111
|
+
};
|
|
6112
|
+
}
|
|
6113
|
+
environment = pruneUndefined({
|
|
6114
|
+
type: "remote",
|
|
6115
|
+
sources: sources != null && sources.length > 0 ? sources : void 0,
|
|
6116
|
+
network
|
|
6117
|
+
});
|
|
6118
|
+
}
|
|
6119
|
+
}
|
|
5986
6120
|
const args = pruneUndefined({
|
|
5987
6121
|
...isAgent ? { agent: this.agent } : { model: this.modelId },
|
|
5988
6122
|
input,
|
|
@@ -5990,18 +6124,20 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
5990
6124
|
tools: toolsForBody,
|
|
5991
6125
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5992
6126
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5993
|
-
previous_interaction_id: (
|
|
5994
|
-
service_tier: (
|
|
5995
|
-
store: (
|
|
6127
|
+
previous_interaction_id: (_v = opts == null ? void 0 : opts.previousInteractionId) != null ? _v : void 0,
|
|
6128
|
+
service_tier: (_w = opts == null ? void 0 : opts.serviceTier) != null ? _w : void 0,
|
|
6129
|
+
store: (_x = opts == null ? void 0 : opts.store) != null ? _x : void 0,
|
|
5996
6130
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5997
6131
|
agent_config: agentConfig,
|
|
5998
|
-
|
|
6132
|
+
environment,
|
|
6133
|
+
background: (_y = opts == null ? void 0 : opts.background) != null ? _y : void 0
|
|
5999
6134
|
});
|
|
6000
6135
|
return {
|
|
6001
6136
|
args,
|
|
6002
6137
|
warnings,
|
|
6003
6138
|
isAgent,
|
|
6004
|
-
|
|
6139
|
+
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
6140
|
+
pollingTimeoutMs: (_z = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _z : void 0
|
|
6005
6141
|
};
|
|
6006
6142
|
}
|
|
6007
6143
|
async doGenerate(options) {
|
|
@@ -6087,14 +6223,14 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
|
|
|
6087
6223
|
}
|
|
6088
6224
|
async doStream(options) {
|
|
6089
6225
|
var _a;
|
|
6090
|
-
const { args, warnings,
|
|
6226
|
+
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
6091
6227
|
const url = `${this.config.baseURL}/interactions`;
|
|
6092
6228
|
const mergedHeaders = combineHeaders7(
|
|
6093
6229
|
INTERACTIONS_API_REVISION_HEADER,
|
|
6094
6230
|
this.config.headers ? await resolve5(this.config.headers) : void 0,
|
|
6095
6231
|
options.headers
|
|
6096
6232
|
);
|
|
6097
|
-
if (
|
|
6233
|
+
if (isBackground) {
|
|
6098
6234
|
return this.doStreamBackground({
|
|
6099
6235
|
args,
|
|
6100
6236
|
warnings,
|