@google/genai 0.6.1 → 0.8.0
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/dist/genai.d.ts +554 -48
- package/dist/index.js +1720 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1713 -69
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +4677 -3028
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +554 -48
- package/dist/web/index.mjs +4657 -3013
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +554 -48
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -1512,6 +1512,7 @@ class Pager {
|
|
|
1512
1512
|
* SPDX-License-Identifier: Apache-2.0
|
|
1513
1513
|
*/
|
|
1514
1514
|
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
1515
|
+
/** Required. Outcome of the code execution. */
|
|
1515
1516
|
var Outcome;
|
|
1516
1517
|
(function (Outcome) {
|
|
1517
1518
|
Outcome["OUTCOME_UNSPECIFIED"] = "OUTCOME_UNSPECIFIED";
|
|
@@ -1519,11 +1520,13 @@ var Outcome;
|
|
|
1519
1520
|
Outcome["OUTCOME_FAILED"] = "OUTCOME_FAILED";
|
|
1520
1521
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
1521
1522
|
})(Outcome || (Outcome = {}));
|
|
1523
|
+
/** Required. Programming language of the `code`. */
|
|
1522
1524
|
var Language;
|
|
1523
1525
|
(function (Language) {
|
|
1524
1526
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1525
1527
|
Language["PYTHON"] = "PYTHON";
|
|
1526
1528
|
})(Language || (Language = {}));
|
|
1529
|
+
/** Optional. The type of the data. */
|
|
1527
1530
|
var Type;
|
|
1528
1531
|
(function (Type) {
|
|
1529
1532
|
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
@@ -1534,6 +1537,7 @@ var Type;
|
|
|
1534
1537
|
Type["ARRAY"] = "ARRAY";
|
|
1535
1538
|
Type["OBJECT"] = "OBJECT";
|
|
1536
1539
|
})(Type || (Type = {}));
|
|
1540
|
+
/** Required. Harm category. */
|
|
1537
1541
|
var HarmCategory;
|
|
1538
1542
|
(function (HarmCategory) {
|
|
1539
1543
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
@@ -1543,12 +1547,14 @@ var HarmCategory;
|
|
|
1543
1547
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
1544
1548
|
HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
|
|
1545
1549
|
})(HarmCategory || (HarmCategory = {}));
|
|
1550
|
+
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
1546
1551
|
var HarmBlockMethod;
|
|
1547
1552
|
(function (HarmBlockMethod) {
|
|
1548
1553
|
HarmBlockMethod["HARM_BLOCK_METHOD_UNSPECIFIED"] = "HARM_BLOCK_METHOD_UNSPECIFIED";
|
|
1549
1554
|
HarmBlockMethod["SEVERITY"] = "SEVERITY";
|
|
1550
1555
|
HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
|
|
1551
1556
|
})(HarmBlockMethod || (HarmBlockMethod = {}));
|
|
1557
|
+
/** Required. The harm block threshold. */
|
|
1552
1558
|
var HarmBlockThreshold;
|
|
1553
1559
|
(function (HarmBlockThreshold) {
|
|
1554
1560
|
HarmBlockThreshold["HARM_BLOCK_THRESHOLD_UNSPECIFIED"] = "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
@@ -1558,11 +1564,16 @@ var HarmBlockThreshold;
|
|
|
1558
1564
|
HarmBlockThreshold["BLOCK_NONE"] = "BLOCK_NONE";
|
|
1559
1565
|
HarmBlockThreshold["OFF"] = "OFF";
|
|
1560
1566
|
})(HarmBlockThreshold || (HarmBlockThreshold = {}));
|
|
1567
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
1561
1568
|
var Mode;
|
|
1562
1569
|
(function (Mode) {
|
|
1563
1570
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1564
1571
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1565
1572
|
})(Mode || (Mode = {}));
|
|
1573
|
+
/** Output only. The reason why the model stopped generating tokens.
|
|
1574
|
+
|
|
1575
|
+
If empty, the model has not stopped generating the tokens.
|
|
1576
|
+
*/
|
|
1566
1577
|
var FinishReason;
|
|
1567
1578
|
(function (FinishReason) {
|
|
1568
1579
|
FinishReason["FINISH_REASON_UNSPECIFIED"] = "FINISH_REASON_UNSPECIFIED";
|
|
@@ -1577,6 +1588,7 @@ var FinishReason;
|
|
|
1577
1588
|
FinishReason["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL";
|
|
1578
1589
|
FinishReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
1579
1590
|
})(FinishReason || (FinishReason = {}));
|
|
1591
|
+
/** Output only. Harm probability levels in the content. */
|
|
1580
1592
|
var HarmProbability;
|
|
1581
1593
|
(function (HarmProbability) {
|
|
1582
1594
|
HarmProbability["HARM_PROBABILITY_UNSPECIFIED"] = "HARM_PROBABILITY_UNSPECIFIED";
|
|
@@ -1585,6 +1597,7 @@ var HarmProbability;
|
|
|
1585
1597
|
HarmProbability["MEDIUM"] = "MEDIUM";
|
|
1586
1598
|
HarmProbability["HIGH"] = "HIGH";
|
|
1587
1599
|
})(HarmProbability || (HarmProbability = {}));
|
|
1600
|
+
/** Output only. Harm severity levels in the content. */
|
|
1588
1601
|
var HarmSeverity;
|
|
1589
1602
|
(function (HarmSeverity) {
|
|
1590
1603
|
HarmSeverity["HARM_SEVERITY_UNSPECIFIED"] = "HARM_SEVERITY_UNSPECIFIED";
|
|
@@ -1593,6 +1606,7 @@ var HarmSeverity;
|
|
|
1593
1606
|
HarmSeverity["HARM_SEVERITY_MEDIUM"] = "HARM_SEVERITY_MEDIUM";
|
|
1594
1607
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
1595
1608
|
})(HarmSeverity || (HarmSeverity = {}));
|
|
1609
|
+
/** Output only. Blocked reason. */
|
|
1596
1610
|
var BlockedReason;
|
|
1597
1611
|
(function (BlockedReason) {
|
|
1598
1612
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
@@ -1601,6 +1615,14 @@ var BlockedReason;
|
|
|
1601
1615
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
1602
1616
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
1603
1617
|
})(BlockedReason || (BlockedReason = {}));
|
|
1618
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
1619
|
+
var TrafficType;
|
|
1620
|
+
(function (TrafficType) {
|
|
1621
|
+
TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
|
|
1622
|
+
TrafficType["ON_DEMAND"] = "ON_DEMAND";
|
|
1623
|
+
TrafficType["PROVISIONED_THROUGHPUT"] = "PROVISIONED_THROUGHPUT";
|
|
1624
|
+
})(TrafficType || (TrafficType = {}));
|
|
1625
|
+
/** Server content modalities. */
|
|
1604
1626
|
var Modality;
|
|
1605
1627
|
(function (Modality) {
|
|
1606
1628
|
Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
@@ -1608,17 +1630,21 @@ var Modality;
|
|
|
1608
1630
|
Modality["IMAGE"] = "IMAGE";
|
|
1609
1631
|
Modality["AUDIO"] = "AUDIO";
|
|
1610
1632
|
})(Modality || (Modality = {}));
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1633
|
+
/** The media resolution to use. */
|
|
1634
|
+
var MediaResolution;
|
|
1635
|
+
(function (MediaResolution) {
|
|
1636
|
+
MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1637
|
+
MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1638
|
+
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1639
|
+
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1640
|
+
})(MediaResolution || (MediaResolution = {}));
|
|
1641
|
+
/** Config for the dynamic retrieval config mode. */
|
|
1617
1642
|
var DynamicRetrievalConfigMode;
|
|
1618
1643
|
(function (DynamicRetrievalConfigMode) {
|
|
1619
1644
|
DynamicRetrievalConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1620
1645
|
DynamicRetrievalConfigMode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1621
1646
|
})(DynamicRetrievalConfigMode || (DynamicRetrievalConfigMode = {}));
|
|
1647
|
+
/** Config for the function calling config mode. */
|
|
1622
1648
|
var FunctionCallingConfigMode;
|
|
1623
1649
|
(function (FunctionCallingConfigMode) {
|
|
1624
1650
|
FunctionCallingConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
@@ -1626,13 +1652,7 @@ var FunctionCallingConfigMode;
|
|
|
1626
1652
|
FunctionCallingConfigMode["ANY"] = "ANY";
|
|
1627
1653
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
1628
1654
|
})(FunctionCallingConfigMode || (FunctionCallingConfigMode = {}));
|
|
1629
|
-
|
|
1630
|
-
(function (MediaResolution) {
|
|
1631
|
-
MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1632
|
-
MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1633
|
-
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1634
|
-
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1635
|
-
})(MediaResolution || (MediaResolution = {}));
|
|
1655
|
+
/** Enum that controls the safety filter level for objectionable content. */
|
|
1636
1656
|
var SafetyFilterLevel;
|
|
1637
1657
|
(function (SafetyFilterLevel) {
|
|
1638
1658
|
SafetyFilterLevel["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
@@ -1640,12 +1660,14 @@ var SafetyFilterLevel;
|
|
|
1640
1660
|
SafetyFilterLevel["BLOCK_ONLY_HIGH"] = "BLOCK_ONLY_HIGH";
|
|
1641
1661
|
SafetyFilterLevel["BLOCK_NONE"] = "BLOCK_NONE";
|
|
1642
1662
|
})(SafetyFilterLevel || (SafetyFilterLevel = {}));
|
|
1663
|
+
/** Enum that controls the generation of people. */
|
|
1643
1664
|
var PersonGeneration;
|
|
1644
1665
|
(function (PersonGeneration) {
|
|
1645
1666
|
PersonGeneration["DONT_ALLOW"] = "DONT_ALLOW";
|
|
1646
1667
|
PersonGeneration["ALLOW_ADULT"] = "ALLOW_ADULT";
|
|
1647
1668
|
PersonGeneration["ALLOW_ALL"] = "ALLOW_ALL";
|
|
1648
1669
|
})(PersonGeneration || (PersonGeneration = {}));
|
|
1670
|
+
/** Enum that specifies the language of the text in the prompt. */
|
|
1649
1671
|
var ImagePromptLanguage;
|
|
1650
1672
|
(function (ImagePromptLanguage) {
|
|
1651
1673
|
ImagePromptLanguage["auto"] = "auto";
|
|
@@ -1654,6 +1676,7 @@ var ImagePromptLanguage;
|
|
|
1654
1676
|
ImagePromptLanguage["ko"] = "ko";
|
|
1655
1677
|
ImagePromptLanguage["hi"] = "hi";
|
|
1656
1678
|
})(ImagePromptLanguage || (ImagePromptLanguage = {}));
|
|
1679
|
+
/** State for the lifecycle of a File. */
|
|
1657
1680
|
var FileState;
|
|
1658
1681
|
(function (FileState) {
|
|
1659
1682
|
FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
@@ -1661,12 +1684,14 @@ var FileState;
|
|
|
1661
1684
|
FileState["ACTIVE"] = "ACTIVE";
|
|
1662
1685
|
FileState["FAILED"] = "FAILED";
|
|
1663
1686
|
})(FileState || (FileState = {}));
|
|
1687
|
+
/** Source of the File. */
|
|
1664
1688
|
var FileSource;
|
|
1665
1689
|
(function (FileSource) {
|
|
1666
1690
|
FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
|
|
1667
1691
|
FileSource["UPLOADED"] = "UPLOADED";
|
|
1668
1692
|
FileSource["GENERATED"] = "GENERATED";
|
|
1669
1693
|
})(FileSource || (FileSource = {}));
|
|
1694
|
+
/** Enum representing the mask mode of a mask reference image. */
|
|
1670
1695
|
var MaskReferenceMode;
|
|
1671
1696
|
(function (MaskReferenceMode) {
|
|
1672
1697
|
MaskReferenceMode["MASK_MODE_DEFAULT"] = "MASK_MODE_DEFAULT";
|
|
@@ -1675,6 +1700,7 @@ var MaskReferenceMode;
|
|
|
1675
1700
|
MaskReferenceMode["MASK_MODE_FOREGROUND"] = "MASK_MODE_FOREGROUND";
|
|
1676
1701
|
MaskReferenceMode["MASK_MODE_SEMANTIC"] = "MASK_MODE_SEMANTIC";
|
|
1677
1702
|
})(MaskReferenceMode || (MaskReferenceMode = {}));
|
|
1703
|
+
/** Enum representing the control type of a control reference image. */
|
|
1678
1704
|
var ControlReferenceType;
|
|
1679
1705
|
(function (ControlReferenceType) {
|
|
1680
1706
|
ControlReferenceType["CONTROL_TYPE_DEFAULT"] = "CONTROL_TYPE_DEFAULT";
|
|
@@ -1682,6 +1708,7 @@ var ControlReferenceType;
|
|
|
1682
1708
|
ControlReferenceType["CONTROL_TYPE_SCRIBBLE"] = "CONTROL_TYPE_SCRIBBLE";
|
|
1683
1709
|
ControlReferenceType["CONTROL_TYPE_FACE_MESH"] = "CONTROL_TYPE_FACE_MESH";
|
|
1684
1710
|
})(ControlReferenceType || (ControlReferenceType = {}));
|
|
1711
|
+
/** Enum representing the subject type of a subject reference image. */
|
|
1685
1712
|
var SubjectReferenceType;
|
|
1686
1713
|
(function (SubjectReferenceType) {
|
|
1687
1714
|
SubjectReferenceType["SUBJECT_TYPE_DEFAULT"] = "SUBJECT_TYPE_DEFAULT";
|
|
@@ -1689,6 +1716,44 @@ var SubjectReferenceType;
|
|
|
1689
1716
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
1690
1717
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
1691
1718
|
})(SubjectReferenceType || (SubjectReferenceType = {}));
|
|
1719
|
+
/** Server content modalities. */
|
|
1720
|
+
var MediaModality;
|
|
1721
|
+
(function (MediaModality) {
|
|
1722
|
+
MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
1723
|
+
MediaModality["TEXT"] = "TEXT";
|
|
1724
|
+
MediaModality["IMAGE"] = "IMAGE";
|
|
1725
|
+
MediaModality["VIDEO"] = "VIDEO";
|
|
1726
|
+
MediaModality["AUDIO"] = "AUDIO";
|
|
1727
|
+
MediaModality["DOCUMENT"] = "DOCUMENT";
|
|
1728
|
+
})(MediaModality || (MediaModality = {}));
|
|
1729
|
+
/** Start of speech sensitivity. */
|
|
1730
|
+
var StartSensitivity;
|
|
1731
|
+
(function (StartSensitivity) {
|
|
1732
|
+
StartSensitivity["START_SENSITIVITY_UNSPECIFIED"] = "START_SENSITIVITY_UNSPECIFIED";
|
|
1733
|
+
StartSensitivity["START_SENSITIVITY_HIGH"] = "START_SENSITIVITY_HIGH";
|
|
1734
|
+
StartSensitivity["START_SENSITIVITY_LOW"] = "START_SENSITIVITY_LOW";
|
|
1735
|
+
})(StartSensitivity || (StartSensitivity = {}));
|
|
1736
|
+
/** End of speech sensitivity. */
|
|
1737
|
+
var EndSensitivity;
|
|
1738
|
+
(function (EndSensitivity) {
|
|
1739
|
+
EndSensitivity["END_SENSITIVITY_UNSPECIFIED"] = "END_SENSITIVITY_UNSPECIFIED";
|
|
1740
|
+
EndSensitivity["END_SENSITIVITY_HIGH"] = "END_SENSITIVITY_HIGH";
|
|
1741
|
+
EndSensitivity["END_SENSITIVITY_LOW"] = "END_SENSITIVITY_LOW";
|
|
1742
|
+
})(EndSensitivity || (EndSensitivity = {}));
|
|
1743
|
+
/** The different ways of handling user activity. */
|
|
1744
|
+
var ActivityHandling;
|
|
1745
|
+
(function (ActivityHandling) {
|
|
1746
|
+
ActivityHandling["ACTIVITY_HANDLING_UNSPECIFIED"] = "ACTIVITY_HANDLING_UNSPECIFIED";
|
|
1747
|
+
ActivityHandling["START_OF_ACTIVITY_INTERRUPTS"] = "START_OF_ACTIVITY_INTERRUPTS";
|
|
1748
|
+
ActivityHandling["NO_INTERRUPTION"] = "NO_INTERRUPTION";
|
|
1749
|
+
})(ActivityHandling || (ActivityHandling = {}));
|
|
1750
|
+
/** Options about which input is included in the user's turn. */
|
|
1751
|
+
var TurnCoverage;
|
|
1752
|
+
(function (TurnCoverage) {
|
|
1753
|
+
TurnCoverage["TURN_COVERAGE_UNSPECIFIED"] = "TURN_COVERAGE_UNSPECIFIED";
|
|
1754
|
+
TurnCoverage["TURN_INCLUDES_ONLY_ACTIVITY"] = "TURN_INCLUDES_ONLY_ACTIVITY";
|
|
1755
|
+
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1756
|
+
})(TurnCoverage || (TurnCoverage = {}));
|
|
1692
1757
|
/** A function response. */
|
|
1693
1758
|
class FunctionResponse {
|
|
1694
1759
|
}
|
|
@@ -1735,7 +1800,7 @@ function createPartFromFunctionResponse(id, name, response) {
|
|
|
1735
1800
|
};
|
|
1736
1801
|
}
|
|
1737
1802
|
/**
|
|
1738
|
-
* Creates a `Part` object from a `base64` `string`.
|
|
1803
|
+
* Creates a `Part` object from a `base64` encoded `string`.
|
|
1739
1804
|
*/
|
|
1740
1805
|
function createPartFromBase64(data, mimeType) {
|
|
1741
1806
|
return {
|
|
@@ -2035,6 +2100,9 @@ class CountTokensResponse {
|
|
|
2035
2100
|
/** Response for computing tokens. */
|
|
2036
2101
|
class ComputeTokensResponse {
|
|
2037
2102
|
}
|
|
2103
|
+
/** Response with generated videos. */
|
|
2104
|
+
class GenerateVideosResponse {
|
|
2105
|
+
}
|
|
2038
2106
|
/** Empty response for caches.delete method. */
|
|
2039
2107
|
class DeleteCachedContentResponse {
|
|
2040
2108
|
}
|
|
@@ -2118,6 +2186,12 @@ class Caches extends BaseModule {
|
|
|
2118
2186
|
/**
|
|
2119
2187
|
* Creates a cached contents resource.
|
|
2120
2188
|
*
|
|
2189
|
+
* @remarks
|
|
2190
|
+
* Context caching is only supported for specific models. See [Gemini
|
|
2191
|
+
* Developer API reference] (https://ai.google.dev/gemini-api/docs/caching?lang=node/context-cac)
|
|
2192
|
+
* and [Vertex AI reference] (https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-overview#supported_models)
|
|
2193
|
+
* for more information.
|
|
2194
|
+
*
|
|
2121
2195
|
* @param params - The parameters for the create request.
|
|
2122
2196
|
* @return The created cached content.
|
|
2123
2197
|
*
|
|
@@ -2125,7 +2199,7 @@ class Caches extends BaseModule {
|
|
|
2125
2199
|
* ```ts
|
|
2126
2200
|
* const contents = ...; // Initialize the content to cache.
|
|
2127
2201
|
* const response = await ai.caches.create({
|
|
2128
|
-
* model: 'gemini-
|
|
2202
|
+
* model: 'gemini-1.5-flash',
|
|
2129
2203
|
* config: {
|
|
2130
2204
|
* 'contents': contents,
|
|
2131
2205
|
* 'displayName': 'test cache',
|
|
@@ -2805,9 +2879,10 @@ class Chat {
|
|
|
2805
2879
|
* SPDX-License-Identifier: Apache-2.0
|
|
2806
2880
|
*/
|
|
2807
2881
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
2882
|
+
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2808
2883
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2809
2884
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2810
|
-
const SDK_VERSION = '0.
|
|
2885
|
+
const SDK_VERSION = '0.8.0'; // x-release-please-version
|
|
2811
2886
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2812
2887
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2813
2888
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2947,11 +3022,9 @@ class ApiClient {
|
|
|
2947
3022
|
throw new Error('HTTP options are not correctly set.');
|
|
2948
3023
|
}
|
|
2949
3024
|
}
|
|
2950
|
-
constructUrl(path, httpOptions) {
|
|
3025
|
+
constructUrl(path, httpOptions, prependProjectLocation) {
|
|
2951
3026
|
const urlElement = [this.getRequestUrlInternal(httpOptions)];
|
|
2952
|
-
if (
|
|
2953
|
-
!this.clientOptions.apiKey &&
|
|
2954
|
-
!path.startsWith('projects/')) {
|
|
3027
|
+
if (prependProjectLocation) {
|
|
2955
3028
|
urlElement.push(this.getBaseResourcePath());
|
|
2956
3029
|
}
|
|
2957
3030
|
if (path !== '') {
|
|
@@ -2960,12 +3033,34 @@ class ApiClient {
|
|
|
2960
3033
|
const url = new URL(`${urlElement.join('/')}`);
|
|
2961
3034
|
return url;
|
|
2962
3035
|
}
|
|
3036
|
+
shouldPrependVertexProjectPath(request) {
|
|
3037
|
+
if (this.clientOptions.apiKey) {
|
|
3038
|
+
return false;
|
|
3039
|
+
}
|
|
3040
|
+
if (!this.clientOptions.vertexai) {
|
|
3041
|
+
return false;
|
|
3042
|
+
}
|
|
3043
|
+
if (request.path.startsWith('projects/')) {
|
|
3044
|
+
// Assume the path already starts with
|
|
3045
|
+
// `projects/<project>/location/<location>`.
|
|
3046
|
+
return false;
|
|
3047
|
+
}
|
|
3048
|
+
if (request.httpMethod === 'GET' &&
|
|
3049
|
+
request.path.startsWith('publishers/google/models')) {
|
|
3050
|
+
// These paths are used by Vertex's models.get and models.list
|
|
3051
|
+
// calls. For base models Vertex does not accept a project/location
|
|
3052
|
+
// prefix (for tuned model the prefix is required).
|
|
3053
|
+
return false;
|
|
3054
|
+
}
|
|
3055
|
+
return true;
|
|
3056
|
+
}
|
|
2963
3057
|
async request(request) {
|
|
2964
3058
|
let patchedHttpOptions = this.clientOptions.httpOptions;
|
|
2965
3059
|
if (request.httpOptions) {
|
|
2966
3060
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
2967
3061
|
}
|
|
2968
|
-
const
|
|
3062
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3063
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
2969
3064
|
if (request.queryParams) {
|
|
2970
3065
|
for (const [key, value] of Object.entries(request.queryParams)) {
|
|
2971
3066
|
url.searchParams.append(key, String(value));
|
|
@@ -3007,7 +3102,8 @@ class ApiClient {
|
|
|
3007
3102
|
if (request.httpOptions) {
|
|
3008
3103
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
3009
3104
|
}
|
|
3010
|
-
const
|
|
3105
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3106
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
3011
3107
|
if (!url.searchParams.has('alt') || url.searchParams.get('alt') !== 'sse') {
|
|
3012
3108
|
url.searchParams.set('alt', 'sse');
|
|
3013
3109
|
}
|
|
@@ -3115,6 +3211,11 @@ class ApiClient {
|
|
|
3115
3211
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
3116
3212
|
headers.append(key, value);
|
|
3117
3213
|
}
|
|
3214
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
3215
|
+
// in milliseconds but the header is in seconds.
|
|
3216
|
+
if (httpOptions.timeout && httpOptions.timeout > 0) {
|
|
3217
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
3218
|
+
}
|
|
3118
3219
|
}
|
|
3119
3220
|
await this.clientOptions.auth.addAuthHeaders(headers);
|
|
3120
3221
|
return headers;
|
|
@@ -3143,7 +3244,7 @@ class ApiClient {
|
|
|
3143
3244
|
}
|
|
3144
3245
|
const uploader = this.clientOptions.uploader;
|
|
3145
3246
|
const fileStat = await uploader.stat(file);
|
|
3146
|
-
fileToUpload.sizeBytes = fileStat.size;
|
|
3247
|
+
fileToUpload.sizeBytes = String(fileStat.size);
|
|
3147
3248
|
const mimeType = (_a = config === null || config === void 0 ? void 0 : config.mimeType) !== null && _a !== void 0 ? _a : fileStat.type;
|
|
3148
3249
|
if (mimeType === undefined || mimeType === '') {
|
|
3149
3250
|
throw new Error('Can not determine mimeType. Please provide mimeType in the config.');
|
|
@@ -3629,8 +3730,9 @@ class Files extends BaseModule {
|
|
|
3629
3730
|
* This section can contain multiple paragraphs and code examples.
|
|
3630
3731
|
*
|
|
3631
3732
|
* @param params - Optional parameters specified in the
|
|
3632
|
-
* `
|
|
3633
|
-
*
|
|
3733
|
+
* `types.UploadFileParameters` interface.
|
|
3734
|
+
* @see {@link types.UploadFileParameters#config} for the optional
|
|
3735
|
+
* config in the parameters.
|
|
3634
3736
|
* @return A promise that resolves to a `types.File` object.
|
|
3635
3737
|
* @throws An error if called on a Vertex AI client.
|
|
3636
3738
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -4134,6 +4236,12 @@ function thinkingConfigToMldev(apiClient, fromObject) {
|
|
|
4134
4236
|
if (fromIncludeThoughts != null) {
|
|
4135
4237
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4136
4238
|
}
|
|
4239
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
4240
|
+
'thinkingBudget',
|
|
4241
|
+
]);
|
|
4242
|
+
if (fromThinkingBudget != null) {
|
|
4243
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
4244
|
+
}
|
|
4137
4245
|
return toObject;
|
|
4138
4246
|
}
|
|
4139
4247
|
function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
@@ -4437,6 +4545,18 @@ function generateImagesParametersToMldev(apiClient, fromObject) {
|
|
|
4437
4545
|
}
|
|
4438
4546
|
return toObject;
|
|
4439
4547
|
}
|
|
4548
|
+
function getModelParametersToMldev(apiClient, fromObject) {
|
|
4549
|
+
const toObject = {};
|
|
4550
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4551
|
+
if (fromModel != null) {
|
|
4552
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
4553
|
+
}
|
|
4554
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4555
|
+
if (fromConfig != null) {
|
|
4556
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
4557
|
+
}
|
|
4558
|
+
return toObject;
|
|
4559
|
+
}
|
|
4440
4560
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
4441
4561
|
const toObject = {};
|
|
4442
4562
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -4473,6 +4593,91 @@ function countTokensParametersToMldev(apiClient, fromObject) {
|
|
|
4473
4593
|
}
|
|
4474
4594
|
return toObject;
|
|
4475
4595
|
}
|
|
4596
|
+
function imageToMldev(apiClient, fromObject) {
|
|
4597
|
+
const toObject = {};
|
|
4598
|
+
if (getValueByPath(fromObject, ['gcsUri']) !== undefined) {
|
|
4599
|
+
throw new Error('gcsUri parameter is not supported in Gemini API.');
|
|
4600
|
+
}
|
|
4601
|
+
const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
|
|
4602
|
+
if (fromImageBytes != null) {
|
|
4603
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
|
|
4604
|
+
}
|
|
4605
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
4606
|
+
if (fromMimeType != null) {
|
|
4607
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
4608
|
+
}
|
|
4609
|
+
return toObject;
|
|
4610
|
+
}
|
|
4611
|
+
function generateVideosConfigToMldev(apiClient, fromObject, parentObject) {
|
|
4612
|
+
const toObject = {};
|
|
4613
|
+
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
4614
|
+
'numberOfVideos',
|
|
4615
|
+
]);
|
|
4616
|
+
if (parentObject !== undefined && fromNumberOfVideos != null) {
|
|
4617
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
|
|
4618
|
+
}
|
|
4619
|
+
if (getValueByPath(fromObject, ['outputGcsUri']) !== undefined) {
|
|
4620
|
+
throw new Error('outputGcsUri parameter is not supported in Gemini API.');
|
|
4621
|
+
}
|
|
4622
|
+
if (getValueByPath(fromObject, ['fps']) !== undefined) {
|
|
4623
|
+
throw new Error('fps parameter is not supported in Gemini API.');
|
|
4624
|
+
}
|
|
4625
|
+
const fromDurationSeconds = getValueByPath(fromObject, [
|
|
4626
|
+
'durationSeconds',
|
|
4627
|
+
]);
|
|
4628
|
+
if (parentObject !== undefined && fromDurationSeconds != null) {
|
|
4629
|
+
setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
|
|
4630
|
+
}
|
|
4631
|
+
if (getValueByPath(fromObject, ['seed']) !== undefined) {
|
|
4632
|
+
throw new Error('seed parameter is not supported in Gemini API.');
|
|
4633
|
+
}
|
|
4634
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
4635
|
+
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
4636
|
+
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
4637
|
+
}
|
|
4638
|
+
if (getValueByPath(fromObject, ['resolution']) !== undefined) {
|
|
4639
|
+
throw new Error('resolution parameter is not supported in Gemini API.');
|
|
4640
|
+
}
|
|
4641
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
4642
|
+
'personGeneration',
|
|
4643
|
+
]);
|
|
4644
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
4645
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
4646
|
+
}
|
|
4647
|
+
if (getValueByPath(fromObject, ['pubsubTopic']) !== undefined) {
|
|
4648
|
+
throw new Error('pubsubTopic parameter is not supported in Gemini API.');
|
|
4649
|
+
}
|
|
4650
|
+
const fromNegativePrompt = getValueByPath(fromObject, [
|
|
4651
|
+
'negativePrompt',
|
|
4652
|
+
]);
|
|
4653
|
+
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
4654
|
+
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
4655
|
+
}
|
|
4656
|
+
if (getValueByPath(fromObject, ['enhancePrompt']) !== undefined) {
|
|
4657
|
+
throw new Error('enhancePrompt parameter is not supported in Gemini API.');
|
|
4658
|
+
}
|
|
4659
|
+
return toObject;
|
|
4660
|
+
}
|
|
4661
|
+
function generateVideosParametersToMldev(apiClient, fromObject) {
|
|
4662
|
+
const toObject = {};
|
|
4663
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4664
|
+
if (fromModel != null) {
|
|
4665
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
4666
|
+
}
|
|
4667
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
4668
|
+
if (fromPrompt != null) {
|
|
4669
|
+
setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
4670
|
+
}
|
|
4671
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
4672
|
+
if (fromImage != null) {
|
|
4673
|
+
setValueByPath(toObject, ['instances[0]', 'image'], imageToMldev(apiClient, fromImage));
|
|
4674
|
+
}
|
|
4675
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4676
|
+
if (fromConfig != null) {
|
|
4677
|
+
setValueByPath(toObject, ['config'], generateVideosConfigToMldev(apiClient, fromConfig, toObject));
|
|
4678
|
+
}
|
|
4679
|
+
return toObject;
|
|
4680
|
+
}
|
|
4476
4681
|
function partToVertex(apiClient, fromObject) {
|
|
4477
4682
|
const toObject = {};
|
|
4478
4683
|
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
@@ -4797,6 +5002,12 @@ function thinkingConfigToVertex(apiClient, fromObject) {
|
|
|
4797
5002
|
if (fromIncludeThoughts != null) {
|
|
4798
5003
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4799
5004
|
}
|
|
5005
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
5006
|
+
'thinkingBudget',
|
|
5007
|
+
]);
|
|
5008
|
+
if (fromThinkingBudget != null) {
|
|
5009
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
5010
|
+
}
|
|
4800
5011
|
return toObject;
|
|
4801
5012
|
}
|
|
4802
5013
|
function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
@@ -5114,6 +5325,18 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
|
|
|
5114
5325
|
}
|
|
5115
5326
|
return toObject;
|
|
5116
5327
|
}
|
|
5328
|
+
function getModelParametersToVertex(apiClient, fromObject) {
|
|
5329
|
+
const toObject = {};
|
|
5330
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5331
|
+
if (fromModel != null) {
|
|
5332
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5333
|
+
}
|
|
5334
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5335
|
+
if (fromConfig != null) {
|
|
5336
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5337
|
+
}
|
|
5338
|
+
return toObject;
|
|
5339
|
+
}
|
|
5117
5340
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5118
5341
|
const toObject = {};
|
|
5119
5342
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -5187,6 +5410,100 @@ function computeTokensParametersToVertex(apiClient, fromObject) {
|
|
|
5187
5410
|
}
|
|
5188
5411
|
return toObject;
|
|
5189
5412
|
}
|
|
5413
|
+
function imageToVertex(apiClient, fromObject) {
|
|
5414
|
+
const toObject = {};
|
|
5415
|
+
const fromGcsUri = getValueByPath(fromObject, ['gcsUri']);
|
|
5416
|
+
if (fromGcsUri != null) {
|
|
5417
|
+
setValueByPath(toObject, ['gcsUri'], fromGcsUri);
|
|
5418
|
+
}
|
|
5419
|
+
const fromImageBytes = getValueByPath(fromObject, ['imageBytes']);
|
|
5420
|
+
if (fromImageBytes != null) {
|
|
5421
|
+
setValueByPath(toObject, ['bytesBase64Encoded'], tBytes(apiClient, fromImageBytes));
|
|
5422
|
+
}
|
|
5423
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
5424
|
+
if (fromMimeType != null) {
|
|
5425
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5426
|
+
}
|
|
5427
|
+
return toObject;
|
|
5428
|
+
}
|
|
5429
|
+
function generateVideosConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5430
|
+
const toObject = {};
|
|
5431
|
+
const fromNumberOfVideos = getValueByPath(fromObject, [
|
|
5432
|
+
'numberOfVideos',
|
|
5433
|
+
]);
|
|
5434
|
+
if (parentObject !== undefined && fromNumberOfVideos != null) {
|
|
5435
|
+
setValueByPath(parentObject, ['parameters', 'sampleCount'], fromNumberOfVideos);
|
|
5436
|
+
}
|
|
5437
|
+
const fromOutputGcsUri = getValueByPath(fromObject, ['outputGcsUri']);
|
|
5438
|
+
if (parentObject !== undefined && fromOutputGcsUri != null) {
|
|
5439
|
+
setValueByPath(parentObject, ['parameters', 'storageUri'], fromOutputGcsUri);
|
|
5440
|
+
}
|
|
5441
|
+
const fromFps = getValueByPath(fromObject, ['fps']);
|
|
5442
|
+
if (parentObject !== undefined && fromFps != null) {
|
|
5443
|
+
setValueByPath(parentObject, ['parameters', 'fps'], fromFps);
|
|
5444
|
+
}
|
|
5445
|
+
const fromDurationSeconds = getValueByPath(fromObject, [
|
|
5446
|
+
'durationSeconds',
|
|
5447
|
+
]);
|
|
5448
|
+
if (parentObject !== undefined && fromDurationSeconds != null) {
|
|
5449
|
+
setValueByPath(parentObject, ['parameters', 'durationSeconds'], fromDurationSeconds);
|
|
5450
|
+
}
|
|
5451
|
+
const fromSeed = getValueByPath(fromObject, ['seed']);
|
|
5452
|
+
if (parentObject !== undefined && fromSeed != null) {
|
|
5453
|
+
setValueByPath(parentObject, ['parameters', 'seed'], fromSeed);
|
|
5454
|
+
}
|
|
5455
|
+
const fromAspectRatio = getValueByPath(fromObject, ['aspectRatio']);
|
|
5456
|
+
if (parentObject !== undefined && fromAspectRatio != null) {
|
|
5457
|
+
setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
|
|
5458
|
+
}
|
|
5459
|
+
const fromResolution = getValueByPath(fromObject, ['resolution']);
|
|
5460
|
+
if (parentObject !== undefined && fromResolution != null) {
|
|
5461
|
+
setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
|
|
5462
|
+
}
|
|
5463
|
+
const fromPersonGeneration = getValueByPath(fromObject, [
|
|
5464
|
+
'personGeneration',
|
|
5465
|
+
]);
|
|
5466
|
+
if (parentObject !== undefined && fromPersonGeneration != null) {
|
|
5467
|
+
setValueByPath(parentObject, ['parameters', 'personGeneration'], fromPersonGeneration);
|
|
5468
|
+
}
|
|
5469
|
+
const fromPubsubTopic = getValueByPath(fromObject, ['pubsubTopic']);
|
|
5470
|
+
if (parentObject !== undefined && fromPubsubTopic != null) {
|
|
5471
|
+
setValueByPath(parentObject, ['parameters', 'pubsubTopic'], fromPubsubTopic);
|
|
5472
|
+
}
|
|
5473
|
+
const fromNegativePrompt = getValueByPath(fromObject, [
|
|
5474
|
+
'negativePrompt',
|
|
5475
|
+
]);
|
|
5476
|
+
if (parentObject !== undefined && fromNegativePrompt != null) {
|
|
5477
|
+
setValueByPath(parentObject, ['parameters', 'negativePrompt'], fromNegativePrompt);
|
|
5478
|
+
}
|
|
5479
|
+
const fromEnhancePrompt = getValueByPath(fromObject, [
|
|
5480
|
+
'enhancePrompt',
|
|
5481
|
+
]);
|
|
5482
|
+
if (parentObject !== undefined && fromEnhancePrompt != null) {
|
|
5483
|
+
setValueByPath(parentObject, ['parameters', 'enhancePrompt'], fromEnhancePrompt);
|
|
5484
|
+
}
|
|
5485
|
+
return toObject;
|
|
5486
|
+
}
|
|
5487
|
+
function generateVideosParametersToVertex(apiClient, fromObject) {
|
|
5488
|
+
const toObject = {};
|
|
5489
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5490
|
+
if (fromModel != null) {
|
|
5491
|
+
setValueByPath(toObject, ['_url', 'model'], tModel(apiClient, fromModel));
|
|
5492
|
+
}
|
|
5493
|
+
const fromPrompt = getValueByPath(fromObject, ['prompt']);
|
|
5494
|
+
if (fromPrompt != null) {
|
|
5495
|
+
setValueByPath(toObject, ['instances[0]', 'prompt'], fromPrompt);
|
|
5496
|
+
}
|
|
5497
|
+
const fromImage = getValueByPath(fromObject, ['image']);
|
|
5498
|
+
if (fromImage != null) {
|
|
5499
|
+
setValueByPath(toObject, ['instances[0]', 'image'], imageToVertex(apiClient, fromImage));
|
|
5500
|
+
}
|
|
5501
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5502
|
+
if (fromConfig != null) {
|
|
5503
|
+
setValueByPath(toObject, ['config'], generateVideosConfigToVertex(apiClient, fromConfig, toObject));
|
|
5504
|
+
}
|
|
5505
|
+
return toObject;
|
|
5506
|
+
}
|
|
5190
5507
|
function partFromMldev(apiClient, fromObject) {
|
|
5191
5508
|
const toObject = {};
|
|
5192
5509
|
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
@@ -5443,6 +5760,64 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
5443
5760
|
}
|
|
5444
5761
|
return toObject;
|
|
5445
5762
|
}
|
|
5763
|
+
function tunedModelInfoFromMldev(apiClient, fromObject) {
|
|
5764
|
+
const toObject = {};
|
|
5765
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
5766
|
+
if (fromBaseModel != null) {
|
|
5767
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
5768
|
+
}
|
|
5769
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
5770
|
+
if (fromCreateTime != null) {
|
|
5771
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
5772
|
+
}
|
|
5773
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
5774
|
+
if (fromUpdateTime != null) {
|
|
5775
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
5776
|
+
}
|
|
5777
|
+
return toObject;
|
|
5778
|
+
}
|
|
5779
|
+
function modelFromMldev(apiClient, fromObject) {
|
|
5780
|
+
const toObject = {};
|
|
5781
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
5782
|
+
if (fromName != null) {
|
|
5783
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
5784
|
+
}
|
|
5785
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5786
|
+
if (fromDisplayName != null) {
|
|
5787
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
5788
|
+
}
|
|
5789
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5790
|
+
if (fromDescription != null) {
|
|
5791
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
5792
|
+
}
|
|
5793
|
+
const fromVersion = getValueByPath(fromObject, ['version']);
|
|
5794
|
+
if (fromVersion != null) {
|
|
5795
|
+
setValueByPath(toObject, ['version'], fromVersion);
|
|
5796
|
+
}
|
|
5797
|
+
const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
|
|
5798
|
+
if (fromTunedModelInfo != null) {
|
|
5799
|
+
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromMldev(apiClient, fromTunedModelInfo));
|
|
5800
|
+
}
|
|
5801
|
+
const fromInputTokenLimit = getValueByPath(fromObject, [
|
|
5802
|
+
'inputTokenLimit',
|
|
5803
|
+
]);
|
|
5804
|
+
if (fromInputTokenLimit != null) {
|
|
5805
|
+
setValueByPath(toObject, ['inputTokenLimit'], fromInputTokenLimit);
|
|
5806
|
+
}
|
|
5807
|
+
const fromOutputTokenLimit = getValueByPath(fromObject, [
|
|
5808
|
+
'outputTokenLimit',
|
|
5809
|
+
]);
|
|
5810
|
+
if (fromOutputTokenLimit != null) {
|
|
5811
|
+
setValueByPath(toObject, ['outputTokenLimit'], fromOutputTokenLimit);
|
|
5812
|
+
}
|
|
5813
|
+
const fromSupportedActions = getValueByPath(fromObject, [
|
|
5814
|
+
'supportedGenerationMethods',
|
|
5815
|
+
]);
|
|
5816
|
+
if (fromSupportedActions != null) {
|
|
5817
|
+
setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
|
|
5818
|
+
}
|
|
5819
|
+
return toObject;
|
|
5820
|
+
}
|
|
5446
5821
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
5447
5822
|
const toObject = {};
|
|
5448
5823
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -5457,35 +5832,125 @@ function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
|
5457
5832
|
}
|
|
5458
5833
|
return toObject;
|
|
5459
5834
|
}
|
|
5460
|
-
function
|
|
5835
|
+
function videoFromMldev$1(apiClient, fromObject) {
|
|
5461
5836
|
const toObject = {};
|
|
5462
|
-
const
|
|
5463
|
-
|
|
5837
|
+
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
5838
|
+
if (fromUri != null) {
|
|
5839
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
5840
|
+
}
|
|
5841
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
5842
|
+
'video',
|
|
5843
|
+
'encodedVideo',
|
|
5464
5844
|
]);
|
|
5465
|
-
if (
|
|
5466
|
-
setValueByPath(toObject, ['
|
|
5845
|
+
if (fromVideoBytes != null) {
|
|
5846
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
5467
5847
|
}
|
|
5468
|
-
const
|
|
5469
|
-
if (
|
|
5470
|
-
setValueByPath(toObject, ['
|
|
5848
|
+
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
5849
|
+
if (fromMimeType != null) {
|
|
5850
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
5471
5851
|
}
|
|
5472
|
-
|
|
5473
|
-
|
|
5852
|
+
return toObject;
|
|
5853
|
+
}
|
|
5854
|
+
function generatedVideoFromMldev$1(apiClient, fromObject) {
|
|
5855
|
+
const toObject = {};
|
|
5856
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
5857
|
+
if (fromVideo != null) {
|
|
5858
|
+
setValueByPath(toObject, ['video'], videoFromMldev$1(apiClient, fromVideo));
|
|
5859
|
+
}
|
|
5860
|
+
return toObject;
|
|
5861
|
+
}
|
|
5862
|
+
function generateVideosResponseFromMldev$1(apiClient, fromObject) {
|
|
5863
|
+
const toObject = {};
|
|
5864
|
+
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
5865
|
+
'generatedSamples',
|
|
5474
5866
|
]);
|
|
5475
|
-
if (
|
|
5476
|
-
|
|
5867
|
+
if (fromGeneratedVideos != null) {
|
|
5868
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
5869
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
5870
|
+
return generatedVideoFromMldev$1(apiClient, item);
|
|
5871
|
+
}));
|
|
5872
|
+
}
|
|
5873
|
+
else {
|
|
5874
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
5875
|
+
}
|
|
5477
5876
|
}
|
|
5478
|
-
const
|
|
5479
|
-
'
|
|
5877
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
5878
|
+
'raiMediaFilteredCount',
|
|
5480
5879
|
]);
|
|
5481
|
-
if (
|
|
5482
|
-
setValueByPath(toObject, ['
|
|
5880
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
5881
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
5483
5882
|
}
|
|
5484
|
-
const
|
|
5485
|
-
|
|
5486
|
-
|
|
5883
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
5884
|
+
'raiMediaFilteredReasons',
|
|
5885
|
+
]);
|
|
5886
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
5887
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
5487
5888
|
}
|
|
5488
|
-
|
|
5889
|
+
return toObject;
|
|
5890
|
+
}
|
|
5891
|
+
function generateVideosOperationFromMldev$1(apiClient, fromObject) {
|
|
5892
|
+
const toObject = {};
|
|
5893
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
5894
|
+
if (fromName != null) {
|
|
5895
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
5896
|
+
}
|
|
5897
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
5898
|
+
if (fromMetadata != null) {
|
|
5899
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
5900
|
+
}
|
|
5901
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
5902
|
+
if (fromDone != null) {
|
|
5903
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
5904
|
+
}
|
|
5905
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
5906
|
+
if (fromError != null) {
|
|
5907
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
5908
|
+
}
|
|
5909
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
5910
|
+
'response',
|
|
5911
|
+
'generateVideoResponse',
|
|
5912
|
+
]);
|
|
5913
|
+
if (fromResponse != null) {
|
|
5914
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(apiClient, fromResponse));
|
|
5915
|
+
}
|
|
5916
|
+
const fromResult = getValueByPath(fromObject, [
|
|
5917
|
+
'response',
|
|
5918
|
+
'generateVideoResponse',
|
|
5919
|
+
]);
|
|
5920
|
+
if (fromResult != null) {
|
|
5921
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromMldev$1(apiClient, fromResult));
|
|
5922
|
+
}
|
|
5923
|
+
return toObject;
|
|
5924
|
+
}
|
|
5925
|
+
function partFromVertex(apiClient, fromObject) {
|
|
5926
|
+
const toObject = {};
|
|
5927
|
+
const fromVideoMetadata = getValueByPath(fromObject, [
|
|
5928
|
+
'videoMetadata',
|
|
5929
|
+
]);
|
|
5930
|
+
if (fromVideoMetadata != null) {
|
|
5931
|
+
setValueByPath(toObject, ['videoMetadata'], fromVideoMetadata);
|
|
5932
|
+
}
|
|
5933
|
+
const fromThought = getValueByPath(fromObject, ['thought']);
|
|
5934
|
+
if (fromThought != null) {
|
|
5935
|
+
setValueByPath(toObject, ['thought'], fromThought);
|
|
5936
|
+
}
|
|
5937
|
+
const fromCodeExecutionResult = getValueByPath(fromObject, [
|
|
5938
|
+
'codeExecutionResult',
|
|
5939
|
+
]);
|
|
5940
|
+
if (fromCodeExecutionResult != null) {
|
|
5941
|
+
setValueByPath(toObject, ['codeExecutionResult'], fromCodeExecutionResult);
|
|
5942
|
+
}
|
|
5943
|
+
const fromExecutableCode = getValueByPath(fromObject, [
|
|
5944
|
+
'executableCode',
|
|
5945
|
+
]);
|
|
5946
|
+
if (fromExecutableCode != null) {
|
|
5947
|
+
setValueByPath(toObject, ['executableCode'], fromExecutableCode);
|
|
5948
|
+
}
|
|
5949
|
+
const fromFileData = getValueByPath(fromObject, ['fileData']);
|
|
5950
|
+
if (fromFileData != null) {
|
|
5951
|
+
setValueByPath(toObject, ['fileData'], fromFileData);
|
|
5952
|
+
}
|
|
5953
|
+
const fromFunctionCall = getValueByPath(fromObject, ['functionCall']);
|
|
5489
5954
|
if (fromFunctionCall != null) {
|
|
5490
5955
|
setValueByPath(toObject, ['functionCall'], fromFunctionCall);
|
|
5491
5956
|
}
|
|
@@ -5762,6 +6227,78 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
5762
6227
|
}
|
|
5763
6228
|
return toObject;
|
|
5764
6229
|
}
|
|
6230
|
+
function endpointFromVertex(apiClient, fromObject) {
|
|
6231
|
+
const toObject = {};
|
|
6232
|
+
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
6233
|
+
if (fromName != null) {
|
|
6234
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
6235
|
+
}
|
|
6236
|
+
const fromDeployedModelId = getValueByPath(fromObject, [
|
|
6237
|
+
'deployedModelId',
|
|
6238
|
+
]);
|
|
6239
|
+
if (fromDeployedModelId != null) {
|
|
6240
|
+
setValueByPath(toObject, ['deployedModelId'], fromDeployedModelId);
|
|
6241
|
+
}
|
|
6242
|
+
return toObject;
|
|
6243
|
+
}
|
|
6244
|
+
function tunedModelInfoFromVertex(apiClient, fromObject) {
|
|
6245
|
+
const toObject = {};
|
|
6246
|
+
const fromBaseModel = getValueByPath(fromObject, [
|
|
6247
|
+
'labels',
|
|
6248
|
+
'google-vertex-llm-tuning-base-model-id',
|
|
6249
|
+
]);
|
|
6250
|
+
if (fromBaseModel != null) {
|
|
6251
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
6252
|
+
}
|
|
6253
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
6254
|
+
if (fromCreateTime != null) {
|
|
6255
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
6256
|
+
}
|
|
6257
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
6258
|
+
if (fromUpdateTime != null) {
|
|
6259
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
6260
|
+
}
|
|
6261
|
+
return toObject;
|
|
6262
|
+
}
|
|
6263
|
+
function modelFromVertex(apiClient, fromObject) {
|
|
6264
|
+
const toObject = {};
|
|
6265
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
6266
|
+
if (fromName != null) {
|
|
6267
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
6268
|
+
}
|
|
6269
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
6270
|
+
if (fromDisplayName != null) {
|
|
6271
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
6272
|
+
}
|
|
6273
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6274
|
+
if (fromDescription != null) {
|
|
6275
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
6276
|
+
}
|
|
6277
|
+
const fromVersion = getValueByPath(fromObject, ['versionId']);
|
|
6278
|
+
if (fromVersion != null) {
|
|
6279
|
+
setValueByPath(toObject, ['version'], fromVersion);
|
|
6280
|
+
}
|
|
6281
|
+
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
6282
|
+
if (fromEndpoints != null) {
|
|
6283
|
+
if (Array.isArray(fromEndpoints)) {
|
|
6284
|
+
setValueByPath(toObject, ['endpoints'], fromEndpoints.map((item) => {
|
|
6285
|
+
return endpointFromVertex(apiClient, item);
|
|
6286
|
+
}));
|
|
6287
|
+
}
|
|
6288
|
+
else {
|
|
6289
|
+
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
6290
|
+
}
|
|
6291
|
+
}
|
|
6292
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
6293
|
+
if (fromLabels != null) {
|
|
6294
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
6295
|
+
}
|
|
6296
|
+
const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
|
|
6297
|
+
if (fromTunedModelInfo != null) {
|
|
6298
|
+
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
|
|
6299
|
+
}
|
|
6300
|
+
return toObject;
|
|
6301
|
+
}
|
|
5765
6302
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
5766
6303
|
const toObject = {};
|
|
5767
6304
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -5778,6 +6315,87 @@ function computeTokensResponseFromVertex(apiClient, fromObject) {
|
|
|
5778
6315
|
}
|
|
5779
6316
|
return toObject;
|
|
5780
6317
|
}
|
|
6318
|
+
function videoFromVertex$1(apiClient, fromObject) {
|
|
6319
|
+
const toObject = {};
|
|
6320
|
+
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
6321
|
+
if (fromUri != null) {
|
|
6322
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
6323
|
+
}
|
|
6324
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
6325
|
+
'bytesBase64Encoded',
|
|
6326
|
+
]);
|
|
6327
|
+
if (fromVideoBytes != null) {
|
|
6328
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
6329
|
+
}
|
|
6330
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
6331
|
+
if (fromMimeType != null) {
|
|
6332
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
6333
|
+
}
|
|
6334
|
+
return toObject;
|
|
6335
|
+
}
|
|
6336
|
+
function generatedVideoFromVertex$1(apiClient, fromObject) {
|
|
6337
|
+
const toObject = {};
|
|
6338
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
6339
|
+
if (fromVideo != null) {
|
|
6340
|
+
setValueByPath(toObject, ['video'], videoFromVertex$1(apiClient, fromVideo));
|
|
6341
|
+
}
|
|
6342
|
+
return toObject;
|
|
6343
|
+
}
|
|
6344
|
+
function generateVideosResponseFromVertex$1(apiClient, fromObject) {
|
|
6345
|
+
const toObject = {};
|
|
6346
|
+
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
6347
|
+
if (fromGeneratedVideos != null) {
|
|
6348
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
6349
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
6350
|
+
return generatedVideoFromVertex$1(apiClient, item);
|
|
6351
|
+
}));
|
|
6352
|
+
}
|
|
6353
|
+
else {
|
|
6354
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
6355
|
+
}
|
|
6356
|
+
}
|
|
6357
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
6358
|
+
'raiMediaFilteredCount',
|
|
6359
|
+
]);
|
|
6360
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
6361
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
6362
|
+
}
|
|
6363
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
6364
|
+
'raiMediaFilteredReasons',
|
|
6365
|
+
]);
|
|
6366
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
6367
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
6368
|
+
}
|
|
6369
|
+
return toObject;
|
|
6370
|
+
}
|
|
6371
|
+
function generateVideosOperationFromVertex$1(apiClient, fromObject) {
|
|
6372
|
+
const toObject = {};
|
|
6373
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
6374
|
+
if (fromName != null) {
|
|
6375
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
6376
|
+
}
|
|
6377
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
6378
|
+
if (fromMetadata != null) {
|
|
6379
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
6380
|
+
}
|
|
6381
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
6382
|
+
if (fromDone != null) {
|
|
6383
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
6384
|
+
}
|
|
6385
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
6386
|
+
if (fromError != null) {
|
|
6387
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
6388
|
+
}
|
|
6389
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6390
|
+
if (fromResponse != null) {
|
|
6391
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(apiClient, fromResponse));
|
|
6392
|
+
}
|
|
6393
|
+
const fromResult = getValueByPath(fromObject, ['response']);
|
|
6394
|
+
if (fromResult != null) {
|
|
6395
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromVertex$1(apiClient, fromResult));
|
|
6396
|
+
}
|
|
6397
|
+
return toObject;
|
|
6398
|
+
}
|
|
5781
6399
|
|
|
5782
6400
|
/**
|
|
5783
6401
|
* @license
|
|
@@ -5836,6 +6454,23 @@ function liveServerMessageFromMldev(apiClient, fromObject) {
|
|
|
5836
6454
|
fromToolCallCancellation !== null) {
|
|
5837
6455
|
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromMldev(apiClient, fromToolCallCancellation));
|
|
5838
6456
|
}
|
|
6457
|
+
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
6458
|
+
'usageMetadata',
|
|
6459
|
+
]);
|
|
6460
|
+
if (fromUsageMetadata != undefined && fromUsageMetadata != null) {
|
|
6461
|
+
setValueByPath(toObject, ['usageMetadata'], usageMetadataFromMldev(apiClient, fromUsageMetadata));
|
|
6462
|
+
}
|
|
6463
|
+
const fromGoAway = getValueByPath(fromObject, ['goAway']);
|
|
6464
|
+
if (fromGoAway !== undefined && fromGoAway !== null) {
|
|
6465
|
+
setValueByPath(toObject, ['goAway'], liveServerGoAwayFromMldev(fromGoAway));
|
|
6466
|
+
}
|
|
6467
|
+
const fromSessionResumptionUpdate = getValueByPath(fromObject, [
|
|
6468
|
+
'sessionResumptionUpdate',
|
|
6469
|
+
]);
|
|
6470
|
+
if (fromSessionResumptionUpdate !== undefined &&
|
|
6471
|
+
fromSessionResumptionUpdate !== null) {
|
|
6472
|
+
setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromMldev(fromSessionResumptionUpdate));
|
|
6473
|
+
}
|
|
5839
6474
|
return toObject;
|
|
5840
6475
|
}
|
|
5841
6476
|
function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
@@ -5863,6 +6498,181 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
|
5863
6498
|
fromToolCallCancellation !== null) {
|
|
5864
6499
|
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromVertex(apiClient, fromToolCallCancellation));
|
|
5865
6500
|
}
|
|
6501
|
+
const fromGoAway = getValueByPath(fromObject, ['goAway']);
|
|
6502
|
+
if (fromGoAway !== undefined && fromGoAway !== null) {
|
|
6503
|
+
setValueByPath(toObject, ['goAway'], liveServerGoAwayFromVertex(fromGoAway));
|
|
6504
|
+
}
|
|
6505
|
+
const fromSessionResumptionUpdate = getValueByPath(fromObject, [
|
|
6506
|
+
'sessionResumptionUpdate',
|
|
6507
|
+
]);
|
|
6508
|
+
if (fromSessionResumptionUpdate !== undefined &&
|
|
6509
|
+
fromSessionResumptionUpdate !== null) {
|
|
6510
|
+
setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromVertex(fromSessionResumptionUpdate));
|
|
6511
|
+
}
|
|
6512
|
+
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
6513
|
+
'usageMetadata',
|
|
6514
|
+
]);
|
|
6515
|
+
if (fromUsageMetadata != undefined && fromUsageMetadata != null) {
|
|
6516
|
+
setValueByPath(toObject, ['usageMetadata'], usageMetadataFromVertex(apiClient, fromUsageMetadata));
|
|
6517
|
+
}
|
|
6518
|
+
return toObject;
|
|
6519
|
+
}
|
|
6520
|
+
function slidingWindowToMldev(fromObject) {
|
|
6521
|
+
const toObject = {};
|
|
6522
|
+
const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
|
|
6523
|
+
if (fromTargetTokens !== undefined && fromTargetTokens !== null) {
|
|
6524
|
+
setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
|
|
6525
|
+
}
|
|
6526
|
+
return toObject;
|
|
6527
|
+
}
|
|
6528
|
+
function slidingWindowToVertex(fromObject) {
|
|
6529
|
+
const toObject = {};
|
|
6530
|
+
const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
|
|
6531
|
+
if (fromTargetTokens !== undefined && fromTargetTokens !== null) {
|
|
6532
|
+
setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
|
|
6533
|
+
}
|
|
6534
|
+
return toObject;
|
|
6535
|
+
}
|
|
6536
|
+
function contextWindowCompressionToMldev(fromObject) {
|
|
6537
|
+
const toObject = {};
|
|
6538
|
+
const fromTriggerTokens = getValueByPath(fromObject, [
|
|
6539
|
+
'triggerTokens',
|
|
6540
|
+
]);
|
|
6541
|
+
if (fromTriggerTokens !== undefined && fromTriggerTokens !== null) {
|
|
6542
|
+
setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
|
|
6543
|
+
}
|
|
6544
|
+
const fromSlidingWindow = getValueByPath(fromObject, [
|
|
6545
|
+
'slidingWindow',
|
|
6546
|
+
]);
|
|
6547
|
+
if (fromSlidingWindow !== undefined && fromSlidingWindow !== null) {
|
|
6548
|
+
setValueByPath(toObject, ['slidingWindow'], slidingWindowToMldev(fromSlidingWindow));
|
|
6549
|
+
}
|
|
6550
|
+
return toObject;
|
|
6551
|
+
}
|
|
6552
|
+
function contextWindowCompressionToVertex(fromObject) {
|
|
6553
|
+
const toObject = {};
|
|
6554
|
+
const fromTriggerTokens = getValueByPath(fromObject, [
|
|
6555
|
+
'triggerTokens',
|
|
6556
|
+
]);
|
|
6557
|
+
if (fromTriggerTokens !== undefined && fromTriggerTokens !== null) {
|
|
6558
|
+
setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
|
|
6559
|
+
}
|
|
6560
|
+
const fromSlidingWindow = getValueByPath(fromObject, [
|
|
6561
|
+
'slidingWindow',
|
|
6562
|
+
]);
|
|
6563
|
+
if (fromSlidingWindow !== undefined && fromSlidingWindow !== null) {
|
|
6564
|
+
setValueByPath(toObject, ['slidingWindow'], slidingWindowToVertex(fromSlidingWindow));
|
|
6565
|
+
}
|
|
6566
|
+
return toObject;
|
|
6567
|
+
}
|
|
6568
|
+
function automaticActivityDetectionToMldev(fromObject) {
|
|
6569
|
+
const toObject = {};
|
|
6570
|
+
const fromDisabled = getValueByPath(fromObject, ['disabled']);
|
|
6571
|
+
if (fromDisabled !== undefined && fromDisabled !== null) {
|
|
6572
|
+
setValueByPath(toObject, ['disabled'], fromDisabled);
|
|
6573
|
+
}
|
|
6574
|
+
const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6575
|
+
'startOfSpeechSensitivity',
|
|
6576
|
+
]);
|
|
6577
|
+
if (fromStartOfSpeechSensitivity !== undefined &&
|
|
6578
|
+
fromStartOfSpeechSensitivity !== null) {
|
|
6579
|
+
setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
|
|
6580
|
+
}
|
|
6581
|
+
const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6582
|
+
'endOfSpeechSensitivity',
|
|
6583
|
+
]);
|
|
6584
|
+
if (fromEndOfSpeechSensitivity !== undefined &&
|
|
6585
|
+
fromEndOfSpeechSensitivity !== null) {
|
|
6586
|
+
setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
|
|
6587
|
+
}
|
|
6588
|
+
const fromPrefixPaddingMs = getValueByPath(fromObject, [
|
|
6589
|
+
'prefixPaddingMs',
|
|
6590
|
+
]);
|
|
6591
|
+
if (fromPrefixPaddingMs !== undefined && fromPrefixPaddingMs !== null) {
|
|
6592
|
+
setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
|
|
6593
|
+
}
|
|
6594
|
+
const fromSilenceDurationMs = getValueByPath(fromObject, [
|
|
6595
|
+
'silenceDurationMs',
|
|
6596
|
+
]);
|
|
6597
|
+
if (fromSilenceDurationMs !== undefined && fromSilenceDurationMs !== null) {
|
|
6598
|
+
setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
|
|
6599
|
+
}
|
|
6600
|
+
return toObject;
|
|
6601
|
+
}
|
|
6602
|
+
function automaticActivityDetectionToVertex(fromObject) {
|
|
6603
|
+
const toObject = {};
|
|
6604
|
+
const fromDisabled = getValueByPath(fromObject, ['disabled']);
|
|
6605
|
+
if (fromDisabled !== undefined && fromDisabled !== null) {
|
|
6606
|
+
setValueByPath(toObject, ['disabled'], fromDisabled);
|
|
6607
|
+
}
|
|
6608
|
+
const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6609
|
+
'startOfSpeechSensitivity',
|
|
6610
|
+
]);
|
|
6611
|
+
if (fromStartOfSpeechSensitivity !== undefined &&
|
|
6612
|
+
fromStartOfSpeechSensitivity !== null) {
|
|
6613
|
+
setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
|
|
6614
|
+
}
|
|
6615
|
+
const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6616
|
+
'endOfSpeechSensitivity',
|
|
6617
|
+
]);
|
|
6618
|
+
if (fromEndOfSpeechSensitivity !== undefined &&
|
|
6619
|
+
fromEndOfSpeechSensitivity !== null) {
|
|
6620
|
+
setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
|
|
6621
|
+
}
|
|
6622
|
+
const fromPrefixPaddingMs = getValueByPath(fromObject, [
|
|
6623
|
+
'prefixPaddingMs',
|
|
6624
|
+
]);
|
|
6625
|
+
if (fromPrefixPaddingMs !== undefined && fromPrefixPaddingMs !== null) {
|
|
6626
|
+
setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
|
|
6627
|
+
}
|
|
6628
|
+
const fromSilenceDurationMs = getValueByPath(fromObject, [
|
|
6629
|
+
'silenceDurationMs',
|
|
6630
|
+
]);
|
|
6631
|
+
if (fromSilenceDurationMs !== undefined && fromSilenceDurationMs !== null) {
|
|
6632
|
+
setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
|
|
6633
|
+
}
|
|
6634
|
+
return toObject;
|
|
6635
|
+
}
|
|
6636
|
+
function realtimeInputConfigToMldev(fromObject) {
|
|
6637
|
+
const toObject = {};
|
|
6638
|
+
const fromAutomaticActivityDetection = getValueByPath(fromObject, [
|
|
6639
|
+
'automaticActivityDetection',
|
|
6640
|
+
]);
|
|
6641
|
+
if (fromAutomaticActivityDetection !== undefined &&
|
|
6642
|
+
fromAutomaticActivityDetection !== null) {
|
|
6643
|
+
setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToMldev(fromAutomaticActivityDetection));
|
|
6644
|
+
}
|
|
6645
|
+
const fromActivityHandling = getValueByPath(fromObject, [
|
|
6646
|
+
'activityHandling',
|
|
6647
|
+
]);
|
|
6648
|
+
if (fromActivityHandling !== undefined && fromActivityHandling !== null) {
|
|
6649
|
+
setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
|
|
6650
|
+
}
|
|
6651
|
+
const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
|
|
6652
|
+
if (fromTurnCoverage !== undefined && fromTurnCoverage !== null) {
|
|
6653
|
+
setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
|
|
6654
|
+
}
|
|
6655
|
+
return toObject;
|
|
6656
|
+
}
|
|
6657
|
+
function realtimeInputConfigToVertex(fromObject) {
|
|
6658
|
+
const toObject = {};
|
|
6659
|
+
const fromAutomaticActivityDetection = getValueByPath(fromObject, [
|
|
6660
|
+
'automaticActivityDetection',
|
|
6661
|
+
]);
|
|
6662
|
+
if (fromAutomaticActivityDetection !== undefined &&
|
|
6663
|
+
fromAutomaticActivityDetection !== null) {
|
|
6664
|
+
setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToVertex(fromAutomaticActivityDetection));
|
|
6665
|
+
}
|
|
6666
|
+
const fromActivityHandling = getValueByPath(fromObject, [
|
|
6667
|
+
'activityHandling',
|
|
6668
|
+
]);
|
|
6669
|
+
if (fromActivityHandling !== undefined && fromActivityHandling !== null) {
|
|
6670
|
+
setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
|
|
6671
|
+
}
|
|
6672
|
+
const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
|
|
6673
|
+
if (fromTurnCoverage !== undefined && fromTurnCoverage !== null) {
|
|
6674
|
+
setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
|
|
6675
|
+
}
|
|
5866
6676
|
return toObject;
|
|
5867
6677
|
}
|
|
5868
6678
|
function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
@@ -5897,6 +6707,26 @@ function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
|
5897
6707
|
return toolToMldev(apiClient, item);
|
|
5898
6708
|
}));
|
|
5899
6709
|
}
|
|
6710
|
+
const fromSessionResumption = getValueByPath(fromObject, [
|
|
6711
|
+
'sessionResumption',
|
|
6712
|
+
]);
|
|
6713
|
+
if (fromSessionResumption !== undefined && fromSessionResumption !== null) {
|
|
6714
|
+
setValueByPath(toObject, ['sessionResumption'], liveClientSessionResumptionConfigToMldev(fromSessionResumption));
|
|
6715
|
+
}
|
|
6716
|
+
const fromContextWindowCompression = getValueByPath(fromObject, [
|
|
6717
|
+
'contextWindowCompression',
|
|
6718
|
+
]);
|
|
6719
|
+
if (fromContextWindowCompression !== undefined &&
|
|
6720
|
+
fromContextWindowCompression !== null) {
|
|
6721
|
+
setValueByPath(toObject, ['contextWindowCompression'], contextWindowCompressionToMldev(fromContextWindowCompression));
|
|
6722
|
+
}
|
|
6723
|
+
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
6724
|
+
'realtimeInputConfig',
|
|
6725
|
+
]);
|
|
6726
|
+
if (fromRealtimeInputConfig !== undefined &&
|
|
6727
|
+
fromRealtimeInputConfig !== null) {
|
|
6728
|
+
setValueByPath(toObject, ['realtimeInputConfig'], realtimeInputConfigToMldev(fromRealtimeInputConfig));
|
|
6729
|
+
}
|
|
5900
6730
|
return toObject;
|
|
5901
6731
|
}
|
|
5902
6732
|
function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
@@ -5935,6 +6765,26 @@ function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
|
5935
6765
|
return toolToVertex(apiClient, item);
|
|
5936
6766
|
}));
|
|
5937
6767
|
}
|
|
6768
|
+
const fromSessionResumption = getValueByPath(fromObject, [
|
|
6769
|
+
'sessionResumption',
|
|
6770
|
+
]);
|
|
6771
|
+
if (fromSessionResumption !== undefined && fromSessionResumption !== null) {
|
|
6772
|
+
setValueByPath(toObject, ['sessionResumption'], liveClientSessionResumptionConfigToVertex(fromSessionResumption));
|
|
6773
|
+
}
|
|
6774
|
+
const fromContextWindowCompression = getValueByPath(fromObject, [
|
|
6775
|
+
'contextWindowCompression',
|
|
6776
|
+
]);
|
|
6777
|
+
if (fromContextWindowCompression !== undefined &&
|
|
6778
|
+
fromContextWindowCompression !== null) {
|
|
6779
|
+
setValueByPath(toObject, ['contextWindowCompression'], contextWindowCompressionToVertex(fromContextWindowCompression));
|
|
6780
|
+
}
|
|
6781
|
+
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
6782
|
+
'realtimeInputConfig',
|
|
6783
|
+
]);
|
|
6784
|
+
if (fromRealtimeInputConfig !== undefined &&
|
|
6785
|
+
fromRealtimeInputConfig !== null) {
|
|
6786
|
+
setValueByPath(toObject, ['realtimeInputConfig'], realtimeInputConfigToVertex(fromRealtimeInputConfig));
|
|
6787
|
+
}
|
|
5938
6788
|
return toObject;
|
|
5939
6789
|
}
|
|
5940
6790
|
function liveServerContentFromMldev(apiClient, fromObject) {
|
|
@@ -5951,6 +6801,12 @@ function liveServerContentFromMldev(apiClient, fromObject) {
|
|
|
5951
6801
|
if (fromInterrupted !== undefined) {
|
|
5952
6802
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
5953
6803
|
}
|
|
6804
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
6805
|
+
'generationComplete',
|
|
6806
|
+
]);
|
|
6807
|
+
if (fromGenerationComplete != null) {
|
|
6808
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
6809
|
+
}
|
|
5954
6810
|
return toObject;
|
|
5955
6811
|
}
|
|
5956
6812
|
function liveServerContentFromVertex(apiClient, fromObject) {
|
|
@@ -5967,6 +6823,12 @@ function liveServerContentFromVertex(apiClient, fromObject) {
|
|
|
5967
6823
|
if (fromInterrupted !== undefined) {
|
|
5968
6824
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
5969
6825
|
}
|
|
6826
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
6827
|
+
'generationComplete',
|
|
6828
|
+
]);
|
|
6829
|
+
if (fromGenerationComplete != null) {
|
|
6830
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
6831
|
+
}
|
|
5970
6832
|
return toObject;
|
|
5971
6833
|
}
|
|
5972
6834
|
function functionCallFromMldev(apiClient, fromObject) {
|
|
@@ -6041,28 +6903,315 @@ function liveServerToolCallCancellationFromVertex(apiClient, fromObject) {
|
|
|
6041
6903
|
}
|
|
6042
6904
|
return toObject;
|
|
6043
6905
|
}
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6906
|
+
function liveServerGoAwayFromMldev(fromObject) {
|
|
6907
|
+
const toObject = {};
|
|
6908
|
+
const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
|
|
6909
|
+
if (fromTimeLeft !== undefined) {
|
|
6910
|
+
setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
|
|
6911
|
+
}
|
|
6912
|
+
return toObject;
|
|
6913
|
+
}
|
|
6914
|
+
function liveServerGoAwayFromVertex(fromObject) {
|
|
6915
|
+
const toObject = {};
|
|
6916
|
+
const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
|
|
6917
|
+
if (fromTimeLeft !== undefined) {
|
|
6918
|
+
setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
|
|
6919
|
+
}
|
|
6920
|
+
return toObject;
|
|
6921
|
+
}
|
|
6922
|
+
function liveServerSessionResumptionUpdateFromMldev(fromObject) {
|
|
6923
|
+
const toObject = {};
|
|
6924
|
+
const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
|
|
6925
|
+
if (fromNewHandle !== undefined) {
|
|
6926
|
+
setValueByPath(toObject, ['newHandle'], fromNewHandle);
|
|
6927
|
+
}
|
|
6928
|
+
const fromResumable = getValueByPath(fromObject, ['resumable']);
|
|
6929
|
+
if (fromResumable !== undefined) {
|
|
6930
|
+
setValueByPath(toObject, ['resumable'], fromResumable);
|
|
6931
|
+
}
|
|
6932
|
+
const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
|
|
6933
|
+
'lastConsumedClientMessageIndex',
|
|
6934
|
+
]);
|
|
6935
|
+
if (fromLastConsumedClientMessageIndex !== undefined) {
|
|
6936
|
+
setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
|
|
6937
|
+
}
|
|
6938
|
+
return toObject;
|
|
6939
|
+
}
|
|
6940
|
+
function liveServerSessionResumptionUpdateFromVertex(fromObject) {
|
|
6941
|
+
const toObject = {};
|
|
6942
|
+
const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
|
|
6943
|
+
if (fromNewHandle !== undefined) {
|
|
6944
|
+
setValueByPath(toObject, ['newHandle'], fromNewHandle);
|
|
6945
|
+
}
|
|
6946
|
+
const fromResumable = getValueByPath(fromObject, ['resumable']);
|
|
6947
|
+
if (fromResumable !== undefined) {
|
|
6948
|
+
setValueByPath(toObject, ['resumable'], fromResumable);
|
|
6949
|
+
}
|
|
6950
|
+
const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
|
|
6951
|
+
'lastConsumedClientMessageIndex',
|
|
6952
|
+
]);
|
|
6953
|
+
if (fromLastConsumedClientMessageIndex !== undefined) {
|
|
6954
|
+
setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
|
|
6955
|
+
}
|
|
6956
|
+
return toObject;
|
|
6957
|
+
}
|
|
6958
|
+
function liveClientSessionResumptionConfigToMldev(fromObject) {
|
|
6959
|
+
const toObject = {};
|
|
6960
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
6961
|
+
if (fromHandle !== undefined) {
|
|
6962
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
6963
|
+
}
|
|
6964
|
+
if (getValueByPath(fromObject, ['transparent']) !== undefined) {
|
|
6965
|
+
throw new Error('transparent parameter is not supported in Gemini API.');
|
|
6966
|
+
}
|
|
6967
|
+
return toObject;
|
|
6968
|
+
}
|
|
6969
|
+
function liveClientSessionResumptionConfigToVertex(fromObject) {
|
|
6970
|
+
const toObject = {};
|
|
6971
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
6972
|
+
if (fromHandle !== undefined) {
|
|
6973
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
6974
|
+
}
|
|
6975
|
+
const fromTransparent = getValueByPath(fromObject, ['transparent']);
|
|
6976
|
+
if (fromTransparent !== undefined) {
|
|
6977
|
+
setValueByPath(toObject, ['transparent'], fromTransparent);
|
|
6978
|
+
}
|
|
6979
|
+
return toObject;
|
|
6980
|
+
}
|
|
6981
|
+
function modalityTokenCountFromMldev(apiClient, fromObject) {
|
|
6982
|
+
const toObject = {};
|
|
6983
|
+
const fromModality = getValueByPath(fromObject, ['modality']);
|
|
6984
|
+
if (fromModality != null) {
|
|
6985
|
+
setValueByPath(toObject, ['modality'], fromModality);
|
|
6986
|
+
}
|
|
6987
|
+
const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
|
|
6988
|
+
if (fromTokenCount != null) {
|
|
6989
|
+
setValueByPath(toObject, ['tokenCount'], fromTokenCount);
|
|
6990
|
+
}
|
|
6991
|
+
return toObject;
|
|
6992
|
+
}
|
|
6993
|
+
function usageMetadataFromMldev(apiClient, fromObject) {
|
|
6994
|
+
const toObject = {};
|
|
6995
|
+
const fromPromptTokenCount = getValueByPath(fromObject, [
|
|
6996
|
+
'promptTokenCount',
|
|
6997
|
+
]);
|
|
6998
|
+
if (fromPromptTokenCount != null) {
|
|
6999
|
+
setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
|
|
7000
|
+
}
|
|
7001
|
+
const fromCachedContentTokenCount = getValueByPath(fromObject, [
|
|
7002
|
+
'cachedContentTokenCount',
|
|
7003
|
+
]);
|
|
7004
|
+
if (fromCachedContentTokenCount != null) {
|
|
7005
|
+
setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
|
|
7006
|
+
}
|
|
7007
|
+
const fromResponseTokenCount = getValueByPath(fromObject, [
|
|
7008
|
+
'responseTokenCount',
|
|
7009
|
+
]);
|
|
7010
|
+
if (fromResponseTokenCount != null) {
|
|
7011
|
+
setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
|
|
7012
|
+
}
|
|
7013
|
+
const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
|
|
7014
|
+
'toolUsePromptTokenCount',
|
|
7015
|
+
]);
|
|
7016
|
+
if (fromToolUsePromptTokenCount != null) {
|
|
7017
|
+
setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
|
|
7018
|
+
}
|
|
7019
|
+
const fromThoughtsTokenCount = getValueByPath(fromObject, [
|
|
7020
|
+
'thoughtsTokenCount',
|
|
7021
|
+
]);
|
|
7022
|
+
if (fromThoughtsTokenCount != null) {
|
|
7023
|
+
setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
|
|
7024
|
+
}
|
|
7025
|
+
const fromTotalTokenCount = getValueByPath(fromObject, [
|
|
7026
|
+
'totalTokenCount',
|
|
7027
|
+
]);
|
|
7028
|
+
if (fromTotalTokenCount != null) {
|
|
7029
|
+
setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
|
|
7030
|
+
}
|
|
7031
|
+
const fromPromptTokensDetails = getValueByPath(fromObject, [
|
|
7032
|
+
'promptTokensDetails',
|
|
7033
|
+
]);
|
|
7034
|
+
if (fromPromptTokensDetails != null) {
|
|
7035
|
+
if (Array.isArray(fromPromptTokensDetails)) {
|
|
7036
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
|
|
7037
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7038
|
+
}));
|
|
7039
|
+
}
|
|
7040
|
+
else {
|
|
7041
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
7042
|
+
}
|
|
7043
|
+
}
|
|
7044
|
+
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
7045
|
+
'cacheTokensDetails',
|
|
7046
|
+
]);
|
|
7047
|
+
if (fromCacheTokensDetails != null) {
|
|
7048
|
+
if (Array.isArray(fromCacheTokensDetails)) {
|
|
7049
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
|
|
7050
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7051
|
+
}));
|
|
7052
|
+
}
|
|
7053
|
+
else {
|
|
7054
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
7058
|
+
'responseTokensDetails',
|
|
7059
|
+
]);
|
|
7060
|
+
if (fromResponseTokensDetails != null) {
|
|
7061
|
+
if (Array.isArray(fromResponseTokensDetails)) {
|
|
7062
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
|
|
7063
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7064
|
+
}));
|
|
7065
|
+
}
|
|
7066
|
+
else {
|
|
7067
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
7071
|
+
'toolUsePromptTokensDetails',
|
|
7072
|
+
]);
|
|
7073
|
+
if (fromToolUsePromptTokensDetails != null) {
|
|
7074
|
+
if (Array.isArray(fromToolUsePromptTokensDetails)) {
|
|
7075
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
|
|
7076
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7077
|
+
}));
|
|
7078
|
+
}
|
|
7079
|
+
else {
|
|
7080
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
7081
|
+
}
|
|
7082
|
+
}
|
|
7083
|
+
return toObject;
|
|
7084
|
+
}
|
|
7085
|
+
function modalityTokenCountFromVertex(apiClient, fromObject) {
|
|
7086
|
+
const toObject = {};
|
|
7087
|
+
const fromModality = getValueByPath(fromObject, ['modality']);
|
|
7088
|
+
if (fromModality != null) {
|
|
7089
|
+
setValueByPath(toObject, ['modality'], fromModality);
|
|
7090
|
+
}
|
|
7091
|
+
const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
|
|
7092
|
+
if (fromTokenCount != null) {
|
|
7093
|
+
setValueByPath(toObject, ['tokenCount'], fromTokenCount);
|
|
7094
|
+
}
|
|
7095
|
+
return toObject;
|
|
7096
|
+
}
|
|
7097
|
+
function usageMetadataFromVertex(apiClient, fromObject) {
|
|
7098
|
+
const toObject = {};
|
|
7099
|
+
const fromPromptTokenCount = getValueByPath(fromObject, [
|
|
7100
|
+
'promptTokenCount',
|
|
7101
|
+
]);
|
|
7102
|
+
if (fromPromptTokenCount != null) {
|
|
7103
|
+
setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
|
|
7104
|
+
}
|
|
7105
|
+
const fromCachedContentTokenCount = getValueByPath(fromObject, [
|
|
7106
|
+
'cachedContentTokenCount',
|
|
7107
|
+
]);
|
|
7108
|
+
if (fromCachedContentTokenCount != null) {
|
|
7109
|
+
setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
|
|
7110
|
+
}
|
|
7111
|
+
const fromResponseTokenCount = getValueByPath(fromObject, [
|
|
7112
|
+
'candidatesTokenCount',
|
|
7113
|
+
]);
|
|
7114
|
+
if (fromResponseTokenCount != null) {
|
|
7115
|
+
setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
|
|
7116
|
+
}
|
|
7117
|
+
const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
|
|
7118
|
+
'toolUsePromptTokenCount',
|
|
7119
|
+
]);
|
|
7120
|
+
if (fromToolUsePromptTokenCount != null) {
|
|
7121
|
+
setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
|
|
7122
|
+
}
|
|
7123
|
+
const fromThoughtsTokenCount = getValueByPath(fromObject, [
|
|
7124
|
+
'thoughtsTokenCount',
|
|
7125
|
+
]);
|
|
7126
|
+
if (fromThoughtsTokenCount != null) {
|
|
7127
|
+
setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
|
|
7128
|
+
}
|
|
7129
|
+
const fromTotalTokenCount = getValueByPath(fromObject, [
|
|
7130
|
+
'totalTokenCount',
|
|
7131
|
+
]);
|
|
7132
|
+
if (fromTotalTokenCount != null) {
|
|
7133
|
+
setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
|
|
7134
|
+
}
|
|
7135
|
+
const fromPromptTokensDetails = getValueByPath(fromObject, [
|
|
7136
|
+
'promptTokensDetails',
|
|
7137
|
+
]);
|
|
7138
|
+
if (fromPromptTokensDetails != null) {
|
|
7139
|
+
if (Array.isArray(fromPromptTokensDetails)) {
|
|
7140
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
|
|
7141
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7142
|
+
}));
|
|
7143
|
+
}
|
|
7144
|
+
else {
|
|
7145
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
7146
|
+
}
|
|
7147
|
+
}
|
|
7148
|
+
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
7149
|
+
'cacheTokensDetails',
|
|
7150
|
+
]);
|
|
7151
|
+
if (fromCacheTokensDetails != null) {
|
|
7152
|
+
if (Array.isArray(fromCacheTokensDetails)) {
|
|
7153
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
|
|
7154
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7155
|
+
}));
|
|
7156
|
+
}
|
|
7157
|
+
else {
|
|
7158
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
7159
|
+
}
|
|
7160
|
+
}
|
|
7161
|
+
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
7162
|
+
'toolUsePromptTokensDetails',
|
|
7163
|
+
]);
|
|
7164
|
+
if (fromToolUsePromptTokensDetails != null) {
|
|
7165
|
+
if (Array.isArray(fromToolUsePromptTokensDetails)) {
|
|
7166
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
|
|
7167
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7168
|
+
}));
|
|
7169
|
+
}
|
|
7170
|
+
else {
|
|
7171
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
7172
|
+
}
|
|
7173
|
+
}
|
|
7174
|
+
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
7175
|
+
'candidatesTokensDetails',
|
|
7176
|
+
]);
|
|
7177
|
+
if (fromResponseTokensDetails != null) {
|
|
7178
|
+
if (Array.isArray(fromResponseTokensDetails)) {
|
|
7179
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
|
|
7180
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7181
|
+
}));
|
|
7182
|
+
}
|
|
7183
|
+
else {
|
|
7184
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
7187
|
+
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
7188
|
+
if (fromTrafficType != null) {
|
|
7189
|
+
setValueByPath(toObject, ['trafficType'], fromTrafficType);
|
|
7190
|
+
}
|
|
7191
|
+
return toObject;
|
|
7192
|
+
}
|
|
7193
|
+
|
|
7194
|
+
/**
|
|
7195
|
+
* @license
|
|
7196
|
+
* Copyright 2025 Google LLC
|
|
7197
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7198
|
+
*/
|
|
7199
|
+
const FUNCTION_RESPONSE_REQUIRES_ID = 'FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.';
|
|
7200
|
+
/**
|
|
7201
|
+
* Handles incoming messages from the WebSocket.
|
|
7202
|
+
*
|
|
7203
|
+
* @remarks
|
|
7204
|
+
* This function is responsible for parsing incoming messages, transforming them
|
|
7205
|
+
* into LiveServerMessages, and then calling the onmessage callback. Note that
|
|
7206
|
+
* the first message which is received from the server is a setupComplete
|
|
7207
|
+
* message.
|
|
7208
|
+
*
|
|
7209
|
+
* @param apiClient The ApiClient instance.
|
|
7210
|
+
* @param onmessage The user-provided onmessage callback (if any).
|
|
7211
|
+
* @param event The MessageEvent from the WebSocket.
|
|
7212
|
+
*/
|
|
7213
|
+
async function handleWebSocketMessage(apiClient, onmessage, event) {
|
|
7214
|
+
let serverMessage;
|
|
6066
7215
|
let data;
|
|
6067
7216
|
if (event.data instanceof Blob) {
|
|
6068
7217
|
data = JSON.parse(await event.data.text());
|
|
@@ -6233,7 +7382,13 @@ class Session {
|
|
|
6233
7382
|
throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
|
|
6234
7383
|
}
|
|
6235
7384
|
// LiveClientRealtimeInput
|
|
6236
|
-
clientMessage = {
|
|
7385
|
+
clientMessage = {
|
|
7386
|
+
realtimeInput: {
|
|
7387
|
+
mediaChunks: [params.media],
|
|
7388
|
+
activityStart: params.activityStart,
|
|
7389
|
+
activityEnd: params.activityEnd,
|
|
7390
|
+
},
|
|
7391
|
+
};
|
|
6237
7392
|
return clientMessage;
|
|
6238
7393
|
}
|
|
6239
7394
|
tLiveClienttToolResponse(apiClient, params) {
|
|
@@ -6244,6 +7399,9 @@ class Session {
|
|
|
6244
7399
|
if (!Array.isArray(params.functionResponses)) {
|
|
6245
7400
|
functionResponses = [params.functionResponses];
|
|
6246
7401
|
}
|
|
7402
|
+
else {
|
|
7403
|
+
functionResponses = params.functionResponses;
|
|
7404
|
+
}
|
|
6247
7405
|
if (functionResponses.length === 0) {
|
|
6248
7406
|
throw new Error('functionResponses is required.');
|
|
6249
7407
|
}
|
|
@@ -6849,6 +8007,66 @@ class Models extends BaseModule {
|
|
|
6849
8007
|
});
|
|
6850
8008
|
}
|
|
6851
8009
|
}
|
|
8010
|
+
/**
|
|
8011
|
+
* Fetches information about a model by name.
|
|
8012
|
+
*
|
|
8013
|
+
* @example
|
|
8014
|
+
* ```ts
|
|
8015
|
+
* const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
|
|
8016
|
+
* ```
|
|
8017
|
+
*/
|
|
8018
|
+
async get(params) {
|
|
8019
|
+
var _a, _b;
|
|
8020
|
+
let response;
|
|
8021
|
+
let path = '';
|
|
8022
|
+
let queryParams = {};
|
|
8023
|
+
if (this.apiClient.isVertexAI()) {
|
|
8024
|
+
const body = getModelParametersToVertex(this.apiClient, params);
|
|
8025
|
+
path = formatMap('{name}', body['_url']);
|
|
8026
|
+
queryParams = body['_query'];
|
|
8027
|
+
delete body['config'];
|
|
8028
|
+
delete body['_url'];
|
|
8029
|
+
delete body['_query'];
|
|
8030
|
+
response = this.apiClient
|
|
8031
|
+
.request({
|
|
8032
|
+
path: path,
|
|
8033
|
+
queryParams: queryParams,
|
|
8034
|
+
body: JSON.stringify(body),
|
|
8035
|
+
httpMethod: 'GET',
|
|
8036
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8037
|
+
})
|
|
8038
|
+
.then((httpResponse) => {
|
|
8039
|
+
return httpResponse.json();
|
|
8040
|
+
});
|
|
8041
|
+
return response.then((apiResponse) => {
|
|
8042
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
8043
|
+
return resp;
|
|
8044
|
+
});
|
|
8045
|
+
}
|
|
8046
|
+
else {
|
|
8047
|
+
const body = getModelParametersToMldev(this.apiClient, params);
|
|
8048
|
+
path = formatMap('{name}', body['_url']);
|
|
8049
|
+
queryParams = body['_query'];
|
|
8050
|
+
delete body['config'];
|
|
8051
|
+
delete body['_url'];
|
|
8052
|
+
delete body['_query'];
|
|
8053
|
+
response = this.apiClient
|
|
8054
|
+
.request({
|
|
8055
|
+
path: path,
|
|
8056
|
+
queryParams: queryParams,
|
|
8057
|
+
body: JSON.stringify(body),
|
|
8058
|
+
httpMethod: 'GET',
|
|
8059
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
8060
|
+
})
|
|
8061
|
+
.then((httpResponse) => {
|
|
8062
|
+
return httpResponse.json();
|
|
8063
|
+
});
|
|
8064
|
+
return response.then((apiResponse) => {
|
|
8065
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8066
|
+
return resp;
|
|
8067
|
+
});
|
|
8068
|
+
}
|
|
8069
|
+
}
|
|
6852
8070
|
/**
|
|
6853
8071
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
6854
8072
|
* supported for Gemini models.
|
|
@@ -6973,6 +8191,431 @@ class Models extends BaseModule {
|
|
|
6973
8191
|
throw new Error('This method is only supported by the Vertex AI.');
|
|
6974
8192
|
}
|
|
6975
8193
|
}
|
|
8194
|
+
/**
|
|
8195
|
+
* Generates videos based on a text description and configuration.
|
|
8196
|
+
*
|
|
8197
|
+
* @param params - The parameters for generating videos.
|
|
8198
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
8199
|
+
*
|
|
8200
|
+
* @example
|
|
8201
|
+
* ```ts
|
|
8202
|
+
* const operation = await ai.models.generateVideos({
|
|
8203
|
+
* model: 'veo-2.0-generate-001',
|
|
8204
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
8205
|
+
* config: {
|
|
8206
|
+
* numberOfVideos: 1
|
|
8207
|
+
* });
|
|
8208
|
+
*
|
|
8209
|
+
* while (!operation.done) {
|
|
8210
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
8211
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
8212
|
+
* }
|
|
8213
|
+
*
|
|
8214
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
8215
|
+
* ```
|
|
8216
|
+
*/
|
|
8217
|
+
async generateVideos(params) {
|
|
8218
|
+
var _a, _b;
|
|
8219
|
+
let response;
|
|
8220
|
+
let path = '';
|
|
8221
|
+
let queryParams = {};
|
|
8222
|
+
if (this.apiClient.isVertexAI()) {
|
|
8223
|
+
const body = generateVideosParametersToVertex(this.apiClient, params);
|
|
8224
|
+
path = formatMap('{model}:predictLongRunning', body['_url']);
|
|
8225
|
+
queryParams = body['_query'];
|
|
8226
|
+
delete body['config'];
|
|
8227
|
+
delete body['_url'];
|
|
8228
|
+
delete body['_query'];
|
|
8229
|
+
response = this.apiClient
|
|
8230
|
+
.request({
|
|
8231
|
+
path: path,
|
|
8232
|
+
queryParams: queryParams,
|
|
8233
|
+
body: JSON.stringify(body),
|
|
8234
|
+
httpMethod: 'POST',
|
|
8235
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8236
|
+
})
|
|
8237
|
+
.then((httpResponse) => {
|
|
8238
|
+
return httpResponse.json();
|
|
8239
|
+
});
|
|
8240
|
+
return response.then((apiResponse) => {
|
|
8241
|
+
const resp = generateVideosOperationFromVertex$1(this.apiClient, apiResponse);
|
|
8242
|
+
return resp;
|
|
8243
|
+
});
|
|
8244
|
+
}
|
|
8245
|
+
else {
|
|
8246
|
+
const body = generateVideosParametersToMldev(this.apiClient, params);
|
|
8247
|
+
path = formatMap('{model}:predictLongRunning', body['_url']);
|
|
8248
|
+
queryParams = body['_query'];
|
|
8249
|
+
delete body['config'];
|
|
8250
|
+
delete body['_url'];
|
|
8251
|
+
delete body['_query'];
|
|
8252
|
+
response = this.apiClient
|
|
8253
|
+
.request({
|
|
8254
|
+
path: path,
|
|
8255
|
+
queryParams: queryParams,
|
|
8256
|
+
body: JSON.stringify(body),
|
|
8257
|
+
httpMethod: 'POST',
|
|
8258
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
8259
|
+
})
|
|
8260
|
+
.then((httpResponse) => {
|
|
8261
|
+
return httpResponse.json();
|
|
8262
|
+
});
|
|
8263
|
+
return response.then((apiResponse) => {
|
|
8264
|
+
const resp = generateVideosOperationFromMldev$1(this.apiClient, apiResponse);
|
|
8265
|
+
return resp;
|
|
8266
|
+
});
|
|
8267
|
+
}
|
|
8268
|
+
}
|
|
8269
|
+
}
|
|
8270
|
+
|
|
8271
|
+
/**
|
|
8272
|
+
* @license
|
|
8273
|
+
* Copyright 2025 Google LLC
|
|
8274
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8275
|
+
*/
|
|
8276
|
+
function getOperationParametersToMldev(apiClient, fromObject) {
|
|
8277
|
+
const toObject = {};
|
|
8278
|
+
const fromOperationName = getValueByPath(fromObject, [
|
|
8279
|
+
'operationName',
|
|
8280
|
+
]);
|
|
8281
|
+
if (fromOperationName != null) {
|
|
8282
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
8283
|
+
}
|
|
8284
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8285
|
+
if (fromConfig != null) {
|
|
8286
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
8287
|
+
}
|
|
8288
|
+
return toObject;
|
|
8289
|
+
}
|
|
8290
|
+
function getOperationParametersToVertex(apiClient, fromObject) {
|
|
8291
|
+
const toObject = {};
|
|
8292
|
+
const fromOperationName = getValueByPath(fromObject, [
|
|
8293
|
+
'operationName',
|
|
8294
|
+
]);
|
|
8295
|
+
if (fromOperationName != null) {
|
|
8296
|
+
setValueByPath(toObject, ['_url', 'operationName'], fromOperationName);
|
|
8297
|
+
}
|
|
8298
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8299
|
+
if (fromConfig != null) {
|
|
8300
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
8301
|
+
}
|
|
8302
|
+
return toObject;
|
|
8303
|
+
}
|
|
8304
|
+
function fetchPredictOperationParametersToVertex(apiClient, fromObject) {
|
|
8305
|
+
const toObject = {};
|
|
8306
|
+
const fromOperationName = getValueByPath(fromObject, [
|
|
8307
|
+
'operationName',
|
|
8308
|
+
]);
|
|
8309
|
+
if (fromOperationName != null) {
|
|
8310
|
+
setValueByPath(toObject, ['operationName'], fromOperationName);
|
|
8311
|
+
}
|
|
8312
|
+
const fromResourceName = getValueByPath(fromObject, ['resourceName']);
|
|
8313
|
+
if (fromResourceName != null) {
|
|
8314
|
+
setValueByPath(toObject, ['_url', 'resourceName'], fromResourceName);
|
|
8315
|
+
}
|
|
8316
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
8317
|
+
if (fromConfig != null) {
|
|
8318
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
8319
|
+
}
|
|
8320
|
+
return toObject;
|
|
8321
|
+
}
|
|
8322
|
+
function videoFromMldev(apiClient, fromObject) {
|
|
8323
|
+
const toObject = {};
|
|
8324
|
+
const fromUri = getValueByPath(fromObject, ['video', 'uri']);
|
|
8325
|
+
if (fromUri != null) {
|
|
8326
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
8327
|
+
}
|
|
8328
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
8329
|
+
'video',
|
|
8330
|
+
'encodedVideo',
|
|
8331
|
+
]);
|
|
8332
|
+
if (fromVideoBytes != null) {
|
|
8333
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
8334
|
+
}
|
|
8335
|
+
const fromMimeType = getValueByPath(fromObject, ['encoding']);
|
|
8336
|
+
if (fromMimeType != null) {
|
|
8337
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
8338
|
+
}
|
|
8339
|
+
return toObject;
|
|
8340
|
+
}
|
|
8341
|
+
function generatedVideoFromMldev(apiClient, fromObject) {
|
|
8342
|
+
const toObject = {};
|
|
8343
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
8344
|
+
if (fromVideo != null) {
|
|
8345
|
+
setValueByPath(toObject, ['video'], videoFromMldev(apiClient, fromVideo));
|
|
8346
|
+
}
|
|
8347
|
+
return toObject;
|
|
8348
|
+
}
|
|
8349
|
+
function generateVideosResponseFromMldev(apiClient, fromObject) {
|
|
8350
|
+
const toObject = {};
|
|
8351
|
+
const fromGeneratedVideos = getValueByPath(fromObject, [
|
|
8352
|
+
'generatedSamples',
|
|
8353
|
+
]);
|
|
8354
|
+
if (fromGeneratedVideos != null) {
|
|
8355
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
8356
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
8357
|
+
return generatedVideoFromMldev(apiClient, item);
|
|
8358
|
+
}));
|
|
8359
|
+
}
|
|
8360
|
+
else {
|
|
8361
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8362
|
+
}
|
|
8363
|
+
}
|
|
8364
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8365
|
+
'raiMediaFilteredCount',
|
|
8366
|
+
]);
|
|
8367
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
8368
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
8369
|
+
}
|
|
8370
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
8371
|
+
'raiMediaFilteredReasons',
|
|
8372
|
+
]);
|
|
8373
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
8374
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
8375
|
+
}
|
|
8376
|
+
return toObject;
|
|
8377
|
+
}
|
|
8378
|
+
function generateVideosOperationFromMldev(apiClient, fromObject) {
|
|
8379
|
+
const toObject = {};
|
|
8380
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
8381
|
+
if (fromName != null) {
|
|
8382
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
8383
|
+
}
|
|
8384
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
8385
|
+
if (fromMetadata != null) {
|
|
8386
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
8387
|
+
}
|
|
8388
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
8389
|
+
if (fromDone != null) {
|
|
8390
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
8391
|
+
}
|
|
8392
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
8393
|
+
if (fromError != null) {
|
|
8394
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
8395
|
+
}
|
|
8396
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
8397
|
+
'response',
|
|
8398
|
+
'generateVideoResponse',
|
|
8399
|
+
]);
|
|
8400
|
+
if (fromResponse != null) {
|
|
8401
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(apiClient, fromResponse));
|
|
8402
|
+
}
|
|
8403
|
+
const fromResult = getValueByPath(fromObject, [
|
|
8404
|
+
'response',
|
|
8405
|
+
'generateVideoResponse',
|
|
8406
|
+
]);
|
|
8407
|
+
if (fromResult != null) {
|
|
8408
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromMldev(apiClient, fromResult));
|
|
8409
|
+
}
|
|
8410
|
+
return toObject;
|
|
8411
|
+
}
|
|
8412
|
+
function videoFromVertex(apiClient, fromObject) {
|
|
8413
|
+
const toObject = {};
|
|
8414
|
+
const fromUri = getValueByPath(fromObject, ['gcsUri']);
|
|
8415
|
+
if (fromUri != null) {
|
|
8416
|
+
setValueByPath(toObject, ['uri'], fromUri);
|
|
8417
|
+
}
|
|
8418
|
+
const fromVideoBytes = getValueByPath(fromObject, [
|
|
8419
|
+
'bytesBase64Encoded',
|
|
8420
|
+
]);
|
|
8421
|
+
if (fromVideoBytes != null) {
|
|
8422
|
+
setValueByPath(toObject, ['videoBytes'], tBytes(apiClient, fromVideoBytes));
|
|
8423
|
+
}
|
|
8424
|
+
const fromMimeType = getValueByPath(fromObject, ['mimeType']);
|
|
8425
|
+
if (fromMimeType != null) {
|
|
8426
|
+
setValueByPath(toObject, ['mimeType'], fromMimeType);
|
|
8427
|
+
}
|
|
8428
|
+
return toObject;
|
|
8429
|
+
}
|
|
8430
|
+
function generatedVideoFromVertex(apiClient, fromObject) {
|
|
8431
|
+
const toObject = {};
|
|
8432
|
+
const fromVideo = getValueByPath(fromObject, ['_self']);
|
|
8433
|
+
if (fromVideo != null) {
|
|
8434
|
+
setValueByPath(toObject, ['video'], videoFromVertex(apiClient, fromVideo));
|
|
8435
|
+
}
|
|
8436
|
+
return toObject;
|
|
8437
|
+
}
|
|
8438
|
+
function generateVideosResponseFromVertex(apiClient, fromObject) {
|
|
8439
|
+
const toObject = {};
|
|
8440
|
+
const fromGeneratedVideos = getValueByPath(fromObject, ['videos']);
|
|
8441
|
+
if (fromGeneratedVideos != null) {
|
|
8442
|
+
if (Array.isArray(fromGeneratedVideos)) {
|
|
8443
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos.map((item) => {
|
|
8444
|
+
return generatedVideoFromVertex(apiClient, item);
|
|
8445
|
+
}));
|
|
8446
|
+
}
|
|
8447
|
+
else {
|
|
8448
|
+
setValueByPath(toObject, ['generatedVideos'], fromGeneratedVideos);
|
|
8449
|
+
}
|
|
8450
|
+
}
|
|
8451
|
+
const fromRaiMediaFilteredCount = getValueByPath(fromObject, [
|
|
8452
|
+
'raiMediaFilteredCount',
|
|
8453
|
+
]);
|
|
8454
|
+
if (fromRaiMediaFilteredCount != null) {
|
|
8455
|
+
setValueByPath(toObject, ['raiMediaFilteredCount'], fromRaiMediaFilteredCount);
|
|
8456
|
+
}
|
|
8457
|
+
const fromRaiMediaFilteredReasons = getValueByPath(fromObject, [
|
|
8458
|
+
'raiMediaFilteredReasons',
|
|
8459
|
+
]);
|
|
8460
|
+
if (fromRaiMediaFilteredReasons != null) {
|
|
8461
|
+
setValueByPath(toObject, ['raiMediaFilteredReasons'], fromRaiMediaFilteredReasons);
|
|
8462
|
+
}
|
|
8463
|
+
return toObject;
|
|
8464
|
+
}
|
|
8465
|
+
function generateVideosOperationFromVertex(apiClient, fromObject) {
|
|
8466
|
+
const toObject = {};
|
|
8467
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
8468
|
+
if (fromName != null) {
|
|
8469
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
8470
|
+
}
|
|
8471
|
+
const fromMetadata = getValueByPath(fromObject, ['metadata']);
|
|
8472
|
+
if (fromMetadata != null) {
|
|
8473
|
+
setValueByPath(toObject, ['metadata'], fromMetadata);
|
|
8474
|
+
}
|
|
8475
|
+
const fromDone = getValueByPath(fromObject, ['done']);
|
|
8476
|
+
if (fromDone != null) {
|
|
8477
|
+
setValueByPath(toObject, ['done'], fromDone);
|
|
8478
|
+
}
|
|
8479
|
+
const fromError = getValueByPath(fromObject, ['error']);
|
|
8480
|
+
if (fromError != null) {
|
|
8481
|
+
setValueByPath(toObject, ['error'], fromError);
|
|
8482
|
+
}
|
|
8483
|
+
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
8484
|
+
if (fromResponse != null) {
|
|
8485
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(apiClient, fromResponse));
|
|
8486
|
+
}
|
|
8487
|
+
const fromResult = getValueByPath(fromObject, ['response']);
|
|
8488
|
+
if (fromResult != null) {
|
|
8489
|
+
setValueByPath(toObject, ['result'], generateVideosResponseFromVertex(apiClient, fromResult));
|
|
8490
|
+
}
|
|
8491
|
+
return toObject;
|
|
8492
|
+
}
|
|
8493
|
+
|
|
8494
|
+
/**
|
|
8495
|
+
* @license
|
|
8496
|
+
* Copyright 2025 Google LLC
|
|
8497
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8498
|
+
*/
|
|
8499
|
+
class Operations extends BaseModule {
|
|
8500
|
+
constructor(apiClient) {
|
|
8501
|
+
super();
|
|
8502
|
+
this.apiClient = apiClient;
|
|
8503
|
+
}
|
|
8504
|
+
/**
|
|
8505
|
+
* Gets the status of a long-running operation.
|
|
8506
|
+
*
|
|
8507
|
+
* @param parameters The parameters for the get operation request.
|
|
8508
|
+
* @return The updated Operation object, with the latest status or result.
|
|
8509
|
+
*/
|
|
8510
|
+
async getVideosOperation(parameters) {
|
|
8511
|
+
const operation = parameters.operation;
|
|
8512
|
+
const config = parameters.config;
|
|
8513
|
+
if (operation.name === undefined || operation.name === '') {
|
|
8514
|
+
throw new Error('Operation name is required.');
|
|
8515
|
+
}
|
|
8516
|
+
if (this.apiClient.isVertexAI()) {
|
|
8517
|
+
const resourceName = operation.name.split('/operations/')[0];
|
|
8518
|
+
var httpOptions = undefined;
|
|
8519
|
+
if (config && 'httpOptions' in config) {
|
|
8520
|
+
httpOptions = config.httpOptions;
|
|
8521
|
+
}
|
|
8522
|
+
return this.fetchPredictVideosOperationInternal({
|
|
8523
|
+
operationName: operation.name,
|
|
8524
|
+
resourceName: resourceName,
|
|
8525
|
+
config: { httpOptions: httpOptions },
|
|
8526
|
+
});
|
|
8527
|
+
}
|
|
8528
|
+
else {
|
|
8529
|
+
return this.getVideosOperationInternal({
|
|
8530
|
+
operationName: operation.name,
|
|
8531
|
+
config: config,
|
|
8532
|
+
});
|
|
8533
|
+
}
|
|
8534
|
+
}
|
|
8535
|
+
async getVideosOperationInternal(params) {
|
|
8536
|
+
var _a, _b;
|
|
8537
|
+
let response;
|
|
8538
|
+
let path = '';
|
|
8539
|
+
let queryParams = {};
|
|
8540
|
+
if (this.apiClient.isVertexAI()) {
|
|
8541
|
+
const body = getOperationParametersToVertex(this.apiClient, params);
|
|
8542
|
+
path = formatMap('{operationName}', body['_url']);
|
|
8543
|
+
queryParams = body['_query'];
|
|
8544
|
+
delete body['config'];
|
|
8545
|
+
delete body['_url'];
|
|
8546
|
+
delete body['_query'];
|
|
8547
|
+
response = this.apiClient
|
|
8548
|
+
.request({
|
|
8549
|
+
path: path,
|
|
8550
|
+
queryParams: queryParams,
|
|
8551
|
+
body: JSON.stringify(body),
|
|
8552
|
+
httpMethod: 'GET',
|
|
8553
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8554
|
+
})
|
|
8555
|
+
.then((httpResponse) => {
|
|
8556
|
+
return httpResponse.json();
|
|
8557
|
+
});
|
|
8558
|
+
return response.then((apiResponse) => {
|
|
8559
|
+
const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
|
|
8560
|
+
return resp;
|
|
8561
|
+
});
|
|
8562
|
+
}
|
|
8563
|
+
else {
|
|
8564
|
+
const body = getOperationParametersToMldev(this.apiClient, params);
|
|
8565
|
+
path = formatMap('{operationName}', body['_url']);
|
|
8566
|
+
queryParams = body['_query'];
|
|
8567
|
+
delete body['config'];
|
|
8568
|
+
delete body['_url'];
|
|
8569
|
+
delete body['_query'];
|
|
8570
|
+
response = this.apiClient
|
|
8571
|
+
.request({
|
|
8572
|
+
path: path,
|
|
8573
|
+
queryParams: queryParams,
|
|
8574
|
+
body: JSON.stringify(body),
|
|
8575
|
+
httpMethod: 'GET',
|
|
8576
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
8577
|
+
})
|
|
8578
|
+
.then((httpResponse) => {
|
|
8579
|
+
return httpResponse.json();
|
|
8580
|
+
});
|
|
8581
|
+
return response.then((apiResponse) => {
|
|
8582
|
+
const resp = generateVideosOperationFromMldev(this.apiClient, apiResponse);
|
|
8583
|
+
return resp;
|
|
8584
|
+
});
|
|
8585
|
+
}
|
|
8586
|
+
}
|
|
8587
|
+
async fetchPredictVideosOperationInternal(params) {
|
|
8588
|
+
var _a;
|
|
8589
|
+
let response;
|
|
8590
|
+
let path = '';
|
|
8591
|
+
let queryParams = {};
|
|
8592
|
+
if (this.apiClient.isVertexAI()) {
|
|
8593
|
+
const body = fetchPredictOperationParametersToVertex(this.apiClient, params);
|
|
8594
|
+
path = formatMap('{resourceName}:fetchPredictOperation', body['_url']);
|
|
8595
|
+
queryParams = body['_query'];
|
|
8596
|
+
delete body['config'];
|
|
8597
|
+
delete body['_url'];
|
|
8598
|
+
delete body['_query'];
|
|
8599
|
+
response = this.apiClient
|
|
8600
|
+
.request({
|
|
8601
|
+
path: path,
|
|
8602
|
+
queryParams: queryParams,
|
|
8603
|
+
body: JSON.stringify(body),
|
|
8604
|
+
httpMethod: 'POST',
|
|
8605
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8606
|
+
})
|
|
8607
|
+
.then((httpResponse) => {
|
|
8608
|
+
return httpResponse.json();
|
|
8609
|
+
});
|
|
8610
|
+
return response.then((apiResponse) => {
|
|
8611
|
+
const resp = generateVideosOperationFromVertex(this.apiClient, apiResponse);
|
|
8612
|
+
return resp;
|
|
8613
|
+
});
|
|
8614
|
+
}
|
|
8615
|
+
else {
|
|
8616
|
+
throw new Error('This method is only supported by the Vertex AI.');
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
6976
8619
|
}
|
|
6977
8620
|
|
|
6978
8621
|
/**
|
|
@@ -7055,8 +8698,9 @@ class GoogleGenAI {
|
|
|
7055
8698
|
this.chats = new Chats(this.models, this.apiClient);
|
|
7056
8699
|
this.caches = new Caches(this.apiClient);
|
|
7057
8700
|
this.files = new Files(this.apiClient);
|
|
8701
|
+
this.operations = new Operations(this.apiClient);
|
|
7058
8702
|
}
|
|
7059
8703
|
}
|
|
7060
8704
|
|
|
7061
|
-
export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, FileSource, FileState, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaResolution, Modality, Mode, Models, Outcome, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session,
|
|
8705
|
+
export { ActivityHandling, BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, EndSensitivity, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpResponse, ImagePromptLanguage, Language, ListCachedContentsResponse, ListFilesResponse, Live, LiveClientToolResponse, LiveSendToolResponseParameters, MaskReferenceMode, MediaModality, MediaResolution, Modality, Mode, Models, Operations, Outcome, PagedItem, Pager, PersonGeneration, ReplayResponse, SafetyFilterLevel, Session, StartSensitivity, SubjectReferenceType, TrafficType, TurnCoverage, Type, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent };
|
|
7062
8706
|
//# sourceMappingURL=index.mjs.map
|