@google/genai 0.7.0 → 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 +367 -45
- package/dist/index.js +887 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +888 -34
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +894 -39
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +367 -45
- package/dist/web/index.mjs +888 -34
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +367 -45
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1514,6 +1514,7 @@ class Pager {
|
|
|
1514
1514
|
* SPDX-License-Identifier: Apache-2.0
|
|
1515
1515
|
*/
|
|
1516
1516
|
// Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
1517
|
+
/** Required. Outcome of the code execution. */
|
|
1517
1518
|
exports.Outcome = void 0;
|
|
1518
1519
|
(function (Outcome) {
|
|
1519
1520
|
Outcome["OUTCOME_UNSPECIFIED"] = "OUTCOME_UNSPECIFIED";
|
|
@@ -1521,11 +1522,13 @@ exports.Outcome = void 0;
|
|
|
1521
1522
|
Outcome["OUTCOME_FAILED"] = "OUTCOME_FAILED";
|
|
1522
1523
|
Outcome["OUTCOME_DEADLINE_EXCEEDED"] = "OUTCOME_DEADLINE_EXCEEDED";
|
|
1523
1524
|
})(exports.Outcome || (exports.Outcome = {}));
|
|
1525
|
+
/** Required. Programming language of the `code`. */
|
|
1524
1526
|
exports.Language = void 0;
|
|
1525
1527
|
(function (Language) {
|
|
1526
1528
|
Language["LANGUAGE_UNSPECIFIED"] = "LANGUAGE_UNSPECIFIED";
|
|
1527
1529
|
Language["PYTHON"] = "PYTHON";
|
|
1528
1530
|
})(exports.Language || (exports.Language = {}));
|
|
1531
|
+
/** Optional. The type of the data. */
|
|
1529
1532
|
exports.Type = void 0;
|
|
1530
1533
|
(function (Type) {
|
|
1531
1534
|
Type["TYPE_UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
@@ -1536,6 +1539,7 @@ exports.Type = void 0;
|
|
|
1536
1539
|
Type["ARRAY"] = "ARRAY";
|
|
1537
1540
|
Type["OBJECT"] = "OBJECT";
|
|
1538
1541
|
})(exports.Type || (exports.Type = {}));
|
|
1542
|
+
/** Required. Harm category. */
|
|
1539
1543
|
exports.HarmCategory = void 0;
|
|
1540
1544
|
(function (HarmCategory) {
|
|
1541
1545
|
HarmCategory["HARM_CATEGORY_UNSPECIFIED"] = "HARM_CATEGORY_UNSPECIFIED";
|
|
@@ -1545,12 +1549,14 @@ exports.HarmCategory = void 0;
|
|
|
1545
1549
|
HarmCategory["HARM_CATEGORY_SEXUALLY_EXPLICIT"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
1546
1550
|
HarmCategory["HARM_CATEGORY_CIVIC_INTEGRITY"] = "HARM_CATEGORY_CIVIC_INTEGRITY";
|
|
1547
1551
|
})(exports.HarmCategory || (exports.HarmCategory = {}));
|
|
1552
|
+
/** Optional. Specify if the threshold is used for probability or severity score. If not specified, the threshold is used for probability score. */
|
|
1548
1553
|
exports.HarmBlockMethod = void 0;
|
|
1549
1554
|
(function (HarmBlockMethod) {
|
|
1550
1555
|
HarmBlockMethod["HARM_BLOCK_METHOD_UNSPECIFIED"] = "HARM_BLOCK_METHOD_UNSPECIFIED";
|
|
1551
1556
|
HarmBlockMethod["SEVERITY"] = "SEVERITY";
|
|
1552
1557
|
HarmBlockMethod["PROBABILITY"] = "PROBABILITY";
|
|
1553
1558
|
})(exports.HarmBlockMethod || (exports.HarmBlockMethod = {}));
|
|
1559
|
+
/** Required. The harm block threshold. */
|
|
1554
1560
|
exports.HarmBlockThreshold = void 0;
|
|
1555
1561
|
(function (HarmBlockThreshold) {
|
|
1556
1562
|
HarmBlockThreshold["HARM_BLOCK_THRESHOLD_UNSPECIFIED"] = "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
@@ -1560,11 +1566,16 @@ exports.HarmBlockThreshold = void 0;
|
|
|
1560
1566
|
HarmBlockThreshold["BLOCK_NONE"] = "BLOCK_NONE";
|
|
1561
1567
|
HarmBlockThreshold["OFF"] = "OFF";
|
|
1562
1568
|
})(exports.HarmBlockThreshold || (exports.HarmBlockThreshold = {}));
|
|
1569
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
1563
1570
|
exports.Mode = void 0;
|
|
1564
1571
|
(function (Mode) {
|
|
1565
1572
|
Mode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1566
1573
|
Mode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1567
1574
|
})(exports.Mode || (exports.Mode = {}));
|
|
1575
|
+
/** Output only. The reason why the model stopped generating tokens.
|
|
1576
|
+
|
|
1577
|
+
If empty, the model has not stopped generating the tokens.
|
|
1578
|
+
*/
|
|
1568
1579
|
exports.FinishReason = void 0;
|
|
1569
1580
|
(function (FinishReason) {
|
|
1570
1581
|
FinishReason["FINISH_REASON_UNSPECIFIED"] = "FINISH_REASON_UNSPECIFIED";
|
|
@@ -1579,6 +1590,7 @@ exports.FinishReason = void 0;
|
|
|
1579
1590
|
FinishReason["MALFORMED_FUNCTION_CALL"] = "MALFORMED_FUNCTION_CALL";
|
|
1580
1591
|
FinishReason["IMAGE_SAFETY"] = "IMAGE_SAFETY";
|
|
1581
1592
|
})(exports.FinishReason || (exports.FinishReason = {}));
|
|
1593
|
+
/** Output only. Harm probability levels in the content. */
|
|
1582
1594
|
exports.HarmProbability = void 0;
|
|
1583
1595
|
(function (HarmProbability) {
|
|
1584
1596
|
HarmProbability["HARM_PROBABILITY_UNSPECIFIED"] = "HARM_PROBABILITY_UNSPECIFIED";
|
|
@@ -1587,6 +1599,7 @@ exports.HarmProbability = void 0;
|
|
|
1587
1599
|
HarmProbability["MEDIUM"] = "MEDIUM";
|
|
1588
1600
|
HarmProbability["HIGH"] = "HIGH";
|
|
1589
1601
|
})(exports.HarmProbability || (exports.HarmProbability = {}));
|
|
1602
|
+
/** Output only. Harm severity levels in the content. */
|
|
1590
1603
|
exports.HarmSeverity = void 0;
|
|
1591
1604
|
(function (HarmSeverity) {
|
|
1592
1605
|
HarmSeverity["HARM_SEVERITY_UNSPECIFIED"] = "HARM_SEVERITY_UNSPECIFIED";
|
|
@@ -1595,6 +1608,7 @@ exports.HarmSeverity = void 0;
|
|
|
1595
1608
|
HarmSeverity["HARM_SEVERITY_MEDIUM"] = "HARM_SEVERITY_MEDIUM";
|
|
1596
1609
|
HarmSeverity["HARM_SEVERITY_HIGH"] = "HARM_SEVERITY_HIGH";
|
|
1597
1610
|
})(exports.HarmSeverity || (exports.HarmSeverity = {}));
|
|
1611
|
+
/** Output only. Blocked reason. */
|
|
1598
1612
|
exports.BlockedReason = void 0;
|
|
1599
1613
|
(function (BlockedReason) {
|
|
1600
1614
|
BlockedReason["BLOCKED_REASON_UNSPECIFIED"] = "BLOCKED_REASON_UNSPECIFIED";
|
|
@@ -1603,6 +1617,14 @@ exports.BlockedReason = void 0;
|
|
|
1603
1617
|
BlockedReason["BLOCKLIST"] = "BLOCKLIST";
|
|
1604
1618
|
BlockedReason["PROHIBITED_CONTENT"] = "PROHIBITED_CONTENT";
|
|
1605
1619
|
})(exports.BlockedReason || (exports.BlockedReason = {}));
|
|
1620
|
+
/** Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. */
|
|
1621
|
+
exports.TrafficType = void 0;
|
|
1622
|
+
(function (TrafficType) {
|
|
1623
|
+
TrafficType["TRAFFIC_TYPE_UNSPECIFIED"] = "TRAFFIC_TYPE_UNSPECIFIED";
|
|
1624
|
+
TrafficType["ON_DEMAND"] = "ON_DEMAND";
|
|
1625
|
+
TrafficType["PROVISIONED_THROUGHPUT"] = "PROVISIONED_THROUGHPUT";
|
|
1626
|
+
})(exports.TrafficType || (exports.TrafficType = {}));
|
|
1627
|
+
/** Server content modalities. */
|
|
1606
1628
|
exports.Modality = void 0;
|
|
1607
1629
|
(function (Modality) {
|
|
1608
1630
|
Modality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
@@ -1610,17 +1632,21 @@ exports.Modality = void 0;
|
|
|
1610
1632
|
Modality["IMAGE"] = "IMAGE";
|
|
1611
1633
|
Modality["AUDIO"] = "AUDIO";
|
|
1612
1634
|
})(exports.Modality || (exports.Modality = {}));
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1635
|
+
/** The media resolution to use. */
|
|
1636
|
+
exports.MediaResolution = void 0;
|
|
1637
|
+
(function (MediaResolution) {
|
|
1638
|
+
MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1639
|
+
MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1640
|
+
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1641
|
+
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1642
|
+
})(exports.MediaResolution || (exports.MediaResolution = {}));
|
|
1643
|
+
/** Config for the dynamic retrieval config mode. */
|
|
1619
1644
|
exports.DynamicRetrievalConfigMode = void 0;
|
|
1620
1645
|
(function (DynamicRetrievalConfigMode) {
|
|
1621
1646
|
DynamicRetrievalConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
1622
1647
|
DynamicRetrievalConfigMode["MODE_DYNAMIC"] = "MODE_DYNAMIC";
|
|
1623
1648
|
})(exports.DynamicRetrievalConfigMode || (exports.DynamicRetrievalConfigMode = {}));
|
|
1649
|
+
/** Config for the function calling config mode. */
|
|
1624
1650
|
exports.FunctionCallingConfigMode = void 0;
|
|
1625
1651
|
(function (FunctionCallingConfigMode) {
|
|
1626
1652
|
FunctionCallingConfigMode["MODE_UNSPECIFIED"] = "MODE_UNSPECIFIED";
|
|
@@ -1628,13 +1654,7 @@ exports.FunctionCallingConfigMode = void 0;
|
|
|
1628
1654
|
FunctionCallingConfigMode["ANY"] = "ANY";
|
|
1629
1655
|
FunctionCallingConfigMode["NONE"] = "NONE";
|
|
1630
1656
|
})(exports.FunctionCallingConfigMode || (exports.FunctionCallingConfigMode = {}));
|
|
1631
|
-
|
|
1632
|
-
(function (MediaResolution) {
|
|
1633
|
-
MediaResolution["MEDIA_RESOLUTION_UNSPECIFIED"] = "MEDIA_RESOLUTION_UNSPECIFIED";
|
|
1634
|
-
MediaResolution["MEDIA_RESOLUTION_LOW"] = "MEDIA_RESOLUTION_LOW";
|
|
1635
|
-
MediaResolution["MEDIA_RESOLUTION_MEDIUM"] = "MEDIA_RESOLUTION_MEDIUM";
|
|
1636
|
-
MediaResolution["MEDIA_RESOLUTION_HIGH"] = "MEDIA_RESOLUTION_HIGH";
|
|
1637
|
-
})(exports.MediaResolution || (exports.MediaResolution = {}));
|
|
1657
|
+
/** Enum that controls the safety filter level for objectionable content. */
|
|
1638
1658
|
exports.SafetyFilterLevel = void 0;
|
|
1639
1659
|
(function (SafetyFilterLevel) {
|
|
1640
1660
|
SafetyFilterLevel["BLOCK_LOW_AND_ABOVE"] = "BLOCK_LOW_AND_ABOVE";
|
|
@@ -1642,12 +1662,14 @@ exports.SafetyFilterLevel = void 0;
|
|
|
1642
1662
|
SafetyFilterLevel["BLOCK_ONLY_HIGH"] = "BLOCK_ONLY_HIGH";
|
|
1643
1663
|
SafetyFilterLevel["BLOCK_NONE"] = "BLOCK_NONE";
|
|
1644
1664
|
})(exports.SafetyFilterLevel || (exports.SafetyFilterLevel = {}));
|
|
1665
|
+
/** Enum that controls the generation of people. */
|
|
1645
1666
|
exports.PersonGeneration = void 0;
|
|
1646
1667
|
(function (PersonGeneration) {
|
|
1647
1668
|
PersonGeneration["DONT_ALLOW"] = "DONT_ALLOW";
|
|
1648
1669
|
PersonGeneration["ALLOW_ADULT"] = "ALLOW_ADULT";
|
|
1649
1670
|
PersonGeneration["ALLOW_ALL"] = "ALLOW_ALL";
|
|
1650
1671
|
})(exports.PersonGeneration || (exports.PersonGeneration = {}));
|
|
1672
|
+
/** Enum that specifies the language of the text in the prompt. */
|
|
1651
1673
|
exports.ImagePromptLanguage = void 0;
|
|
1652
1674
|
(function (ImagePromptLanguage) {
|
|
1653
1675
|
ImagePromptLanguage["auto"] = "auto";
|
|
@@ -1656,6 +1678,7 @@ exports.ImagePromptLanguage = void 0;
|
|
|
1656
1678
|
ImagePromptLanguage["ko"] = "ko";
|
|
1657
1679
|
ImagePromptLanguage["hi"] = "hi";
|
|
1658
1680
|
})(exports.ImagePromptLanguage || (exports.ImagePromptLanguage = {}));
|
|
1681
|
+
/** State for the lifecycle of a File. */
|
|
1659
1682
|
exports.FileState = void 0;
|
|
1660
1683
|
(function (FileState) {
|
|
1661
1684
|
FileState["STATE_UNSPECIFIED"] = "STATE_UNSPECIFIED";
|
|
@@ -1663,12 +1686,14 @@ exports.FileState = void 0;
|
|
|
1663
1686
|
FileState["ACTIVE"] = "ACTIVE";
|
|
1664
1687
|
FileState["FAILED"] = "FAILED";
|
|
1665
1688
|
})(exports.FileState || (exports.FileState = {}));
|
|
1689
|
+
/** Source of the File. */
|
|
1666
1690
|
exports.FileSource = void 0;
|
|
1667
1691
|
(function (FileSource) {
|
|
1668
1692
|
FileSource["SOURCE_UNSPECIFIED"] = "SOURCE_UNSPECIFIED";
|
|
1669
1693
|
FileSource["UPLOADED"] = "UPLOADED";
|
|
1670
1694
|
FileSource["GENERATED"] = "GENERATED";
|
|
1671
1695
|
})(exports.FileSource || (exports.FileSource = {}));
|
|
1696
|
+
/** Enum representing the mask mode of a mask reference image. */
|
|
1672
1697
|
exports.MaskReferenceMode = void 0;
|
|
1673
1698
|
(function (MaskReferenceMode) {
|
|
1674
1699
|
MaskReferenceMode["MASK_MODE_DEFAULT"] = "MASK_MODE_DEFAULT";
|
|
@@ -1677,6 +1702,7 @@ exports.MaskReferenceMode = void 0;
|
|
|
1677
1702
|
MaskReferenceMode["MASK_MODE_FOREGROUND"] = "MASK_MODE_FOREGROUND";
|
|
1678
1703
|
MaskReferenceMode["MASK_MODE_SEMANTIC"] = "MASK_MODE_SEMANTIC";
|
|
1679
1704
|
})(exports.MaskReferenceMode || (exports.MaskReferenceMode = {}));
|
|
1705
|
+
/** Enum representing the control type of a control reference image. */
|
|
1680
1706
|
exports.ControlReferenceType = void 0;
|
|
1681
1707
|
(function (ControlReferenceType) {
|
|
1682
1708
|
ControlReferenceType["CONTROL_TYPE_DEFAULT"] = "CONTROL_TYPE_DEFAULT";
|
|
@@ -1684,6 +1710,7 @@ exports.ControlReferenceType = void 0;
|
|
|
1684
1710
|
ControlReferenceType["CONTROL_TYPE_SCRIBBLE"] = "CONTROL_TYPE_SCRIBBLE";
|
|
1685
1711
|
ControlReferenceType["CONTROL_TYPE_FACE_MESH"] = "CONTROL_TYPE_FACE_MESH";
|
|
1686
1712
|
})(exports.ControlReferenceType || (exports.ControlReferenceType = {}));
|
|
1713
|
+
/** Enum representing the subject type of a subject reference image. */
|
|
1687
1714
|
exports.SubjectReferenceType = void 0;
|
|
1688
1715
|
(function (SubjectReferenceType) {
|
|
1689
1716
|
SubjectReferenceType["SUBJECT_TYPE_DEFAULT"] = "SUBJECT_TYPE_DEFAULT";
|
|
@@ -1691,6 +1718,7 @@ exports.SubjectReferenceType = void 0;
|
|
|
1691
1718
|
SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
|
|
1692
1719
|
SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
|
|
1693
1720
|
})(exports.SubjectReferenceType || (exports.SubjectReferenceType = {}));
|
|
1721
|
+
/** Server content modalities. */
|
|
1694
1722
|
exports.MediaModality = void 0;
|
|
1695
1723
|
(function (MediaModality) {
|
|
1696
1724
|
MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
@@ -1700,6 +1728,34 @@ exports.MediaModality = void 0;
|
|
|
1700
1728
|
MediaModality["AUDIO"] = "AUDIO";
|
|
1701
1729
|
MediaModality["DOCUMENT"] = "DOCUMENT";
|
|
1702
1730
|
})(exports.MediaModality || (exports.MediaModality = {}));
|
|
1731
|
+
/** Start of speech sensitivity. */
|
|
1732
|
+
exports.StartSensitivity = void 0;
|
|
1733
|
+
(function (StartSensitivity) {
|
|
1734
|
+
StartSensitivity["START_SENSITIVITY_UNSPECIFIED"] = "START_SENSITIVITY_UNSPECIFIED";
|
|
1735
|
+
StartSensitivity["START_SENSITIVITY_HIGH"] = "START_SENSITIVITY_HIGH";
|
|
1736
|
+
StartSensitivity["START_SENSITIVITY_LOW"] = "START_SENSITIVITY_LOW";
|
|
1737
|
+
})(exports.StartSensitivity || (exports.StartSensitivity = {}));
|
|
1738
|
+
/** End of speech sensitivity. */
|
|
1739
|
+
exports.EndSensitivity = void 0;
|
|
1740
|
+
(function (EndSensitivity) {
|
|
1741
|
+
EndSensitivity["END_SENSITIVITY_UNSPECIFIED"] = "END_SENSITIVITY_UNSPECIFIED";
|
|
1742
|
+
EndSensitivity["END_SENSITIVITY_HIGH"] = "END_SENSITIVITY_HIGH";
|
|
1743
|
+
EndSensitivity["END_SENSITIVITY_LOW"] = "END_SENSITIVITY_LOW";
|
|
1744
|
+
})(exports.EndSensitivity || (exports.EndSensitivity = {}));
|
|
1745
|
+
/** The different ways of handling user activity. */
|
|
1746
|
+
exports.ActivityHandling = void 0;
|
|
1747
|
+
(function (ActivityHandling) {
|
|
1748
|
+
ActivityHandling["ACTIVITY_HANDLING_UNSPECIFIED"] = "ACTIVITY_HANDLING_UNSPECIFIED";
|
|
1749
|
+
ActivityHandling["START_OF_ACTIVITY_INTERRUPTS"] = "START_OF_ACTIVITY_INTERRUPTS";
|
|
1750
|
+
ActivityHandling["NO_INTERRUPTION"] = "NO_INTERRUPTION";
|
|
1751
|
+
})(exports.ActivityHandling || (exports.ActivityHandling = {}));
|
|
1752
|
+
/** Options about which input is included in the user's turn. */
|
|
1753
|
+
exports.TurnCoverage = void 0;
|
|
1754
|
+
(function (TurnCoverage) {
|
|
1755
|
+
TurnCoverage["TURN_COVERAGE_UNSPECIFIED"] = "TURN_COVERAGE_UNSPECIFIED";
|
|
1756
|
+
TurnCoverage["TURN_INCLUDES_ONLY_ACTIVITY"] = "TURN_INCLUDES_ONLY_ACTIVITY";
|
|
1757
|
+
TurnCoverage["TURN_INCLUDES_ALL_INPUT"] = "TURN_INCLUDES_ALL_INPUT";
|
|
1758
|
+
})(exports.TurnCoverage || (exports.TurnCoverage = {}));
|
|
1703
1759
|
/** A function response. */
|
|
1704
1760
|
class FunctionResponse {
|
|
1705
1761
|
}
|
|
@@ -1746,7 +1802,7 @@ function createPartFromFunctionResponse(id, name, response) {
|
|
|
1746
1802
|
};
|
|
1747
1803
|
}
|
|
1748
1804
|
/**
|
|
1749
|
-
* Creates a `Part` object from a `base64` `string`.
|
|
1805
|
+
* Creates a `Part` object from a `base64` encoded `string`.
|
|
1750
1806
|
*/
|
|
1751
1807
|
function createPartFromBase64(data, mimeType) {
|
|
1752
1808
|
return {
|
|
@@ -2825,9 +2881,10 @@ class Chat {
|
|
|
2825
2881
|
* SPDX-License-Identifier: Apache-2.0
|
|
2826
2882
|
*/
|
|
2827
2883
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
2884
|
+
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2828
2885
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2829
2886
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2830
|
-
const SDK_VERSION = '0.
|
|
2887
|
+
const SDK_VERSION = '0.8.0'; // x-release-please-version
|
|
2831
2888
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2832
2889
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2833
2890
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2967,11 +3024,9 @@ class ApiClient {
|
|
|
2967
3024
|
throw new Error('HTTP options are not correctly set.');
|
|
2968
3025
|
}
|
|
2969
3026
|
}
|
|
2970
|
-
constructUrl(path, httpOptions) {
|
|
3027
|
+
constructUrl(path, httpOptions, prependProjectLocation) {
|
|
2971
3028
|
const urlElement = [this.getRequestUrlInternal(httpOptions)];
|
|
2972
|
-
if (
|
|
2973
|
-
!this.clientOptions.apiKey &&
|
|
2974
|
-
!path.startsWith('projects/')) {
|
|
3029
|
+
if (prependProjectLocation) {
|
|
2975
3030
|
urlElement.push(this.getBaseResourcePath());
|
|
2976
3031
|
}
|
|
2977
3032
|
if (path !== '') {
|
|
@@ -2980,12 +3035,34 @@ class ApiClient {
|
|
|
2980
3035
|
const url = new URL(`${urlElement.join('/')}`);
|
|
2981
3036
|
return url;
|
|
2982
3037
|
}
|
|
3038
|
+
shouldPrependVertexProjectPath(request) {
|
|
3039
|
+
if (this.clientOptions.apiKey) {
|
|
3040
|
+
return false;
|
|
3041
|
+
}
|
|
3042
|
+
if (!this.clientOptions.vertexai) {
|
|
3043
|
+
return false;
|
|
3044
|
+
}
|
|
3045
|
+
if (request.path.startsWith('projects/')) {
|
|
3046
|
+
// Assume the path already starts with
|
|
3047
|
+
// `projects/<project>/location/<location>`.
|
|
3048
|
+
return false;
|
|
3049
|
+
}
|
|
3050
|
+
if (request.httpMethod === 'GET' &&
|
|
3051
|
+
request.path.startsWith('publishers/google/models')) {
|
|
3052
|
+
// These paths are used by Vertex's models.get and models.list
|
|
3053
|
+
// calls. For base models Vertex does not accept a project/location
|
|
3054
|
+
// prefix (for tuned model the prefix is required).
|
|
3055
|
+
return false;
|
|
3056
|
+
}
|
|
3057
|
+
return true;
|
|
3058
|
+
}
|
|
2983
3059
|
async request(request) {
|
|
2984
3060
|
let patchedHttpOptions = this.clientOptions.httpOptions;
|
|
2985
3061
|
if (request.httpOptions) {
|
|
2986
3062
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
2987
3063
|
}
|
|
2988
|
-
const
|
|
3064
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3065
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
2989
3066
|
if (request.queryParams) {
|
|
2990
3067
|
for (const [key, value] of Object.entries(request.queryParams)) {
|
|
2991
3068
|
url.searchParams.append(key, String(value));
|
|
@@ -3027,7 +3104,8 @@ class ApiClient {
|
|
|
3027
3104
|
if (request.httpOptions) {
|
|
3028
3105
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
3029
3106
|
}
|
|
3030
|
-
const
|
|
3107
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3108
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
3031
3109
|
if (!url.searchParams.has('alt') || url.searchParams.get('alt') !== 'sse') {
|
|
3032
3110
|
url.searchParams.set('alt', 'sse');
|
|
3033
3111
|
}
|
|
@@ -3135,6 +3213,11 @@ class ApiClient {
|
|
|
3135
3213
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
3136
3214
|
headers.append(key, value);
|
|
3137
3215
|
}
|
|
3216
|
+
// Append a timeout header if it is set, note that the timeout option is
|
|
3217
|
+
// in milliseconds but the header is in seconds.
|
|
3218
|
+
if (httpOptions.timeout && httpOptions.timeout > 0) {
|
|
3219
|
+
headers.append(SERVER_TIMEOUT_HEADER, String(Math.ceil(httpOptions.timeout / 1000)));
|
|
3220
|
+
}
|
|
3138
3221
|
}
|
|
3139
3222
|
await this.clientOptions.auth.addAuthHeaders(headers);
|
|
3140
3223
|
return headers;
|
|
@@ -3649,7 +3732,9 @@ class Files extends BaseModule {
|
|
|
3649
3732
|
* This section can contain multiple paragraphs and code examples.
|
|
3650
3733
|
*
|
|
3651
3734
|
* @param params - Optional parameters specified in the
|
|
3652
|
-
* `
|
|
3735
|
+
* `types.UploadFileParameters` interface.
|
|
3736
|
+
* @see {@link types.UploadFileParameters#config} for the optional
|
|
3737
|
+
* config in the parameters.
|
|
3653
3738
|
* @return A promise that resolves to a `types.File` object.
|
|
3654
3739
|
* @throws An error if called on a Vertex AI client.
|
|
3655
3740
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -4153,6 +4238,12 @@ function thinkingConfigToMldev(apiClient, fromObject) {
|
|
|
4153
4238
|
if (fromIncludeThoughts != null) {
|
|
4154
4239
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4155
4240
|
}
|
|
4241
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
4242
|
+
'thinkingBudget',
|
|
4243
|
+
]);
|
|
4244
|
+
if (fromThinkingBudget != null) {
|
|
4245
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
4246
|
+
}
|
|
4156
4247
|
return toObject;
|
|
4157
4248
|
}
|
|
4158
4249
|
function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
@@ -4456,6 +4547,18 @@ function generateImagesParametersToMldev(apiClient, fromObject) {
|
|
|
4456
4547
|
}
|
|
4457
4548
|
return toObject;
|
|
4458
4549
|
}
|
|
4550
|
+
function getModelParametersToMldev(apiClient, fromObject) {
|
|
4551
|
+
const toObject = {};
|
|
4552
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
4553
|
+
if (fromModel != null) {
|
|
4554
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
4555
|
+
}
|
|
4556
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
4557
|
+
if (fromConfig != null) {
|
|
4558
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
4559
|
+
}
|
|
4560
|
+
return toObject;
|
|
4561
|
+
}
|
|
4459
4562
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
4460
4563
|
const toObject = {};
|
|
4461
4564
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -4901,6 +5004,12 @@ function thinkingConfigToVertex(apiClient, fromObject) {
|
|
|
4901
5004
|
if (fromIncludeThoughts != null) {
|
|
4902
5005
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4903
5006
|
}
|
|
5007
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
5008
|
+
'thinkingBudget',
|
|
5009
|
+
]);
|
|
5010
|
+
if (fromThinkingBudget != null) {
|
|
5011
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
5012
|
+
}
|
|
4904
5013
|
return toObject;
|
|
4905
5014
|
}
|
|
4906
5015
|
function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
@@ -5218,6 +5327,18 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
|
|
|
5218
5327
|
}
|
|
5219
5328
|
return toObject;
|
|
5220
5329
|
}
|
|
5330
|
+
function getModelParametersToVertex(apiClient, fromObject) {
|
|
5331
|
+
const toObject = {};
|
|
5332
|
+
const fromModel = getValueByPath(fromObject, ['model']);
|
|
5333
|
+
if (fromModel != null) {
|
|
5334
|
+
setValueByPath(toObject, ['_url', 'name'], tModel(apiClient, fromModel));
|
|
5335
|
+
}
|
|
5336
|
+
const fromConfig = getValueByPath(fromObject, ['config']);
|
|
5337
|
+
if (fromConfig != null) {
|
|
5338
|
+
setValueByPath(toObject, ['config'], fromConfig);
|
|
5339
|
+
}
|
|
5340
|
+
return toObject;
|
|
5341
|
+
}
|
|
5221
5342
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5222
5343
|
const toObject = {};
|
|
5223
5344
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -5641,6 +5762,64 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
5641
5762
|
}
|
|
5642
5763
|
return toObject;
|
|
5643
5764
|
}
|
|
5765
|
+
function tunedModelInfoFromMldev(apiClient, fromObject) {
|
|
5766
|
+
const toObject = {};
|
|
5767
|
+
const fromBaseModel = getValueByPath(fromObject, ['baseModel']);
|
|
5768
|
+
if (fromBaseModel != null) {
|
|
5769
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
5770
|
+
}
|
|
5771
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
5772
|
+
if (fromCreateTime != null) {
|
|
5773
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
5774
|
+
}
|
|
5775
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
5776
|
+
if (fromUpdateTime != null) {
|
|
5777
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
5778
|
+
}
|
|
5779
|
+
return toObject;
|
|
5780
|
+
}
|
|
5781
|
+
function modelFromMldev(apiClient, fromObject) {
|
|
5782
|
+
const toObject = {};
|
|
5783
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
5784
|
+
if (fromName != null) {
|
|
5785
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
5786
|
+
}
|
|
5787
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
5788
|
+
if (fromDisplayName != null) {
|
|
5789
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
5790
|
+
}
|
|
5791
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
5792
|
+
if (fromDescription != null) {
|
|
5793
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
5794
|
+
}
|
|
5795
|
+
const fromVersion = getValueByPath(fromObject, ['version']);
|
|
5796
|
+
if (fromVersion != null) {
|
|
5797
|
+
setValueByPath(toObject, ['version'], fromVersion);
|
|
5798
|
+
}
|
|
5799
|
+
const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
|
|
5800
|
+
if (fromTunedModelInfo != null) {
|
|
5801
|
+
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromMldev(apiClient, fromTunedModelInfo));
|
|
5802
|
+
}
|
|
5803
|
+
const fromInputTokenLimit = getValueByPath(fromObject, [
|
|
5804
|
+
'inputTokenLimit',
|
|
5805
|
+
]);
|
|
5806
|
+
if (fromInputTokenLimit != null) {
|
|
5807
|
+
setValueByPath(toObject, ['inputTokenLimit'], fromInputTokenLimit);
|
|
5808
|
+
}
|
|
5809
|
+
const fromOutputTokenLimit = getValueByPath(fromObject, [
|
|
5810
|
+
'outputTokenLimit',
|
|
5811
|
+
]);
|
|
5812
|
+
if (fromOutputTokenLimit != null) {
|
|
5813
|
+
setValueByPath(toObject, ['outputTokenLimit'], fromOutputTokenLimit);
|
|
5814
|
+
}
|
|
5815
|
+
const fromSupportedActions = getValueByPath(fromObject, [
|
|
5816
|
+
'supportedGenerationMethods',
|
|
5817
|
+
]);
|
|
5818
|
+
if (fromSupportedActions != null) {
|
|
5819
|
+
setValueByPath(toObject, ['supportedActions'], fromSupportedActions);
|
|
5820
|
+
}
|
|
5821
|
+
return toObject;
|
|
5822
|
+
}
|
|
5644
5823
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
5645
5824
|
const toObject = {};
|
|
5646
5825
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -5729,9 +5908,12 @@ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
|
|
|
5729
5908
|
if (fromError != null) {
|
|
5730
5909
|
setValueByPath(toObject, ['error'], fromError);
|
|
5731
5910
|
}
|
|
5732
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
5911
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
5912
|
+
'response',
|
|
5913
|
+
'generateVideoResponse',
|
|
5914
|
+
]);
|
|
5733
5915
|
if (fromResponse != null) {
|
|
5734
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
5916
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(apiClient, fromResponse));
|
|
5735
5917
|
}
|
|
5736
5918
|
const fromResult = getValueByPath(fromObject, [
|
|
5737
5919
|
'response',
|
|
@@ -6047,6 +6229,78 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
6047
6229
|
}
|
|
6048
6230
|
return toObject;
|
|
6049
6231
|
}
|
|
6232
|
+
function endpointFromVertex(apiClient, fromObject) {
|
|
6233
|
+
const toObject = {};
|
|
6234
|
+
const fromName = getValueByPath(fromObject, ['endpoint']);
|
|
6235
|
+
if (fromName != null) {
|
|
6236
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
6237
|
+
}
|
|
6238
|
+
const fromDeployedModelId = getValueByPath(fromObject, [
|
|
6239
|
+
'deployedModelId',
|
|
6240
|
+
]);
|
|
6241
|
+
if (fromDeployedModelId != null) {
|
|
6242
|
+
setValueByPath(toObject, ['deployedModelId'], fromDeployedModelId);
|
|
6243
|
+
}
|
|
6244
|
+
return toObject;
|
|
6245
|
+
}
|
|
6246
|
+
function tunedModelInfoFromVertex(apiClient, fromObject) {
|
|
6247
|
+
const toObject = {};
|
|
6248
|
+
const fromBaseModel = getValueByPath(fromObject, [
|
|
6249
|
+
'labels',
|
|
6250
|
+
'google-vertex-llm-tuning-base-model-id',
|
|
6251
|
+
]);
|
|
6252
|
+
if (fromBaseModel != null) {
|
|
6253
|
+
setValueByPath(toObject, ['baseModel'], fromBaseModel);
|
|
6254
|
+
}
|
|
6255
|
+
const fromCreateTime = getValueByPath(fromObject, ['createTime']);
|
|
6256
|
+
if (fromCreateTime != null) {
|
|
6257
|
+
setValueByPath(toObject, ['createTime'], fromCreateTime);
|
|
6258
|
+
}
|
|
6259
|
+
const fromUpdateTime = getValueByPath(fromObject, ['updateTime']);
|
|
6260
|
+
if (fromUpdateTime != null) {
|
|
6261
|
+
setValueByPath(toObject, ['updateTime'], fromUpdateTime);
|
|
6262
|
+
}
|
|
6263
|
+
return toObject;
|
|
6264
|
+
}
|
|
6265
|
+
function modelFromVertex(apiClient, fromObject) {
|
|
6266
|
+
const toObject = {};
|
|
6267
|
+
const fromName = getValueByPath(fromObject, ['name']);
|
|
6268
|
+
if (fromName != null) {
|
|
6269
|
+
setValueByPath(toObject, ['name'], fromName);
|
|
6270
|
+
}
|
|
6271
|
+
const fromDisplayName = getValueByPath(fromObject, ['displayName']);
|
|
6272
|
+
if (fromDisplayName != null) {
|
|
6273
|
+
setValueByPath(toObject, ['displayName'], fromDisplayName);
|
|
6274
|
+
}
|
|
6275
|
+
const fromDescription = getValueByPath(fromObject, ['description']);
|
|
6276
|
+
if (fromDescription != null) {
|
|
6277
|
+
setValueByPath(toObject, ['description'], fromDescription);
|
|
6278
|
+
}
|
|
6279
|
+
const fromVersion = getValueByPath(fromObject, ['versionId']);
|
|
6280
|
+
if (fromVersion != null) {
|
|
6281
|
+
setValueByPath(toObject, ['version'], fromVersion);
|
|
6282
|
+
}
|
|
6283
|
+
const fromEndpoints = getValueByPath(fromObject, ['deployedModels']);
|
|
6284
|
+
if (fromEndpoints != null) {
|
|
6285
|
+
if (Array.isArray(fromEndpoints)) {
|
|
6286
|
+
setValueByPath(toObject, ['endpoints'], fromEndpoints.map((item) => {
|
|
6287
|
+
return endpointFromVertex(apiClient, item);
|
|
6288
|
+
}));
|
|
6289
|
+
}
|
|
6290
|
+
else {
|
|
6291
|
+
setValueByPath(toObject, ['endpoints'], fromEndpoints);
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
const fromLabels = getValueByPath(fromObject, ['labels']);
|
|
6295
|
+
if (fromLabels != null) {
|
|
6296
|
+
setValueByPath(toObject, ['labels'], fromLabels);
|
|
6297
|
+
}
|
|
6298
|
+
const fromTunedModelInfo = getValueByPath(fromObject, ['_self']);
|
|
6299
|
+
if (fromTunedModelInfo != null) {
|
|
6300
|
+
setValueByPath(toObject, ['tunedModelInfo'], tunedModelInfoFromVertex(apiClient, fromTunedModelInfo));
|
|
6301
|
+
}
|
|
6302
|
+
return toObject;
|
|
6303
|
+
}
|
|
6050
6304
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
6051
6305
|
const toObject = {};
|
|
6052
6306
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6136,7 +6390,7 @@ function generateVideosOperationFromVertex$1(apiClient, fromObject) {
|
|
|
6136
6390
|
}
|
|
6137
6391
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6138
6392
|
if (fromResponse != null) {
|
|
6139
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
6393
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(apiClient, fromResponse));
|
|
6140
6394
|
}
|
|
6141
6395
|
const fromResult = getValueByPath(fromObject, ['response']);
|
|
6142
6396
|
if (fromResult != null) {
|
|
@@ -6202,6 +6456,23 @@ function liveServerMessageFromMldev(apiClient, fromObject) {
|
|
|
6202
6456
|
fromToolCallCancellation !== null) {
|
|
6203
6457
|
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromMldev(apiClient, fromToolCallCancellation));
|
|
6204
6458
|
}
|
|
6459
|
+
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
6460
|
+
'usageMetadata',
|
|
6461
|
+
]);
|
|
6462
|
+
if (fromUsageMetadata != undefined && fromUsageMetadata != null) {
|
|
6463
|
+
setValueByPath(toObject, ['usageMetadata'], usageMetadataFromMldev(apiClient, fromUsageMetadata));
|
|
6464
|
+
}
|
|
6465
|
+
const fromGoAway = getValueByPath(fromObject, ['goAway']);
|
|
6466
|
+
if (fromGoAway !== undefined && fromGoAway !== null) {
|
|
6467
|
+
setValueByPath(toObject, ['goAway'], liveServerGoAwayFromMldev(fromGoAway));
|
|
6468
|
+
}
|
|
6469
|
+
const fromSessionResumptionUpdate = getValueByPath(fromObject, [
|
|
6470
|
+
'sessionResumptionUpdate',
|
|
6471
|
+
]);
|
|
6472
|
+
if (fromSessionResumptionUpdate !== undefined &&
|
|
6473
|
+
fromSessionResumptionUpdate !== null) {
|
|
6474
|
+
setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromMldev(fromSessionResumptionUpdate));
|
|
6475
|
+
}
|
|
6205
6476
|
return toObject;
|
|
6206
6477
|
}
|
|
6207
6478
|
function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
@@ -6229,6 +6500,181 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
|
6229
6500
|
fromToolCallCancellation !== null) {
|
|
6230
6501
|
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromVertex(apiClient, fromToolCallCancellation));
|
|
6231
6502
|
}
|
|
6503
|
+
const fromGoAway = getValueByPath(fromObject, ['goAway']);
|
|
6504
|
+
if (fromGoAway !== undefined && fromGoAway !== null) {
|
|
6505
|
+
setValueByPath(toObject, ['goAway'], liveServerGoAwayFromVertex(fromGoAway));
|
|
6506
|
+
}
|
|
6507
|
+
const fromSessionResumptionUpdate = getValueByPath(fromObject, [
|
|
6508
|
+
'sessionResumptionUpdate',
|
|
6509
|
+
]);
|
|
6510
|
+
if (fromSessionResumptionUpdate !== undefined &&
|
|
6511
|
+
fromSessionResumptionUpdate !== null) {
|
|
6512
|
+
setValueByPath(toObject, ['sessionResumptionUpdate'], liveServerSessionResumptionUpdateFromVertex(fromSessionResumptionUpdate));
|
|
6513
|
+
}
|
|
6514
|
+
const fromUsageMetadata = getValueByPath(fromObject, [
|
|
6515
|
+
'usageMetadata',
|
|
6516
|
+
]);
|
|
6517
|
+
if (fromUsageMetadata != undefined && fromUsageMetadata != null) {
|
|
6518
|
+
setValueByPath(toObject, ['usageMetadata'], usageMetadataFromVertex(apiClient, fromUsageMetadata));
|
|
6519
|
+
}
|
|
6520
|
+
return toObject;
|
|
6521
|
+
}
|
|
6522
|
+
function slidingWindowToMldev(fromObject) {
|
|
6523
|
+
const toObject = {};
|
|
6524
|
+
const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
|
|
6525
|
+
if (fromTargetTokens !== undefined && fromTargetTokens !== null) {
|
|
6526
|
+
setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
|
|
6527
|
+
}
|
|
6528
|
+
return toObject;
|
|
6529
|
+
}
|
|
6530
|
+
function slidingWindowToVertex(fromObject) {
|
|
6531
|
+
const toObject = {};
|
|
6532
|
+
const fromTargetTokens = getValueByPath(fromObject, ['targetTokens']);
|
|
6533
|
+
if (fromTargetTokens !== undefined && fromTargetTokens !== null) {
|
|
6534
|
+
setValueByPath(toObject, ['targetTokens'], fromTargetTokens);
|
|
6535
|
+
}
|
|
6536
|
+
return toObject;
|
|
6537
|
+
}
|
|
6538
|
+
function contextWindowCompressionToMldev(fromObject) {
|
|
6539
|
+
const toObject = {};
|
|
6540
|
+
const fromTriggerTokens = getValueByPath(fromObject, [
|
|
6541
|
+
'triggerTokens',
|
|
6542
|
+
]);
|
|
6543
|
+
if (fromTriggerTokens !== undefined && fromTriggerTokens !== null) {
|
|
6544
|
+
setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
|
|
6545
|
+
}
|
|
6546
|
+
const fromSlidingWindow = getValueByPath(fromObject, [
|
|
6547
|
+
'slidingWindow',
|
|
6548
|
+
]);
|
|
6549
|
+
if (fromSlidingWindow !== undefined && fromSlidingWindow !== null) {
|
|
6550
|
+
setValueByPath(toObject, ['slidingWindow'], slidingWindowToMldev(fromSlidingWindow));
|
|
6551
|
+
}
|
|
6552
|
+
return toObject;
|
|
6553
|
+
}
|
|
6554
|
+
function contextWindowCompressionToVertex(fromObject) {
|
|
6555
|
+
const toObject = {};
|
|
6556
|
+
const fromTriggerTokens = getValueByPath(fromObject, [
|
|
6557
|
+
'triggerTokens',
|
|
6558
|
+
]);
|
|
6559
|
+
if (fromTriggerTokens !== undefined && fromTriggerTokens !== null) {
|
|
6560
|
+
setValueByPath(toObject, ['triggerTokens'], fromTriggerTokens);
|
|
6561
|
+
}
|
|
6562
|
+
const fromSlidingWindow = getValueByPath(fromObject, [
|
|
6563
|
+
'slidingWindow',
|
|
6564
|
+
]);
|
|
6565
|
+
if (fromSlidingWindow !== undefined && fromSlidingWindow !== null) {
|
|
6566
|
+
setValueByPath(toObject, ['slidingWindow'], slidingWindowToVertex(fromSlidingWindow));
|
|
6567
|
+
}
|
|
6568
|
+
return toObject;
|
|
6569
|
+
}
|
|
6570
|
+
function automaticActivityDetectionToMldev(fromObject) {
|
|
6571
|
+
const toObject = {};
|
|
6572
|
+
const fromDisabled = getValueByPath(fromObject, ['disabled']);
|
|
6573
|
+
if (fromDisabled !== undefined && fromDisabled !== null) {
|
|
6574
|
+
setValueByPath(toObject, ['disabled'], fromDisabled);
|
|
6575
|
+
}
|
|
6576
|
+
const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6577
|
+
'startOfSpeechSensitivity',
|
|
6578
|
+
]);
|
|
6579
|
+
if (fromStartOfSpeechSensitivity !== undefined &&
|
|
6580
|
+
fromStartOfSpeechSensitivity !== null) {
|
|
6581
|
+
setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
|
|
6582
|
+
}
|
|
6583
|
+
const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6584
|
+
'endOfSpeechSensitivity',
|
|
6585
|
+
]);
|
|
6586
|
+
if (fromEndOfSpeechSensitivity !== undefined &&
|
|
6587
|
+
fromEndOfSpeechSensitivity !== null) {
|
|
6588
|
+
setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
|
|
6589
|
+
}
|
|
6590
|
+
const fromPrefixPaddingMs = getValueByPath(fromObject, [
|
|
6591
|
+
'prefixPaddingMs',
|
|
6592
|
+
]);
|
|
6593
|
+
if (fromPrefixPaddingMs !== undefined && fromPrefixPaddingMs !== null) {
|
|
6594
|
+
setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
|
|
6595
|
+
}
|
|
6596
|
+
const fromSilenceDurationMs = getValueByPath(fromObject, [
|
|
6597
|
+
'silenceDurationMs',
|
|
6598
|
+
]);
|
|
6599
|
+
if (fromSilenceDurationMs !== undefined && fromSilenceDurationMs !== null) {
|
|
6600
|
+
setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
|
|
6601
|
+
}
|
|
6602
|
+
return toObject;
|
|
6603
|
+
}
|
|
6604
|
+
function automaticActivityDetectionToVertex(fromObject) {
|
|
6605
|
+
const toObject = {};
|
|
6606
|
+
const fromDisabled = getValueByPath(fromObject, ['disabled']);
|
|
6607
|
+
if (fromDisabled !== undefined && fromDisabled !== null) {
|
|
6608
|
+
setValueByPath(toObject, ['disabled'], fromDisabled);
|
|
6609
|
+
}
|
|
6610
|
+
const fromStartOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6611
|
+
'startOfSpeechSensitivity',
|
|
6612
|
+
]);
|
|
6613
|
+
if (fromStartOfSpeechSensitivity !== undefined &&
|
|
6614
|
+
fromStartOfSpeechSensitivity !== null) {
|
|
6615
|
+
setValueByPath(toObject, ['startOfSpeechSensitivity'], fromStartOfSpeechSensitivity);
|
|
6616
|
+
}
|
|
6617
|
+
const fromEndOfSpeechSensitivity = getValueByPath(fromObject, [
|
|
6618
|
+
'endOfSpeechSensitivity',
|
|
6619
|
+
]);
|
|
6620
|
+
if (fromEndOfSpeechSensitivity !== undefined &&
|
|
6621
|
+
fromEndOfSpeechSensitivity !== null) {
|
|
6622
|
+
setValueByPath(toObject, ['endOfSpeechSensitivity'], fromEndOfSpeechSensitivity);
|
|
6623
|
+
}
|
|
6624
|
+
const fromPrefixPaddingMs = getValueByPath(fromObject, [
|
|
6625
|
+
'prefixPaddingMs',
|
|
6626
|
+
]);
|
|
6627
|
+
if (fromPrefixPaddingMs !== undefined && fromPrefixPaddingMs !== null) {
|
|
6628
|
+
setValueByPath(toObject, ['prefixPaddingMs'], fromPrefixPaddingMs);
|
|
6629
|
+
}
|
|
6630
|
+
const fromSilenceDurationMs = getValueByPath(fromObject, [
|
|
6631
|
+
'silenceDurationMs',
|
|
6632
|
+
]);
|
|
6633
|
+
if (fromSilenceDurationMs !== undefined && fromSilenceDurationMs !== null) {
|
|
6634
|
+
setValueByPath(toObject, ['silenceDurationMs'], fromSilenceDurationMs);
|
|
6635
|
+
}
|
|
6636
|
+
return toObject;
|
|
6637
|
+
}
|
|
6638
|
+
function realtimeInputConfigToMldev(fromObject) {
|
|
6639
|
+
const toObject = {};
|
|
6640
|
+
const fromAutomaticActivityDetection = getValueByPath(fromObject, [
|
|
6641
|
+
'automaticActivityDetection',
|
|
6642
|
+
]);
|
|
6643
|
+
if (fromAutomaticActivityDetection !== undefined &&
|
|
6644
|
+
fromAutomaticActivityDetection !== null) {
|
|
6645
|
+
setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToMldev(fromAutomaticActivityDetection));
|
|
6646
|
+
}
|
|
6647
|
+
const fromActivityHandling = getValueByPath(fromObject, [
|
|
6648
|
+
'activityHandling',
|
|
6649
|
+
]);
|
|
6650
|
+
if (fromActivityHandling !== undefined && fromActivityHandling !== null) {
|
|
6651
|
+
setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
|
|
6652
|
+
}
|
|
6653
|
+
const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
|
|
6654
|
+
if (fromTurnCoverage !== undefined && fromTurnCoverage !== null) {
|
|
6655
|
+
setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
|
|
6656
|
+
}
|
|
6657
|
+
return toObject;
|
|
6658
|
+
}
|
|
6659
|
+
function realtimeInputConfigToVertex(fromObject) {
|
|
6660
|
+
const toObject = {};
|
|
6661
|
+
const fromAutomaticActivityDetection = getValueByPath(fromObject, [
|
|
6662
|
+
'automaticActivityDetection',
|
|
6663
|
+
]);
|
|
6664
|
+
if (fromAutomaticActivityDetection !== undefined &&
|
|
6665
|
+
fromAutomaticActivityDetection !== null) {
|
|
6666
|
+
setValueByPath(toObject, ['automaticActivityDetection'], automaticActivityDetectionToVertex(fromAutomaticActivityDetection));
|
|
6667
|
+
}
|
|
6668
|
+
const fromActivityHandling = getValueByPath(fromObject, [
|
|
6669
|
+
'activityHandling',
|
|
6670
|
+
]);
|
|
6671
|
+
if (fromActivityHandling !== undefined && fromActivityHandling !== null) {
|
|
6672
|
+
setValueByPath(toObject, ['activityHandling'], fromActivityHandling);
|
|
6673
|
+
}
|
|
6674
|
+
const fromTurnCoverage = getValueByPath(fromObject, ['turnCoverage']);
|
|
6675
|
+
if (fromTurnCoverage !== undefined && fromTurnCoverage !== null) {
|
|
6676
|
+
setValueByPath(toObject, ['turnCoverage'], fromTurnCoverage);
|
|
6677
|
+
}
|
|
6232
6678
|
return toObject;
|
|
6233
6679
|
}
|
|
6234
6680
|
function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
@@ -6263,6 +6709,26 @@ function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
|
6263
6709
|
return toolToMldev(apiClient, item);
|
|
6264
6710
|
}));
|
|
6265
6711
|
}
|
|
6712
|
+
const fromSessionResumption = getValueByPath(fromObject, [
|
|
6713
|
+
'sessionResumption',
|
|
6714
|
+
]);
|
|
6715
|
+
if (fromSessionResumption !== undefined && fromSessionResumption !== null) {
|
|
6716
|
+
setValueByPath(toObject, ['sessionResumption'], liveClientSessionResumptionConfigToMldev(fromSessionResumption));
|
|
6717
|
+
}
|
|
6718
|
+
const fromContextWindowCompression = getValueByPath(fromObject, [
|
|
6719
|
+
'contextWindowCompression',
|
|
6720
|
+
]);
|
|
6721
|
+
if (fromContextWindowCompression !== undefined &&
|
|
6722
|
+
fromContextWindowCompression !== null) {
|
|
6723
|
+
setValueByPath(toObject, ['contextWindowCompression'], contextWindowCompressionToMldev(fromContextWindowCompression));
|
|
6724
|
+
}
|
|
6725
|
+
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
6726
|
+
'realtimeInputConfig',
|
|
6727
|
+
]);
|
|
6728
|
+
if (fromRealtimeInputConfig !== undefined &&
|
|
6729
|
+
fromRealtimeInputConfig !== null) {
|
|
6730
|
+
setValueByPath(toObject, ['realtimeInputConfig'], realtimeInputConfigToMldev(fromRealtimeInputConfig));
|
|
6731
|
+
}
|
|
6266
6732
|
return toObject;
|
|
6267
6733
|
}
|
|
6268
6734
|
function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
@@ -6301,6 +6767,26 @@ function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
|
6301
6767
|
return toolToVertex(apiClient, item);
|
|
6302
6768
|
}));
|
|
6303
6769
|
}
|
|
6770
|
+
const fromSessionResumption = getValueByPath(fromObject, [
|
|
6771
|
+
'sessionResumption',
|
|
6772
|
+
]);
|
|
6773
|
+
if (fromSessionResumption !== undefined && fromSessionResumption !== null) {
|
|
6774
|
+
setValueByPath(toObject, ['sessionResumption'], liveClientSessionResumptionConfigToVertex(fromSessionResumption));
|
|
6775
|
+
}
|
|
6776
|
+
const fromContextWindowCompression = getValueByPath(fromObject, [
|
|
6777
|
+
'contextWindowCompression',
|
|
6778
|
+
]);
|
|
6779
|
+
if (fromContextWindowCompression !== undefined &&
|
|
6780
|
+
fromContextWindowCompression !== null) {
|
|
6781
|
+
setValueByPath(toObject, ['contextWindowCompression'], contextWindowCompressionToVertex(fromContextWindowCompression));
|
|
6782
|
+
}
|
|
6783
|
+
const fromRealtimeInputConfig = getValueByPath(fromObject, [
|
|
6784
|
+
'realtimeInputConfig',
|
|
6785
|
+
]);
|
|
6786
|
+
if (fromRealtimeInputConfig !== undefined &&
|
|
6787
|
+
fromRealtimeInputConfig !== null) {
|
|
6788
|
+
setValueByPath(toObject, ['realtimeInputConfig'], realtimeInputConfigToVertex(fromRealtimeInputConfig));
|
|
6789
|
+
}
|
|
6304
6790
|
return toObject;
|
|
6305
6791
|
}
|
|
6306
6792
|
function liveServerContentFromMldev(apiClient, fromObject) {
|
|
@@ -6317,6 +6803,12 @@ function liveServerContentFromMldev(apiClient, fromObject) {
|
|
|
6317
6803
|
if (fromInterrupted !== undefined) {
|
|
6318
6804
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
6319
6805
|
}
|
|
6806
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
6807
|
+
'generationComplete',
|
|
6808
|
+
]);
|
|
6809
|
+
if (fromGenerationComplete != null) {
|
|
6810
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
6811
|
+
}
|
|
6320
6812
|
return toObject;
|
|
6321
6813
|
}
|
|
6322
6814
|
function liveServerContentFromVertex(apiClient, fromObject) {
|
|
@@ -6333,6 +6825,12 @@ function liveServerContentFromVertex(apiClient, fromObject) {
|
|
|
6333
6825
|
if (fromInterrupted !== undefined) {
|
|
6334
6826
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
6335
6827
|
}
|
|
6828
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
6829
|
+
'generationComplete',
|
|
6830
|
+
]);
|
|
6831
|
+
if (fromGenerationComplete != null) {
|
|
6832
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
6833
|
+
}
|
|
6336
6834
|
return toObject;
|
|
6337
6835
|
}
|
|
6338
6836
|
function functionCallFromMldev(apiClient, fromObject) {
|
|
@@ -6407,6 +6905,293 @@ function liveServerToolCallCancellationFromVertex(apiClient, fromObject) {
|
|
|
6407
6905
|
}
|
|
6408
6906
|
return toObject;
|
|
6409
6907
|
}
|
|
6908
|
+
function liveServerGoAwayFromMldev(fromObject) {
|
|
6909
|
+
const toObject = {};
|
|
6910
|
+
const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
|
|
6911
|
+
if (fromTimeLeft !== undefined) {
|
|
6912
|
+
setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
|
|
6913
|
+
}
|
|
6914
|
+
return toObject;
|
|
6915
|
+
}
|
|
6916
|
+
function liveServerGoAwayFromVertex(fromObject) {
|
|
6917
|
+
const toObject = {};
|
|
6918
|
+
const fromTimeLeft = getValueByPath(fromObject, ['timeLeft']);
|
|
6919
|
+
if (fromTimeLeft !== undefined) {
|
|
6920
|
+
setValueByPath(toObject, ['timeLeft'], fromTimeLeft);
|
|
6921
|
+
}
|
|
6922
|
+
return toObject;
|
|
6923
|
+
}
|
|
6924
|
+
function liveServerSessionResumptionUpdateFromMldev(fromObject) {
|
|
6925
|
+
const toObject = {};
|
|
6926
|
+
const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
|
|
6927
|
+
if (fromNewHandle !== undefined) {
|
|
6928
|
+
setValueByPath(toObject, ['newHandle'], fromNewHandle);
|
|
6929
|
+
}
|
|
6930
|
+
const fromResumable = getValueByPath(fromObject, ['resumable']);
|
|
6931
|
+
if (fromResumable !== undefined) {
|
|
6932
|
+
setValueByPath(toObject, ['resumable'], fromResumable);
|
|
6933
|
+
}
|
|
6934
|
+
const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
|
|
6935
|
+
'lastConsumedClientMessageIndex',
|
|
6936
|
+
]);
|
|
6937
|
+
if (fromLastConsumedClientMessageIndex !== undefined) {
|
|
6938
|
+
setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
|
|
6939
|
+
}
|
|
6940
|
+
return toObject;
|
|
6941
|
+
}
|
|
6942
|
+
function liveServerSessionResumptionUpdateFromVertex(fromObject) {
|
|
6943
|
+
const toObject = {};
|
|
6944
|
+
const fromNewHandle = getValueByPath(fromObject, ['newHandle']);
|
|
6945
|
+
if (fromNewHandle !== undefined) {
|
|
6946
|
+
setValueByPath(toObject, ['newHandle'], fromNewHandle);
|
|
6947
|
+
}
|
|
6948
|
+
const fromResumable = getValueByPath(fromObject, ['resumable']);
|
|
6949
|
+
if (fromResumable !== undefined) {
|
|
6950
|
+
setValueByPath(toObject, ['resumable'], fromResumable);
|
|
6951
|
+
}
|
|
6952
|
+
const fromLastConsumedClientMessageIndex = getValueByPath(fromObject, [
|
|
6953
|
+
'lastConsumedClientMessageIndex',
|
|
6954
|
+
]);
|
|
6955
|
+
if (fromLastConsumedClientMessageIndex !== undefined) {
|
|
6956
|
+
setValueByPath(toObject, ['lastConsumedClientMessageIndex'], fromLastConsumedClientMessageIndex);
|
|
6957
|
+
}
|
|
6958
|
+
return toObject;
|
|
6959
|
+
}
|
|
6960
|
+
function liveClientSessionResumptionConfigToMldev(fromObject) {
|
|
6961
|
+
const toObject = {};
|
|
6962
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
6963
|
+
if (fromHandle !== undefined) {
|
|
6964
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
6965
|
+
}
|
|
6966
|
+
if (getValueByPath(fromObject, ['transparent']) !== undefined) {
|
|
6967
|
+
throw new Error('transparent parameter is not supported in Gemini API.');
|
|
6968
|
+
}
|
|
6969
|
+
return toObject;
|
|
6970
|
+
}
|
|
6971
|
+
function liveClientSessionResumptionConfigToVertex(fromObject) {
|
|
6972
|
+
const toObject = {};
|
|
6973
|
+
const fromHandle = getValueByPath(fromObject, ['handle']);
|
|
6974
|
+
if (fromHandle !== undefined) {
|
|
6975
|
+
setValueByPath(toObject, ['handle'], fromHandle);
|
|
6976
|
+
}
|
|
6977
|
+
const fromTransparent = getValueByPath(fromObject, ['transparent']);
|
|
6978
|
+
if (fromTransparent !== undefined) {
|
|
6979
|
+
setValueByPath(toObject, ['transparent'], fromTransparent);
|
|
6980
|
+
}
|
|
6981
|
+
return toObject;
|
|
6982
|
+
}
|
|
6983
|
+
function modalityTokenCountFromMldev(apiClient, fromObject) {
|
|
6984
|
+
const toObject = {};
|
|
6985
|
+
const fromModality = getValueByPath(fromObject, ['modality']);
|
|
6986
|
+
if (fromModality != null) {
|
|
6987
|
+
setValueByPath(toObject, ['modality'], fromModality);
|
|
6988
|
+
}
|
|
6989
|
+
const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
|
|
6990
|
+
if (fromTokenCount != null) {
|
|
6991
|
+
setValueByPath(toObject, ['tokenCount'], fromTokenCount);
|
|
6992
|
+
}
|
|
6993
|
+
return toObject;
|
|
6994
|
+
}
|
|
6995
|
+
function usageMetadataFromMldev(apiClient, fromObject) {
|
|
6996
|
+
const toObject = {};
|
|
6997
|
+
const fromPromptTokenCount = getValueByPath(fromObject, [
|
|
6998
|
+
'promptTokenCount',
|
|
6999
|
+
]);
|
|
7000
|
+
if (fromPromptTokenCount != null) {
|
|
7001
|
+
setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
|
|
7002
|
+
}
|
|
7003
|
+
const fromCachedContentTokenCount = getValueByPath(fromObject, [
|
|
7004
|
+
'cachedContentTokenCount',
|
|
7005
|
+
]);
|
|
7006
|
+
if (fromCachedContentTokenCount != null) {
|
|
7007
|
+
setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
|
|
7008
|
+
}
|
|
7009
|
+
const fromResponseTokenCount = getValueByPath(fromObject, [
|
|
7010
|
+
'responseTokenCount',
|
|
7011
|
+
]);
|
|
7012
|
+
if (fromResponseTokenCount != null) {
|
|
7013
|
+
setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
|
|
7014
|
+
}
|
|
7015
|
+
const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
|
|
7016
|
+
'toolUsePromptTokenCount',
|
|
7017
|
+
]);
|
|
7018
|
+
if (fromToolUsePromptTokenCount != null) {
|
|
7019
|
+
setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
|
|
7020
|
+
}
|
|
7021
|
+
const fromThoughtsTokenCount = getValueByPath(fromObject, [
|
|
7022
|
+
'thoughtsTokenCount',
|
|
7023
|
+
]);
|
|
7024
|
+
if (fromThoughtsTokenCount != null) {
|
|
7025
|
+
setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
|
|
7026
|
+
}
|
|
7027
|
+
const fromTotalTokenCount = getValueByPath(fromObject, [
|
|
7028
|
+
'totalTokenCount',
|
|
7029
|
+
]);
|
|
7030
|
+
if (fromTotalTokenCount != null) {
|
|
7031
|
+
setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
|
|
7032
|
+
}
|
|
7033
|
+
const fromPromptTokensDetails = getValueByPath(fromObject, [
|
|
7034
|
+
'promptTokensDetails',
|
|
7035
|
+
]);
|
|
7036
|
+
if (fromPromptTokensDetails != null) {
|
|
7037
|
+
if (Array.isArray(fromPromptTokensDetails)) {
|
|
7038
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
|
|
7039
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7040
|
+
}));
|
|
7041
|
+
}
|
|
7042
|
+
else {
|
|
7043
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
7047
|
+
'cacheTokensDetails',
|
|
7048
|
+
]);
|
|
7049
|
+
if (fromCacheTokensDetails != null) {
|
|
7050
|
+
if (Array.isArray(fromCacheTokensDetails)) {
|
|
7051
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
|
|
7052
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7053
|
+
}));
|
|
7054
|
+
}
|
|
7055
|
+
else {
|
|
7056
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
7057
|
+
}
|
|
7058
|
+
}
|
|
7059
|
+
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
7060
|
+
'responseTokensDetails',
|
|
7061
|
+
]);
|
|
7062
|
+
if (fromResponseTokensDetails != null) {
|
|
7063
|
+
if (Array.isArray(fromResponseTokensDetails)) {
|
|
7064
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
|
|
7065
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7066
|
+
}));
|
|
7067
|
+
}
|
|
7068
|
+
else {
|
|
7069
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
7070
|
+
}
|
|
7071
|
+
}
|
|
7072
|
+
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
7073
|
+
'toolUsePromptTokensDetails',
|
|
7074
|
+
]);
|
|
7075
|
+
if (fromToolUsePromptTokensDetails != null) {
|
|
7076
|
+
if (Array.isArray(fromToolUsePromptTokensDetails)) {
|
|
7077
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
|
|
7078
|
+
return modalityTokenCountFromMldev(apiClient, item);
|
|
7079
|
+
}));
|
|
7080
|
+
}
|
|
7081
|
+
else {
|
|
7082
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
7083
|
+
}
|
|
7084
|
+
}
|
|
7085
|
+
return toObject;
|
|
7086
|
+
}
|
|
7087
|
+
function modalityTokenCountFromVertex(apiClient, fromObject) {
|
|
7088
|
+
const toObject = {};
|
|
7089
|
+
const fromModality = getValueByPath(fromObject, ['modality']);
|
|
7090
|
+
if (fromModality != null) {
|
|
7091
|
+
setValueByPath(toObject, ['modality'], fromModality);
|
|
7092
|
+
}
|
|
7093
|
+
const fromTokenCount = getValueByPath(fromObject, ['tokenCount']);
|
|
7094
|
+
if (fromTokenCount != null) {
|
|
7095
|
+
setValueByPath(toObject, ['tokenCount'], fromTokenCount);
|
|
7096
|
+
}
|
|
7097
|
+
return toObject;
|
|
7098
|
+
}
|
|
7099
|
+
function usageMetadataFromVertex(apiClient, fromObject) {
|
|
7100
|
+
const toObject = {};
|
|
7101
|
+
const fromPromptTokenCount = getValueByPath(fromObject, [
|
|
7102
|
+
'promptTokenCount',
|
|
7103
|
+
]);
|
|
7104
|
+
if (fromPromptTokenCount != null) {
|
|
7105
|
+
setValueByPath(toObject, ['promptTokenCount'], fromPromptTokenCount);
|
|
7106
|
+
}
|
|
7107
|
+
const fromCachedContentTokenCount = getValueByPath(fromObject, [
|
|
7108
|
+
'cachedContentTokenCount',
|
|
7109
|
+
]);
|
|
7110
|
+
if (fromCachedContentTokenCount != null) {
|
|
7111
|
+
setValueByPath(toObject, ['cachedContentTokenCount'], fromCachedContentTokenCount);
|
|
7112
|
+
}
|
|
7113
|
+
const fromResponseTokenCount = getValueByPath(fromObject, [
|
|
7114
|
+
'candidatesTokenCount',
|
|
7115
|
+
]);
|
|
7116
|
+
if (fromResponseTokenCount != null) {
|
|
7117
|
+
setValueByPath(toObject, ['responseTokenCount'], fromResponseTokenCount);
|
|
7118
|
+
}
|
|
7119
|
+
const fromToolUsePromptTokenCount = getValueByPath(fromObject, [
|
|
7120
|
+
'toolUsePromptTokenCount',
|
|
7121
|
+
]);
|
|
7122
|
+
if (fromToolUsePromptTokenCount != null) {
|
|
7123
|
+
setValueByPath(toObject, ['toolUsePromptTokenCount'], fromToolUsePromptTokenCount);
|
|
7124
|
+
}
|
|
7125
|
+
const fromThoughtsTokenCount = getValueByPath(fromObject, [
|
|
7126
|
+
'thoughtsTokenCount',
|
|
7127
|
+
]);
|
|
7128
|
+
if (fromThoughtsTokenCount != null) {
|
|
7129
|
+
setValueByPath(toObject, ['thoughtsTokenCount'], fromThoughtsTokenCount);
|
|
7130
|
+
}
|
|
7131
|
+
const fromTotalTokenCount = getValueByPath(fromObject, [
|
|
7132
|
+
'totalTokenCount',
|
|
7133
|
+
]);
|
|
7134
|
+
if (fromTotalTokenCount != null) {
|
|
7135
|
+
setValueByPath(toObject, ['totalTokenCount'], fromTotalTokenCount);
|
|
7136
|
+
}
|
|
7137
|
+
const fromPromptTokensDetails = getValueByPath(fromObject, [
|
|
7138
|
+
'promptTokensDetails',
|
|
7139
|
+
]);
|
|
7140
|
+
if (fromPromptTokensDetails != null) {
|
|
7141
|
+
if (Array.isArray(fromPromptTokensDetails)) {
|
|
7142
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails.map((item) => {
|
|
7143
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7144
|
+
}));
|
|
7145
|
+
}
|
|
7146
|
+
else {
|
|
7147
|
+
setValueByPath(toObject, ['promptTokensDetails'], fromPromptTokensDetails);
|
|
7148
|
+
}
|
|
7149
|
+
}
|
|
7150
|
+
const fromCacheTokensDetails = getValueByPath(fromObject, [
|
|
7151
|
+
'cacheTokensDetails',
|
|
7152
|
+
]);
|
|
7153
|
+
if (fromCacheTokensDetails != null) {
|
|
7154
|
+
if (Array.isArray(fromCacheTokensDetails)) {
|
|
7155
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails.map((item) => {
|
|
7156
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7157
|
+
}));
|
|
7158
|
+
}
|
|
7159
|
+
else {
|
|
7160
|
+
setValueByPath(toObject, ['cacheTokensDetails'], fromCacheTokensDetails);
|
|
7161
|
+
}
|
|
7162
|
+
}
|
|
7163
|
+
const fromToolUsePromptTokensDetails = getValueByPath(fromObject, [
|
|
7164
|
+
'toolUsePromptTokensDetails',
|
|
7165
|
+
]);
|
|
7166
|
+
if (fromToolUsePromptTokensDetails != null) {
|
|
7167
|
+
if (Array.isArray(fromToolUsePromptTokensDetails)) {
|
|
7168
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails.map((item) => {
|
|
7169
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7170
|
+
}));
|
|
7171
|
+
}
|
|
7172
|
+
else {
|
|
7173
|
+
setValueByPath(toObject, ['toolUsePromptTokensDetails'], fromToolUsePromptTokensDetails);
|
|
7174
|
+
}
|
|
7175
|
+
}
|
|
7176
|
+
const fromResponseTokensDetails = getValueByPath(fromObject, [
|
|
7177
|
+
'candidatesTokensDetails',
|
|
7178
|
+
]);
|
|
7179
|
+
if (fromResponseTokensDetails != null) {
|
|
7180
|
+
if (Array.isArray(fromResponseTokensDetails)) {
|
|
7181
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails.map((item) => {
|
|
7182
|
+
return modalityTokenCountFromVertex(apiClient, item);
|
|
7183
|
+
}));
|
|
7184
|
+
}
|
|
7185
|
+
else {
|
|
7186
|
+
setValueByPath(toObject, ['responseTokensDetails'], fromResponseTokensDetails);
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
const fromTrafficType = getValueByPath(fromObject, ['trafficType']);
|
|
7190
|
+
if (fromTrafficType != null) {
|
|
7191
|
+
setValueByPath(toObject, ['trafficType'], fromTrafficType);
|
|
7192
|
+
}
|
|
7193
|
+
return toObject;
|
|
7194
|
+
}
|
|
6410
7195
|
|
|
6411
7196
|
/**
|
|
6412
7197
|
* @license
|
|
@@ -6599,7 +7384,13 @@ class Session {
|
|
|
6599
7384
|
throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
|
|
6600
7385
|
}
|
|
6601
7386
|
// LiveClientRealtimeInput
|
|
6602
|
-
clientMessage = {
|
|
7387
|
+
clientMessage = {
|
|
7388
|
+
realtimeInput: {
|
|
7389
|
+
mediaChunks: [params.media],
|
|
7390
|
+
activityStart: params.activityStart,
|
|
7391
|
+
activityEnd: params.activityEnd,
|
|
7392
|
+
},
|
|
7393
|
+
};
|
|
6603
7394
|
return clientMessage;
|
|
6604
7395
|
}
|
|
6605
7396
|
tLiveClienttToolResponse(apiClient, params) {
|
|
@@ -7218,6 +8009,66 @@ class Models extends BaseModule {
|
|
|
7218
8009
|
});
|
|
7219
8010
|
}
|
|
7220
8011
|
}
|
|
8012
|
+
/**
|
|
8013
|
+
* Fetches information about a model by name.
|
|
8014
|
+
*
|
|
8015
|
+
* @example
|
|
8016
|
+
* ```ts
|
|
8017
|
+
* const modelInfo = await ai.models.get({model: 'gemini-2.0-flash'});
|
|
8018
|
+
* ```
|
|
8019
|
+
*/
|
|
8020
|
+
async get(params) {
|
|
8021
|
+
var _a, _b;
|
|
8022
|
+
let response;
|
|
8023
|
+
let path = '';
|
|
8024
|
+
let queryParams = {};
|
|
8025
|
+
if (this.apiClient.isVertexAI()) {
|
|
8026
|
+
const body = getModelParametersToVertex(this.apiClient, params);
|
|
8027
|
+
path = formatMap('{name}', body['_url']);
|
|
8028
|
+
queryParams = body['_query'];
|
|
8029
|
+
delete body['config'];
|
|
8030
|
+
delete body['_url'];
|
|
8031
|
+
delete body['_query'];
|
|
8032
|
+
response = this.apiClient
|
|
8033
|
+
.request({
|
|
8034
|
+
path: path,
|
|
8035
|
+
queryParams: queryParams,
|
|
8036
|
+
body: JSON.stringify(body),
|
|
8037
|
+
httpMethod: 'GET',
|
|
8038
|
+
httpOptions: (_a = params.config) === null || _a === void 0 ? void 0 : _a.httpOptions,
|
|
8039
|
+
})
|
|
8040
|
+
.then((httpResponse) => {
|
|
8041
|
+
return httpResponse.json();
|
|
8042
|
+
});
|
|
8043
|
+
return response.then((apiResponse) => {
|
|
8044
|
+
const resp = modelFromVertex(this.apiClient, apiResponse);
|
|
8045
|
+
return resp;
|
|
8046
|
+
});
|
|
8047
|
+
}
|
|
8048
|
+
else {
|
|
8049
|
+
const body = getModelParametersToMldev(this.apiClient, params);
|
|
8050
|
+
path = formatMap('{name}', body['_url']);
|
|
8051
|
+
queryParams = body['_query'];
|
|
8052
|
+
delete body['config'];
|
|
8053
|
+
delete body['_url'];
|
|
8054
|
+
delete body['_query'];
|
|
8055
|
+
response = this.apiClient
|
|
8056
|
+
.request({
|
|
8057
|
+
path: path,
|
|
8058
|
+
queryParams: queryParams,
|
|
8059
|
+
body: JSON.stringify(body),
|
|
8060
|
+
httpMethod: 'GET',
|
|
8061
|
+
httpOptions: (_b = params.config) === null || _b === void 0 ? void 0 : _b.httpOptions,
|
|
8062
|
+
})
|
|
8063
|
+
.then((httpResponse) => {
|
|
8064
|
+
return httpResponse.json();
|
|
8065
|
+
});
|
|
8066
|
+
return response.then((apiResponse) => {
|
|
8067
|
+
const resp = modelFromMldev(this.apiClient, apiResponse);
|
|
8068
|
+
return resp;
|
|
8069
|
+
});
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
7221
8072
|
/**
|
|
7222
8073
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
7223
8074
|
* supported for Gemini models.
|
|
@@ -7359,10 +8210,10 @@ class Models extends BaseModule {
|
|
|
7359
8210
|
*
|
|
7360
8211
|
* while (!operation.done) {
|
|
7361
8212
|
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
7362
|
-
* operation = await ai.operations.
|
|
8213
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
7363
8214
|
* }
|
|
7364
8215
|
*
|
|
7365
|
-
* console.log(operation.
|
|
8216
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
7366
8217
|
* ```
|
|
7367
8218
|
*/
|
|
7368
8219
|
async generateVideos(params) {
|
|
@@ -7544,9 +8395,12 @@ function generateVideosOperationFromMldev(apiClient, fromObject) {
|
|
|
7544
8395
|
if (fromError != null) {
|
|
7545
8396
|
setValueByPath(toObject, ['error'], fromError);
|
|
7546
8397
|
}
|
|
7547
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
8398
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
8399
|
+
'response',
|
|
8400
|
+
'generateVideoResponse',
|
|
8401
|
+
]);
|
|
7548
8402
|
if (fromResponse != null) {
|
|
7549
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
8403
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(apiClient, fromResponse));
|
|
7550
8404
|
}
|
|
7551
8405
|
const fromResult = getValueByPath(fromObject, [
|
|
7552
8406
|
'response',
|
|
@@ -7630,7 +8484,7 @@ function generateVideosOperationFromVertex(apiClient, fromObject) {
|
|
|
7630
8484
|
}
|
|
7631
8485
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
7632
8486
|
if (fromResponse != null) {
|
|
7633
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
8487
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(apiClient, fromResponse));
|
|
7634
8488
|
}
|
|
7635
8489
|
const fromResult = getValueByPath(fromObject, ['response']);
|
|
7636
8490
|
if (fromResult != null) {
|
|
@@ -7652,10 +8506,10 @@ class Operations extends BaseModule {
|
|
|
7652
8506
|
/**
|
|
7653
8507
|
* Gets the status of a long-running operation.
|
|
7654
8508
|
*
|
|
7655
|
-
* @param
|
|
8509
|
+
* @param parameters The parameters for the get operation request.
|
|
7656
8510
|
* @return The updated Operation object, with the latest status or result.
|
|
7657
8511
|
*/
|
|
7658
|
-
async
|
|
8512
|
+
async getVideosOperation(parameters) {
|
|
7659
8513
|
const operation = parameters.operation;
|
|
7660
8514
|
const config = parameters.config;
|
|
7661
8515
|
if (operation.name === undefined || operation.name === '') {
|