@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.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,7 @@ 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. */
|
|
1692
1720
|
var MediaModality;
|
|
1693
1721
|
(function (MediaModality) {
|
|
1694
1722
|
MediaModality["MODALITY_UNSPECIFIED"] = "MODALITY_UNSPECIFIED";
|
|
@@ -1698,6 +1726,34 @@ var MediaModality;
|
|
|
1698
1726
|
MediaModality["AUDIO"] = "AUDIO";
|
|
1699
1727
|
MediaModality["DOCUMENT"] = "DOCUMENT";
|
|
1700
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 = {}));
|
|
1701
1757
|
/** A function response. */
|
|
1702
1758
|
class FunctionResponse {
|
|
1703
1759
|
}
|
|
@@ -1744,7 +1800,7 @@ function createPartFromFunctionResponse(id, name, response) {
|
|
|
1744
1800
|
};
|
|
1745
1801
|
}
|
|
1746
1802
|
/**
|
|
1747
|
-
* Creates a `Part` object from a `base64` `string`.
|
|
1803
|
+
* Creates a `Part` object from a `base64` encoded `string`.
|
|
1748
1804
|
*/
|
|
1749
1805
|
function createPartFromBase64(data, mimeType) {
|
|
1750
1806
|
return {
|
|
@@ -2823,9 +2879,10 @@ class Chat {
|
|
|
2823
2879
|
* SPDX-License-Identifier: Apache-2.0
|
|
2824
2880
|
*/
|
|
2825
2881
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
2882
|
+
const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
|
|
2826
2883
|
const USER_AGENT_HEADER = 'User-Agent';
|
|
2827
2884
|
const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
|
|
2828
|
-
const SDK_VERSION = '0.
|
|
2885
|
+
const SDK_VERSION = '0.8.0'; // x-release-please-version
|
|
2829
2886
|
const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
|
|
2830
2887
|
const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
|
|
2831
2888
|
const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
|
|
@@ -2965,11 +3022,9 @@ class ApiClient {
|
|
|
2965
3022
|
throw new Error('HTTP options are not correctly set.');
|
|
2966
3023
|
}
|
|
2967
3024
|
}
|
|
2968
|
-
constructUrl(path, httpOptions) {
|
|
3025
|
+
constructUrl(path, httpOptions, prependProjectLocation) {
|
|
2969
3026
|
const urlElement = [this.getRequestUrlInternal(httpOptions)];
|
|
2970
|
-
if (
|
|
2971
|
-
!this.clientOptions.apiKey &&
|
|
2972
|
-
!path.startsWith('projects/')) {
|
|
3027
|
+
if (prependProjectLocation) {
|
|
2973
3028
|
urlElement.push(this.getBaseResourcePath());
|
|
2974
3029
|
}
|
|
2975
3030
|
if (path !== '') {
|
|
@@ -2978,12 +3033,34 @@ class ApiClient {
|
|
|
2978
3033
|
const url = new URL(`${urlElement.join('/')}`);
|
|
2979
3034
|
return url;
|
|
2980
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
|
+
}
|
|
2981
3057
|
async request(request) {
|
|
2982
3058
|
let patchedHttpOptions = this.clientOptions.httpOptions;
|
|
2983
3059
|
if (request.httpOptions) {
|
|
2984
3060
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
2985
3061
|
}
|
|
2986
|
-
const
|
|
3062
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3063
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
2987
3064
|
if (request.queryParams) {
|
|
2988
3065
|
for (const [key, value] of Object.entries(request.queryParams)) {
|
|
2989
3066
|
url.searchParams.append(key, String(value));
|
|
@@ -3025,7 +3102,8 @@ class ApiClient {
|
|
|
3025
3102
|
if (request.httpOptions) {
|
|
3026
3103
|
patchedHttpOptions = this.patchHttpOptions(this.clientOptions.httpOptions, request.httpOptions);
|
|
3027
3104
|
}
|
|
3028
|
-
const
|
|
3105
|
+
const prependProjectLocation = this.shouldPrependVertexProjectPath(request);
|
|
3106
|
+
const url = this.constructUrl(request.path, patchedHttpOptions, prependProjectLocation);
|
|
3029
3107
|
if (!url.searchParams.has('alt') || url.searchParams.get('alt') !== 'sse') {
|
|
3030
3108
|
url.searchParams.set('alt', 'sse');
|
|
3031
3109
|
}
|
|
@@ -3133,6 +3211,11 @@ class ApiClient {
|
|
|
3133
3211
|
for (const [key, value] of Object.entries(httpOptions.headers)) {
|
|
3134
3212
|
headers.append(key, value);
|
|
3135
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
|
+
}
|
|
3136
3219
|
}
|
|
3137
3220
|
await this.clientOptions.auth.addAuthHeaders(headers);
|
|
3138
3221
|
return headers;
|
|
@@ -3647,7 +3730,9 @@ class Files extends BaseModule {
|
|
|
3647
3730
|
* This section can contain multiple paragraphs and code examples.
|
|
3648
3731
|
*
|
|
3649
3732
|
* @param params - Optional parameters specified in the
|
|
3650
|
-
* `
|
|
3733
|
+
* `types.UploadFileParameters` interface.
|
|
3734
|
+
* @see {@link types.UploadFileParameters#config} for the optional
|
|
3735
|
+
* config in the parameters.
|
|
3651
3736
|
* @return A promise that resolves to a `types.File` object.
|
|
3652
3737
|
* @throws An error if called on a Vertex AI client.
|
|
3653
3738
|
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
@@ -4151,6 +4236,12 @@ function thinkingConfigToMldev(apiClient, fromObject) {
|
|
|
4151
4236
|
if (fromIncludeThoughts != null) {
|
|
4152
4237
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4153
4238
|
}
|
|
4239
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
4240
|
+
'thinkingBudget',
|
|
4241
|
+
]);
|
|
4242
|
+
if (fromThinkingBudget != null) {
|
|
4243
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
4244
|
+
}
|
|
4154
4245
|
return toObject;
|
|
4155
4246
|
}
|
|
4156
4247
|
function generateContentConfigToMldev(apiClient, fromObject, parentObject) {
|
|
@@ -4454,6 +4545,18 @@ function generateImagesParametersToMldev(apiClient, fromObject) {
|
|
|
4454
4545
|
}
|
|
4455
4546
|
return toObject;
|
|
4456
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
|
+
}
|
|
4457
4560
|
function countTokensConfigToMldev(apiClient, fromObject) {
|
|
4458
4561
|
const toObject = {};
|
|
4459
4562
|
if (getValueByPath(fromObject, ['systemInstruction']) !== undefined) {
|
|
@@ -4899,6 +5002,12 @@ function thinkingConfigToVertex(apiClient, fromObject) {
|
|
|
4899
5002
|
if (fromIncludeThoughts != null) {
|
|
4900
5003
|
setValueByPath(toObject, ['includeThoughts'], fromIncludeThoughts);
|
|
4901
5004
|
}
|
|
5005
|
+
const fromThinkingBudget = getValueByPath(fromObject, [
|
|
5006
|
+
'thinkingBudget',
|
|
5007
|
+
]);
|
|
5008
|
+
if (fromThinkingBudget != null) {
|
|
5009
|
+
setValueByPath(toObject, ['thinkingBudget'], fromThinkingBudget);
|
|
5010
|
+
}
|
|
4902
5011
|
return toObject;
|
|
4903
5012
|
}
|
|
4904
5013
|
function generateContentConfigToVertex(apiClient, fromObject, parentObject) {
|
|
@@ -5216,6 +5325,18 @@ function generateImagesParametersToVertex(apiClient, fromObject) {
|
|
|
5216
5325
|
}
|
|
5217
5326
|
return toObject;
|
|
5218
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
|
+
}
|
|
5219
5340
|
function countTokensConfigToVertex(apiClient, fromObject, parentObject) {
|
|
5220
5341
|
const toObject = {};
|
|
5221
5342
|
const fromSystemInstruction = getValueByPath(fromObject, [
|
|
@@ -5639,6 +5760,64 @@ function generateImagesResponseFromMldev(apiClient, fromObject) {
|
|
|
5639
5760
|
}
|
|
5640
5761
|
return toObject;
|
|
5641
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
|
+
}
|
|
5642
5821
|
function countTokensResponseFromMldev(apiClient, fromObject) {
|
|
5643
5822
|
const toObject = {};
|
|
5644
5823
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -5727,9 +5906,12 @@ function generateVideosOperationFromMldev$1(apiClient, fromObject) {
|
|
|
5727
5906
|
if (fromError != null) {
|
|
5728
5907
|
setValueByPath(toObject, ['error'], fromError);
|
|
5729
5908
|
}
|
|
5730
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
5909
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
5910
|
+
'response',
|
|
5911
|
+
'generateVideoResponse',
|
|
5912
|
+
]);
|
|
5731
5913
|
if (fromResponse != null) {
|
|
5732
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
5914
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev$1(apiClient, fromResponse));
|
|
5733
5915
|
}
|
|
5734
5916
|
const fromResult = getValueByPath(fromObject, [
|
|
5735
5917
|
'response',
|
|
@@ -6045,6 +6227,78 @@ function generateImagesResponseFromVertex(apiClient, fromObject) {
|
|
|
6045
6227
|
}
|
|
6046
6228
|
return toObject;
|
|
6047
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
|
+
}
|
|
6048
6302
|
function countTokensResponseFromVertex(apiClient, fromObject) {
|
|
6049
6303
|
const toObject = {};
|
|
6050
6304
|
const fromTotalTokens = getValueByPath(fromObject, ['totalTokens']);
|
|
@@ -6134,7 +6388,7 @@ function generateVideosOperationFromVertex$1(apiClient, fromObject) {
|
|
|
6134
6388
|
}
|
|
6135
6389
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
6136
6390
|
if (fromResponse != null) {
|
|
6137
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
6391
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex$1(apiClient, fromResponse));
|
|
6138
6392
|
}
|
|
6139
6393
|
const fromResult = getValueByPath(fromObject, ['response']);
|
|
6140
6394
|
if (fromResult != null) {
|
|
@@ -6200,6 +6454,23 @@ function liveServerMessageFromMldev(apiClient, fromObject) {
|
|
|
6200
6454
|
fromToolCallCancellation !== null) {
|
|
6201
6455
|
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromMldev(apiClient, fromToolCallCancellation));
|
|
6202
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
|
+
}
|
|
6203
6474
|
return toObject;
|
|
6204
6475
|
}
|
|
6205
6476
|
function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
@@ -6227,6 +6498,181 @@ function liveServerMessageFromVertex(apiClient, fromObject) {
|
|
|
6227
6498
|
fromToolCallCancellation !== null) {
|
|
6228
6499
|
setValueByPath(toObject, ['toolCallCancellation'], liveServerToolCallCancellationFromVertex(apiClient, fromToolCallCancellation));
|
|
6229
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
|
+
}
|
|
6230
6676
|
return toObject;
|
|
6231
6677
|
}
|
|
6232
6678
|
function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
@@ -6261,6 +6707,26 @@ function liveConnectConfigToMldev(apiClient, fromObject) {
|
|
|
6261
6707
|
return toolToMldev(apiClient, item);
|
|
6262
6708
|
}));
|
|
6263
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
|
+
}
|
|
6264
6730
|
return toObject;
|
|
6265
6731
|
}
|
|
6266
6732
|
function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
@@ -6299,6 +6765,26 @@ function liveConnectConfigToVertex(apiClient, fromObject) {
|
|
|
6299
6765
|
return toolToVertex(apiClient, item);
|
|
6300
6766
|
}));
|
|
6301
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
|
+
}
|
|
6302
6788
|
return toObject;
|
|
6303
6789
|
}
|
|
6304
6790
|
function liveServerContentFromMldev(apiClient, fromObject) {
|
|
@@ -6315,6 +6801,12 @@ function liveServerContentFromMldev(apiClient, fromObject) {
|
|
|
6315
6801
|
if (fromInterrupted !== undefined) {
|
|
6316
6802
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
6317
6803
|
}
|
|
6804
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
6805
|
+
'generationComplete',
|
|
6806
|
+
]);
|
|
6807
|
+
if (fromGenerationComplete != null) {
|
|
6808
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
6809
|
+
}
|
|
6318
6810
|
return toObject;
|
|
6319
6811
|
}
|
|
6320
6812
|
function liveServerContentFromVertex(apiClient, fromObject) {
|
|
@@ -6331,6 +6823,12 @@ function liveServerContentFromVertex(apiClient, fromObject) {
|
|
|
6331
6823
|
if (fromInterrupted !== undefined) {
|
|
6332
6824
|
setValueByPath(toObject, ['interrupted'], fromInterrupted);
|
|
6333
6825
|
}
|
|
6826
|
+
const fromGenerationComplete = getValueByPath(fromObject, [
|
|
6827
|
+
'generationComplete',
|
|
6828
|
+
]);
|
|
6829
|
+
if (fromGenerationComplete != null) {
|
|
6830
|
+
setValueByPath(toObject, ['generationComplete'], fromGenerationComplete);
|
|
6831
|
+
}
|
|
6334
6832
|
return toObject;
|
|
6335
6833
|
}
|
|
6336
6834
|
function functionCallFromMldev(apiClient, fromObject) {
|
|
@@ -6405,6 +6903,293 @@ function liveServerToolCallCancellationFromVertex(apiClient, fromObject) {
|
|
|
6405
6903
|
}
|
|
6406
6904
|
return toObject;
|
|
6407
6905
|
}
|
|
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
|
+
}
|
|
6408
7193
|
|
|
6409
7194
|
/**
|
|
6410
7195
|
* @license
|
|
@@ -6597,7 +7382,13 @@ class Session {
|
|
|
6597
7382
|
throw new Error(`Failed to convert realtime input "media", type: '${typeof params.media}'`);
|
|
6598
7383
|
}
|
|
6599
7384
|
// LiveClientRealtimeInput
|
|
6600
|
-
clientMessage = {
|
|
7385
|
+
clientMessage = {
|
|
7386
|
+
realtimeInput: {
|
|
7387
|
+
mediaChunks: [params.media],
|
|
7388
|
+
activityStart: params.activityStart,
|
|
7389
|
+
activityEnd: params.activityEnd,
|
|
7390
|
+
},
|
|
7391
|
+
};
|
|
6601
7392
|
return clientMessage;
|
|
6602
7393
|
}
|
|
6603
7394
|
tLiveClienttToolResponse(apiClient, params) {
|
|
@@ -7216,6 +8007,66 @@ class Models extends BaseModule {
|
|
|
7216
8007
|
});
|
|
7217
8008
|
}
|
|
7218
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
|
+
}
|
|
7219
8070
|
/**
|
|
7220
8071
|
* Counts the number of tokens in the given contents. Multimodal input is
|
|
7221
8072
|
* supported for Gemini models.
|
|
@@ -7357,10 +8208,10 @@ class Models extends BaseModule {
|
|
|
7357
8208
|
*
|
|
7358
8209
|
* while (!operation.done) {
|
|
7359
8210
|
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
7360
|
-
* operation = await ai.operations.
|
|
8211
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
7361
8212
|
* }
|
|
7362
8213
|
*
|
|
7363
|
-
* console.log(operation.
|
|
8214
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
7364
8215
|
* ```
|
|
7365
8216
|
*/
|
|
7366
8217
|
async generateVideos(params) {
|
|
@@ -7542,9 +8393,12 @@ function generateVideosOperationFromMldev(apiClient, fromObject) {
|
|
|
7542
8393
|
if (fromError != null) {
|
|
7543
8394
|
setValueByPath(toObject, ['error'], fromError);
|
|
7544
8395
|
}
|
|
7545
|
-
const fromResponse = getValueByPath(fromObject, [
|
|
8396
|
+
const fromResponse = getValueByPath(fromObject, [
|
|
8397
|
+
'response',
|
|
8398
|
+
'generateVideoResponse',
|
|
8399
|
+
]);
|
|
7546
8400
|
if (fromResponse != null) {
|
|
7547
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
8401
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromMldev(apiClient, fromResponse));
|
|
7548
8402
|
}
|
|
7549
8403
|
const fromResult = getValueByPath(fromObject, [
|
|
7550
8404
|
'response',
|
|
@@ -7628,7 +8482,7 @@ function generateVideosOperationFromVertex(apiClient, fromObject) {
|
|
|
7628
8482
|
}
|
|
7629
8483
|
const fromResponse = getValueByPath(fromObject, ['response']);
|
|
7630
8484
|
if (fromResponse != null) {
|
|
7631
|
-
setValueByPath(toObject, ['response'], fromResponse);
|
|
8485
|
+
setValueByPath(toObject, ['response'], generateVideosResponseFromVertex(apiClient, fromResponse));
|
|
7632
8486
|
}
|
|
7633
8487
|
const fromResult = getValueByPath(fromObject, ['response']);
|
|
7634
8488
|
if (fromResult != null) {
|
|
@@ -7650,10 +8504,10 @@ class Operations extends BaseModule {
|
|
|
7650
8504
|
/**
|
|
7651
8505
|
* Gets the status of a long-running operation.
|
|
7652
8506
|
*
|
|
7653
|
-
* @param
|
|
8507
|
+
* @param parameters The parameters for the get operation request.
|
|
7654
8508
|
* @return The updated Operation object, with the latest status or result.
|
|
7655
8509
|
*/
|
|
7656
|
-
async
|
|
8510
|
+
async getVideosOperation(parameters) {
|
|
7657
8511
|
const operation = parameters.operation;
|
|
7658
8512
|
const config = parameters.config;
|
|
7659
8513
|
if (operation.name === undefined || operation.name === '') {
|
|
@@ -7848,5 +8702,5 @@ class GoogleGenAI {
|
|
|
7848
8702
|
}
|
|
7849
8703
|
}
|
|
7850
8704
|
|
|
7851
|
-
export { BlockedReason, Caches, Chat, Chats, ComputeTokensResponse, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DynamicRetrievalConfigMode, EmbedContentResponse, 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,
|
|
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 };
|
|
7852
8706
|
//# sourceMappingURL=index.mjs.map
|