@signageos/lib 23.23.1-master.4632 → 23.24.0-master.4637
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/GCP/MockVertex.d.ts +7 -0
- package/dist/GCP/MockVertex.js +102 -0
- package/dist/GCP/MockVertex.js.map +1 -0
- package/dist/GCP/Vertex.d.ts +35 -0
- package/dist/GCP/Vertex.js +75 -0
- package/dist/GCP/Vertex.js.map +1 -0
- package/dist/GCP/VertexTypes.d.ts +16 -0
- package/dist/GCP/VertexTypes.js +3 -0
- package/dist/GCP/VertexTypes.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GenerateContentResponse } from '@google/genai';
|
|
2
|
+
import { IGcpVertex } from './Vertex';
|
|
3
|
+
import { GenerateContentInput } from './VertexTypes';
|
|
4
|
+
export declare class MockVertex implements IGcpVertex {
|
|
5
|
+
generateContent(_input: GenerateContentInput): Promise<GenerateContentResponse>;
|
|
6
|
+
generateContentStream(input: GenerateContentInput): Promise<AsyncGenerator<GenerateContentResponse>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
39
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
40
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
41
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
42
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
43
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
44
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
45
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
46
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
47
|
+
function fulfill(value) { resume("next", value); }
|
|
48
|
+
function reject(value) { resume("throw", value); }
|
|
49
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.MockVertex = void 0;
|
|
53
|
+
var genai_1 = require("@google/genai");
|
|
54
|
+
var MockVertex = /** @class */ (function () {
|
|
55
|
+
function MockVertex() {
|
|
56
|
+
}
|
|
57
|
+
MockVertex.prototype.generateContent = function (_input) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
/// GenerateContentResponse is a class with convenience getters (e.g. `.text`), so a real
|
|
61
|
+
/// instance is built and the canned fields are copied onto it.
|
|
62
|
+
return [2 /*return*/, Object.assign(new genai_1.GenerateContentResponse(), {
|
|
63
|
+
candidates: [
|
|
64
|
+
{
|
|
65
|
+
content: { role: 'model', parts: [{ text: 'Hello, world!' }] },
|
|
66
|
+
finishReason: genai_1.FinishReason.STOP,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
usageMetadata: { promptTokenCount: 100, candidatesTokenCount: 100, totalTokenCount: 200 },
|
|
70
|
+
})];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
MockVertex.prototype.generateContentStream = function (input) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var response;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0: return [4 /*yield*/, this.generateContent(input)];
|
|
80
|
+
case 1:
|
|
81
|
+
response = _a.sent();
|
|
82
|
+
return [2 /*return*/, (function () {
|
|
83
|
+
return __asyncGenerator(this, arguments, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0: return [4 /*yield*/, __await(response)];
|
|
87
|
+
case 1: return [4 /*yield*/, _a.sent()];
|
|
88
|
+
case 2:
|
|
89
|
+
_a.sent();
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
})()];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return MockVertex;
|
|
100
|
+
}());
|
|
101
|
+
exports.MockVertex = MockVertex;
|
|
102
|
+
//# sourceMappingURL=MockVertex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockVertex.js","sourceRoot":"","sources":["../../src/GCP/MockVertex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsE;AAItE;IAAA;IAqBA,CAAC;IApBM,oCAAe,GAArB,UAAsB,MAA4B;;;gBACjD,yFAAyF;gBACzF,+DAA+D;gBAC/D,sBAAO,MAAM,CAAC,MAAM,CAAC,IAAI,+BAAuB,EAAE,EAAE;wBACnD,UAAU,EAAE;4BACX;gCACC,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE;gCAC9D,YAAY,EAAE,oBAAY,CAAC,IAAI;6BAC/B;yBACD;wBACD,aAAa,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,oBAAoB,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE;qBACzF,CAAC,EAAC;;;KACH;IAEK,0CAAqB,GAA3B,UAA4B,KAA2B;;;;;4BACrC,qBAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAA;;wBAA5C,QAAQ,GAAG,SAAiC;wBAClD,sBAAO,CAAC;;;;iFACD,QAAQ;oDAAd,gCAAc;;gDAAd,SAAc,CAAC;;;;;6BACf,CAAC,EAAE,EAAC;;;;KACL;IACF,iBAAC;AAAD,CAAC,AArBD,IAqBC;AArBY,gCAAU"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GenerateContentResponse, GoogleGenAIOptions } from '@google/genai';
|
|
2
|
+
import { GenerateContentInput } from './VertexTypes';
|
|
3
|
+
export interface IGcpVertex {
|
|
4
|
+
/**
|
|
5
|
+
* Generate content from a Gemini model on Vertex AI.
|
|
6
|
+
* More info: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference
|
|
7
|
+
* @param input - The input for the generation request
|
|
8
|
+
* @returns The response from the model
|
|
9
|
+
*/
|
|
10
|
+
generateContent(input: GenerateContentInput): Promise<GenerateContentResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Generate content from a Gemini model on Vertex AI with a streaming response.
|
|
13
|
+
* Could be used for cases when you expect to receive a stream of data from the model.
|
|
14
|
+
* More info: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#streaming
|
|
15
|
+
* @param input - The input for the generation request
|
|
16
|
+
* @returns An async generator yielding response chunks from the model
|
|
17
|
+
*/
|
|
18
|
+
generateContentStream(input: GenerateContentInput): Promise<AsyncGenerator<GenerateContentResponse>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Minimal surface of the underlying GoogleGenAI client used by the wrapper.
|
|
22
|
+
* Kept narrow and public so tests can substitute a typed stub without any casts.
|
|
23
|
+
*/
|
|
24
|
+
export interface IGoogleGenAiClient {
|
|
25
|
+
models: {
|
|
26
|
+
generateContent(params: GenerateContentInput): Promise<GenerateContentResponse>;
|
|
27
|
+
generateContentStream(params: GenerateContentInput): Promise<AsyncGenerator<GenerateContentResponse>>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare class GcpVertex implements IGcpVertex {
|
|
31
|
+
client: IGoogleGenAiClient;
|
|
32
|
+
constructor(options: Omit<GoogleGenAIOptions, 'vertexai'>);
|
|
33
|
+
generateContent(input: GenerateContentInput): Promise<GenerateContentResponse>;
|
|
34
|
+
generateContentStream(input: GenerateContentInput): Promise<AsyncGenerator<GenerateContentResponse>>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.GcpVertex = void 0;
|
|
51
|
+
var genai_1 = require("@google/genai");
|
|
52
|
+
var GcpVertex = /** @class */ (function () {
|
|
53
|
+
function GcpVertex(options) {
|
|
54
|
+
/// The wrapper is explicitly the Vertex AI entry point — the Gemini API-key mode is out of scope.
|
|
55
|
+
/// GCP authentication uses Application Default Credentials (https://cloud.google.com/docs/authentication/application-default-credentials).
|
|
56
|
+
this.client = new genai_1.GoogleGenAI(__assign(__assign({}, options), { vertexai: true }));
|
|
57
|
+
}
|
|
58
|
+
GcpVertex.prototype.generateContent = function (input) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
return [2 /*return*/, this.client.models.generateContent(input)];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
GcpVertex.prototype.generateContentStream = function (input) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
return [2 /*return*/, this.client.models.generateContentStream(input)];
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
return GcpVertex;
|
|
73
|
+
}());
|
|
74
|
+
exports.GcpVertex = GcpVertex;
|
|
75
|
+
//# sourceMappingURL=Vertex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vertex.js","sourceRoot":"","sources":["../../src/GCP/Vertex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyF;AAiCzF;IAGC,mBAAY,OAA6C;QACxD,kGAAkG;QAClG,2IAA2I;QAC3I,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAW,uBAAM,OAAO,KAAE,QAAQ,EAAE,IAAI,IAAG,CAAC;IAC/D,CAAC;IAEK,mCAAe,GAArB,UAAsB,KAA2B;;;gBAChD,sBAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAC;;;KACjD;IAEK,yCAAqB,GAA3B,UAA4B,KAA2B;;;gBACtD,sBAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAC;;;KACvD;IACF,gBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,8BAAS"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Content, GenerateContentConfig } from '@google/genai';
|
|
2
|
+
/**
|
|
3
|
+
* Input for a Vertex AI Gemini content generation request.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the SDK's `GenerateContentParameters` with `contents` narrowed to the explicit
|
|
6
|
+
* `Content[]` form (the SDK also accepts string/part shorthands, which are avoided in the
|
|
7
|
+
* shared surface so requests stay unambiguous).
|
|
8
|
+
*/
|
|
9
|
+
export interface GenerateContentInput {
|
|
10
|
+
/** Gemini model id to use, e.g. `gemini-2.5-flash` */
|
|
11
|
+
model: string;
|
|
12
|
+
/** Conversation contents (user/model turns with text and image parts) */
|
|
13
|
+
contents: Content[];
|
|
14
|
+
/** Optional model parameters (system instruction, response mime type, thinking config, token caps, ...) */
|
|
15
|
+
config?: GenerateContentConfig;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VertexTypes.js","sourceRoot":"","sources":["../../src/GCP/VertexTypes.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/lib",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.24.0-master.4637",
|
|
4
4
|
"main": "./dist",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@signageos/amqp": "^0.14.0",
|
|
42
42
|
"@signageos/core": "^1.5.0",
|
|
43
|
-
"@signageos/lib-ci": "23.
|
|
43
|
+
"@signageos/lib-ci": "23.24.0-master.4637",
|
|
44
44
|
"@signageos/metrics": "^1.0.0",
|
|
45
45
|
"@signageos/redis": "^3.1.0",
|
|
46
46
|
"@signageos/service": "^1.2.0",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"@aws-sdk/client-s3": "3.489.0",
|
|
70
70
|
"@aws-sdk/lib-storage": "3.489.0",
|
|
71
71
|
"@aws-sdk/s3-request-presigner": "3.489.0",
|
|
72
|
+
"@google/genai": "2.13.0",
|
|
72
73
|
"aws-sdk": "^2.1472.0",
|
|
73
74
|
"mocha": "^3.1.2",
|
|
74
75
|
"mongoose": "^8.0.0",
|
|
@@ -89,6 +90,7 @@
|
|
|
89
90
|
"@aws-sdk/lib-storage": "3.489.0",
|
|
90
91
|
"@aws-sdk/s3-request-presigner": "3.489.0",
|
|
91
92
|
"@aws-sdk/types": "^3.489.0",
|
|
93
|
+
"@google/genai": "2.13.0",
|
|
92
94
|
"@faker-js/faker": "8.3.1",
|
|
93
95
|
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
94
96
|
"@types/async-lock": "1.4.2",
|