@dataclouder/nest-vertex 0.0.52 → 0.0.54
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/controllers/{vertex-image-adapter.controller.d.ts → image/vertex-image-adapter.controller.d.ts} +4 -4
- package/controllers/{vertex-image-adapter.controller.js → image/vertex-image-adapter.controller.js} +5 -11
- package/controllers/llm/groq-llm.controller.d.ts +9 -0
- package/controllers/llm/groq-llm.controller.js +51 -0
- package/controllers/llm/llm-adapter.controller.d.ts +11 -0
- package/controllers/{vertex-llm-adapter.controller.js → llm/llm-adapter.controller.js} +18 -5
- package/controllers/llm/llm-gemini-chat.controller.d.ts +11 -0
- package/controllers/{vertex-gemini-chat.controller.js → llm/llm-gemini-chat.controller.js} +13 -48
- package/controllers/{groq-stt.controller.d.ts → stt/groq-stt.controller.d.ts} +1 -1
- package/controllers/{groq-stt.controller.js → stt/groq-stt.controller.js} +1 -1
- package/controllers/{vertex-gemini-tts.controller.d.ts → tts/vertex-gemini-tts.controller.d.ts} +2 -2
- package/controllers/{vertex-gemini-tts.controller.js → tts/vertex-gemini-tts.controller.js} +1 -1
- package/controllers/{vertex-tts-adapter.controller.d.ts → tts/vertex-tts-adapter.controller.d.ts} +1 -1
- package/controllers/{vertex-tts-adapter.controller.js → tts/vertex-tts-adapter.controller.js} +1 -1
- package/controllers/{veo-video.controller.d.ts → video/veo-video.controller.d.ts} +1 -1
- package/controllers/{veo-video.controller.js → video/veo-video.controller.js} +1 -1
- package/controllers/{video-gen-adapter.controller.d.ts → video/video-gen-adapter.controller.d.ts} +10 -10
- package/controllers/{video-gen-adapter.controller.js → video/video-gen-adapter.controller.js} +8 -8
- package/dto/conversation.dto.d.ts +13 -0
- package/dto/conversation.dto.js +16 -0
- package/dto/generate-text.dto.d.ts +1 -0
- package/dto/generate-text.dto.js +9 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/models/adapter.models.js +47 -3
- package/nest-vertex.module.js +15 -10
- package/package.json +1 -1
- package/services/adapter-llm.service.d.ts +2 -1
- package/services/adapter-llm.service.js +9 -5
- package/services/google-genai.service.d.ts +8 -7
- package/services/google-genai.service.js +31 -17
- package/services/llm/groq-llm.service.d.ts +9 -0
- package/services/llm/groq-llm.service.js +61 -0
- package/services/vertex-gemini-chat.service.d.ts +2 -0
- package/services/vertex-gemini-chat.service.js +37 -2
- package/services/vertex-image.service.js +1 -1
- package/controllers/vertex-gemini-chat.controller.d.ts +0 -20
- package/controllers/vertex-llm-adapter.controller.d.ts +0 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { VertexImageVideoService } from '
|
|
2
|
-
import { ImageGenRequestAdapter } from '
|
|
3
|
-
import { ImageGenAdapterResponse } from '
|
|
4
|
-
import { ImageGenAdapterService } from '
|
|
1
|
+
import { VertexImageVideoService } from '../../services/vertex-image-video.service';
|
|
2
|
+
import { ImageGenRequestAdapter } from '../../models/adapter.models';
|
|
3
|
+
import { ImageGenAdapterResponse } from '../../models/adapter.models';
|
|
4
|
+
import { ImageGenAdapterService } from '../../services/adapter-image-gen.service';
|
|
5
5
|
export declare class VertexImageVideoAdapterController {
|
|
6
6
|
private readonly vertexImageVideoService;
|
|
7
7
|
private readonly imageGenAdapterService;
|
package/controllers/{vertex-image-adapter.controller.js → image/vertex-image-adapter.controller.js}
RENAMED
|
@@ -14,10 +14,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.VertexImageVideoAdapterController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
-
const vertex_image_video_service_1 = require("
|
|
18
|
-
const adapter_models_1 = require("
|
|
17
|
+
const vertex_image_video_service_1 = require("../../services/vertex-image-video.service");
|
|
18
|
+
const adapter_models_1 = require("../../models/adapter.models");
|
|
19
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
20
|
-
const adapter_image_gen_service_1 = require("
|
|
20
|
+
const adapter_image_gen_service_1 = require("../../services/adapter-image-gen.service");
|
|
21
21
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
22
22
|
const common_2 = require("@nestjs/common");
|
|
23
23
|
let VertexImageVideoAdapterController = class VertexImageVideoAdapterController {
|
|
@@ -53,20 +53,14 @@ __decorate([
|
|
|
53
53
|
], VertexImageVideoAdapterController.prototype, "listModels", null);
|
|
54
54
|
__decorate([
|
|
55
55
|
(0, common_1.Post)('generate-image'),
|
|
56
|
-
(0, swagger_1.ApiQuery)({
|
|
57
|
-
name: 'provider',
|
|
58
|
-
required: false,
|
|
59
|
-
type: String,
|
|
60
|
-
description: 'The provider for the image generation service (e.g., "local", "google")',
|
|
61
|
-
}),
|
|
62
56
|
__param(0, (0, common_1.Body)()),
|
|
63
57
|
__metadata("design:type", Function),
|
|
64
58
|
__metadata("design:paramtypes", [adapter_models_1.ImageGenRequestAdapter]),
|
|
65
59
|
__metadata("design:returntype", Promise)
|
|
66
60
|
], VertexImageVideoAdapterController.prototype, "generateImage", null);
|
|
67
61
|
exports.VertexImageVideoAdapterController = VertexImageVideoAdapterController = __decorate([
|
|
68
|
-
(0, swagger_1.ApiTags)('
|
|
69
|
-
(0, common_1.Controller)('api/
|
|
62
|
+
(0, swagger_1.ApiTags)('Image Generation Adapter'),
|
|
63
|
+
(0, common_1.Controller)('api/ai-services/image/adapter'),
|
|
70
64
|
(0, common_2.UseFilters)(nest_core_1.AllExceptionsHandler),
|
|
71
65
|
__metadata("design:paramtypes", [vertex_image_video_service_1.VertexImageVideoService,
|
|
72
66
|
adapter_image_gen_service_1.ImageGenAdapterService])
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GroqLlmService } from '../../services/llm/groq-llm.service';
|
|
2
|
+
import { GenerateTextDto } from '../../dto/generate-text.dto';
|
|
3
|
+
import Groq from 'groq-sdk';
|
|
4
|
+
export declare class GroqLlmController {
|
|
5
|
+
private readonly groqLlmService;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(groqLlmService: GroqLlmService);
|
|
8
|
+
generateText(generateTextDto: GenerateTextDto): Promise<Groq.Chat.Completions.ChatCompletion>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var GroqLlmController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GroqLlmController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const groq_llm_service_1 = require("../../services/llm/groq-llm.service");
|
|
19
|
+
const generate_text_dto_1 = require("../../dto/generate-text.dto");
|
|
20
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
21
|
+
let GroqLlmController = GroqLlmController_1 = class GroqLlmController {
|
|
22
|
+
groqLlmService;
|
|
23
|
+
logger = new common_1.Logger(GroqLlmController_1.name);
|
|
24
|
+
constructor(groqLlmService) {
|
|
25
|
+
this.groqLlmService = groqLlmService;
|
|
26
|
+
}
|
|
27
|
+
async generateText(generateTextDto) {
|
|
28
|
+
this.logger.log(`Received request to generate text with model: ${generateTextDto.model}`);
|
|
29
|
+
const messages = generateTextDto.messages
|
|
30
|
+
.filter(message => ['system', 'user', 'assistant'].includes(message.role))
|
|
31
|
+
.map(message => ({
|
|
32
|
+
role: message.role,
|
|
33
|
+
content: message.content,
|
|
34
|
+
}));
|
|
35
|
+
return this.groqLlmService.getGroqChatCompletion(messages, generateTextDto.model);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.GroqLlmController = GroqLlmController;
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, common_1.Post)('chat'),
|
|
41
|
+
__param(0, (0, common_1.Body)()),
|
|
42
|
+
__metadata("design:type", Function),
|
|
43
|
+
__metadata("design:paramtypes", [generate_text_dto_1.GenerateTextDto]),
|
|
44
|
+
__metadata("design:returntype", Promise)
|
|
45
|
+
], GroqLlmController.prototype, "generateText", null);
|
|
46
|
+
exports.GroqLlmController = GroqLlmController = GroqLlmController_1 = __decorate([
|
|
47
|
+
(0, swagger_1.ApiTags)('LLM Groq'),
|
|
48
|
+
(0, common_1.Controller)('api/ai-services/groq/llm'),
|
|
49
|
+
__metadata("design:paramtypes", [groq_llm_service_1.GroqLlmService])
|
|
50
|
+
], GroqLlmController);
|
|
51
|
+
//# sourceMappingURL=groq-llm.controller.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ChatLLMRequestAdapter, ChatMessageDict, DescribeImageRequestAdapter } from '../../models/adapter.models';
|
|
2
|
+
import { LLMAdapterService } from '../../services/adapter-llm.service';
|
|
3
|
+
import { ConversationDTO } from '../../dto/conversation.dto';
|
|
4
|
+
export declare class VertexAdapterLLMController {
|
|
5
|
+
private readonly llmAdapterService;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(llmAdapterService: LLMAdapterService);
|
|
8
|
+
generateText(request: ChatLLMRequestAdapter): Promise<any>;
|
|
9
|
+
describeImage(request: DescribeImageRequestAdapter): Promise<import("../../models/adapter.models").GeneratedTextAdapter>;
|
|
10
|
+
continueConversation(conversation: ConversationDTO): Promise<ChatMessageDict>;
|
|
11
|
+
}
|
|
@@ -16,10 +16,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.VertexAdapterLLMController = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
-
const adapter_models_1 = require("
|
|
20
|
-
const adapter_llm_service_1 = require("
|
|
19
|
+
const adapter_models_1 = require("../../models/adapter.models");
|
|
20
|
+
const adapter_llm_service_1 = require("../../services/adapter-llm.service");
|
|
21
21
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
22
22
|
const common_2 = require("@nestjs/common");
|
|
23
|
+
const conversation_dto_1 = require("../../dto/conversation.dto");
|
|
23
24
|
let VertexAdapterLLMController = VertexAdapterLLMController_1 = class VertexAdapterLLMController {
|
|
24
25
|
llmAdapterService;
|
|
25
26
|
logger = new common_1.Logger(VertexAdapterLLMController_1.name);
|
|
@@ -36,6 +37,9 @@ let VertexAdapterLLMController = VertexAdapterLLMController_1 = class VertexAdap
|
|
|
36
37
|
const result = await this.llmAdapterService.describeImage(request);
|
|
37
38
|
return result;
|
|
38
39
|
}
|
|
40
|
+
async continueConversation(conversation) {
|
|
41
|
+
return this.llmAdapterService.chat(conversation);
|
|
42
|
+
}
|
|
39
43
|
};
|
|
40
44
|
exports.VertexAdapterLLMController = VertexAdapterLLMController;
|
|
41
45
|
__decorate([
|
|
@@ -52,10 +56,19 @@ __decorate([
|
|
|
52
56
|
__metadata("design:paramtypes", [adapter_models_1.DescribeImageRequestAdapter]),
|
|
53
57
|
__metadata("design:returntype", Promise)
|
|
54
58
|
], VertexAdapterLLMController.prototype, "describeImage", null);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, common_1.Post)('/chat'),
|
|
61
|
+
(0, swagger_1.ApiOperation)({ summary: 'Continue the conversation' }),
|
|
62
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Return the conversation.' }),
|
|
63
|
+
__param(0, (0, common_1.Body)()),
|
|
64
|
+
__metadata("design:type", Function),
|
|
65
|
+
__metadata("design:paramtypes", [conversation_dto_1.ConversationDTO]),
|
|
66
|
+
__metadata("design:returntype", Promise)
|
|
67
|
+
], VertexAdapterLLMController.prototype, "continueConversation", null);
|
|
55
68
|
exports.VertexAdapterLLMController = VertexAdapterLLMController = VertexAdapterLLMController_1 = __decorate([
|
|
56
|
-
(0, swagger_1.ApiTags)('
|
|
57
|
-
(0, common_1.Controller)('api/
|
|
69
|
+
(0, swagger_1.ApiTags)('AI Services Adapter LLM'),
|
|
70
|
+
(0, common_1.Controller)('api/ai-services/adapter/llm'),
|
|
58
71
|
(0, common_2.UseFilters)(nest_core_1.AllExceptionsHandler),
|
|
59
72
|
__metadata("design:paramtypes", [adapter_llm_service_1.LLMAdapterService])
|
|
60
73
|
], VertexAdapterLLMController);
|
|
61
|
-
//# sourceMappingURL=
|
|
74
|
+
//# sourceMappingURL=llm-adapter.controller.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GeminiChatService } from '../../services/vertex-gemini-chat.service';
|
|
2
|
+
import { GenerateTextDto } from '../../dto/generate-text.dto';
|
|
3
|
+
import { ChatMessageDict } from '../../models/adapter.models';
|
|
4
|
+
import { ConversationDTO } from '../../dto/conversation.dto';
|
|
5
|
+
export declare class GeminiChatController {
|
|
6
|
+
private readonly geminiChatService;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(geminiChatService: GeminiChatService);
|
|
9
|
+
generateText(generateTextDto: GenerateTextDto): Promise<ChatMessageDict>;
|
|
10
|
+
continueConversation(conversation: ConversationDTO): Promise<ChatMessageDict>;
|
|
11
|
+
}
|
|
@@ -13,25 +13,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
var GeminiChatController_1;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.GeminiChatController =
|
|
16
|
+
exports.GeminiChatController = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
|
-
const vertex_gemini_chat_service_1 = require("
|
|
18
|
+
const vertex_gemini_chat_service_1 = require("../../services/vertex-gemini-chat.service");
|
|
19
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
20
|
-
const generate_text_dto_1 = require("
|
|
20
|
+
const generate_text_dto_1 = require("../../dto/generate-text.dto");
|
|
21
|
+
const key_balancer_models_1 = require("../../models/key-balancer.models");
|
|
21
22
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
22
|
-
const
|
|
23
|
-
const adapter_models_1 = require("../models/adapter.models");
|
|
24
|
-
class ConversationDTO {
|
|
25
|
-
id;
|
|
26
|
-
entityId;
|
|
27
|
-
type;
|
|
28
|
-
createdAt;
|
|
29
|
-
messages;
|
|
30
|
-
transcription;
|
|
31
|
-
model;
|
|
32
|
-
returnJson;
|
|
33
|
-
}
|
|
34
|
-
exports.ConversationDTO = ConversationDTO;
|
|
23
|
+
const conversation_dto_1 = require("../../dto/conversation.dto");
|
|
35
24
|
let GeminiChatController = GeminiChatController_1 = class GeminiChatController {
|
|
36
25
|
geminiChatService;
|
|
37
26
|
logger = new common_1.Logger(GeminiChatController_1.name);
|
|
@@ -44,37 +33,13 @@ let GeminiChatController = GeminiChatController_1 = class GeminiChatController {
|
|
|
44
33
|
return result;
|
|
45
34
|
}
|
|
46
35
|
async continueConversation(conversation) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
conversation.model = { provider: 'google', modelName: gemini_models_1.GeminiModels.Gemini2_5Lite, id: 'no-id' };
|
|
36
|
+
try {
|
|
37
|
+
return this.geminiChatService.chatWithConversation(conversation);
|
|
50
38
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
conversation.
|
|
54
|
-
|
|
55
|
-
const returnJson = conversation.returnJson;
|
|
56
|
-
if (returnJson) {
|
|
57
|
-
const obj = await this.geminiChatService.chatAndExtractJson(conversation.messages, conversation.model.modelName);
|
|
58
|
-
const endTime = Date.now();
|
|
59
|
-
const processTime = (endTime - startTime) / 1000;
|
|
60
|
-
const metadata = {
|
|
61
|
-
type: 'json',
|
|
62
|
-
provider: conversation.model.provider,
|
|
63
|
-
model: conversation.model.modelName,
|
|
64
|
-
processTime,
|
|
65
|
-
...obj?.metadata,
|
|
66
|
-
};
|
|
67
|
-
return { content: obj.json, role: adapter_models_1.ChatRole.Assistant, metadata };
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
const response = await this.geminiChatService.chat(conversation.messages, conversation.model.modelName);
|
|
71
|
-
const endTime = Date.now();
|
|
72
|
-
const processTime = (endTime - startTime) / 1000;
|
|
73
|
-
return {
|
|
74
|
-
content: response.content,
|
|
75
|
-
role: response.role,
|
|
76
|
-
metadata: { provider: conversation.model.provider, model: conversation.model.modelName, processTime, tokens: response.metadata.tokens },
|
|
77
|
-
};
|
|
39
|
+
catch (error) {
|
|
40
|
+
this.logger.warn(` 🎀 Error trying with tier 1 ....`);
|
|
41
|
+
conversation.tierType = key_balancer_models_1.TierType.TIER_1;
|
|
42
|
+
return this.geminiChatService.chatWithConversation(conversation);
|
|
78
43
|
}
|
|
79
44
|
}
|
|
80
45
|
};
|
|
@@ -92,7 +57,7 @@ __decorate([
|
|
|
92
57
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Return the conversation.' }),
|
|
93
58
|
__param(0, (0, common_1.Body)()),
|
|
94
59
|
__metadata("design:type", Function),
|
|
95
|
-
__metadata("design:paramtypes", [ConversationDTO]),
|
|
60
|
+
__metadata("design:paramtypes", [conversation_dto_1.ConversationDTO]),
|
|
96
61
|
__metadata("design:returntype", Promise)
|
|
97
62
|
], GeminiChatController.prototype, "continueConversation", null);
|
|
98
63
|
exports.GeminiChatController = GeminiChatController = GeminiChatController_1 = __decorate([
|
|
@@ -101,4 +66,4 @@ exports.GeminiChatController = GeminiChatController = GeminiChatController_1 = _
|
|
|
101
66
|
(0, common_1.UseFilters)(nest_core_1.AllExceptionsHandler),
|
|
102
67
|
__metadata("design:paramtypes", [vertex_gemini_chat_service_1.GeminiChatService])
|
|
103
68
|
], GeminiChatController);
|
|
104
|
-
//# sourceMappingURL=
|
|
69
|
+
//# sourceMappingURL=llm-gemini-chat.controller.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MulterFile } from '@webundsoehne/nest-fastify-file-upload';
|
|
2
|
-
import { GroqService } from '
|
|
2
|
+
import { GroqService } from '../../services/whisper/groq.service';
|
|
3
3
|
export declare class GroqSttController {
|
|
4
4
|
private readonly groqService;
|
|
5
5
|
private readonly logger;
|
|
@@ -17,7 +17,7 @@ exports.GroqSttController = void 0;
|
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const nest_fastify_file_upload_1 = require("@webundsoehne/nest-fastify-file-upload");
|
|
19
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
20
|
-
const groq_service_1 = require("
|
|
20
|
+
const groq_service_1 = require("../../services/whisper/groq.service");
|
|
21
21
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
22
22
|
let GroqSttController = GroqSttController_1 = class GroqSttController {
|
|
23
23
|
groqService;
|
package/controllers/{vertex-gemini-tts.controller.d.ts → tts/vertex-gemini-tts.controller.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FastifyReply } from 'fastify';
|
|
2
|
-
import { VertexGeminiTtsService } from '
|
|
3
|
-
import { type SynthesizeSpeechInput } from '
|
|
2
|
+
import { VertexGeminiTtsService } from '../../services/vertex-gemini-tts.service';
|
|
3
|
+
import { type SynthesizeSpeechInput } from '../../services/vertex-tts.service';
|
|
4
4
|
export declare class VertexGeminiTtsController {
|
|
5
5
|
private readonly vertexGeminiTtsService;
|
|
6
6
|
private readonly logger;
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.VertexGeminiTtsController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const vertex_gemini_tts_service_1 = require("
|
|
18
|
+
const vertex_gemini_tts_service_1 = require("../../services/vertex-gemini-tts.service");
|
|
19
19
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
20
20
|
let VertexGeminiTtsController = class VertexGeminiTtsController {
|
|
21
21
|
vertexGeminiTtsService;
|
package/controllers/{vertex-tts-adapter.controller.d.ts → tts/vertex-tts-adapter.controller.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { google } from '@google-cloud/text-to-speech/build/protos/protos';
|
|
2
2
|
import { type FastifyReply } from 'fastify';
|
|
3
|
-
import { VertextTtsService, type SynthesizeSpeechInput } from '
|
|
3
|
+
import { VertextTtsService, type SynthesizeSpeechInput } from '../../services/vertex-tts.service';
|
|
4
4
|
import { type AppToken } from '@dataclouder/nest-auth';
|
|
5
5
|
export declare class VertexTtsAdapterController {
|
|
6
6
|
private readonly nestTtsService;
|
package/controllers/{vertex-tts-adapter.controller.js → tts/vertex-tts-adapter.controller.js}
RENAMED
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.VertexTtsAdapterController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const vertex_tts_service_1 = require("
|
|
18
|
+
const vertex_tts_service_1 = require("../../services/vertex-tts.service");
|
|
19
19
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
20
20
|
const common_2 = require("@nestjs/common");
|
|
21
21
|
const nest_auth_1 = require("@dataclouder/nest-auth");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VertexVeoGenaiService } from '
|
|
1
|
+
import { VertexVeoGenaiService } from '../../services/vertex-veo-genai.service';
|
|
2
2
|
export declare class VertexVeoGenerationController {
|
|
3
3
|
private readonly vertexVeoGcpService;
|
|
4
4
|
private readonly logger;
|
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.VertexVeoGenerationController = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
-
const vertex_veo_genai_service_1 = require("
|
|
16
|
+
const vertex_veo_genai_service_1 = require("../../services/vertex-veo-genai.service");
|
|
17
17
|
let VertexVeoGenerationController = VertexVeoGenerationController_1 = class VertexVeoGenerationController {
|
|
18
18
|
vertexVeoGcpService;
|
|
19
19
|
logger = new common_1.Logger(VertexVeoGenerationController_1.name);
|
package/controllers/{video-gen-adapter.controller.d.ts → video/video-gen-adapter.controller.d.ts}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { VertexImageVideoService } from '
|
|
2
|
-
import { GenerateVideoDto } from '
|
|
3
|
-
import { GetVeoVideoStatusDto } from '
|
|
1
|
+
import { VertexImageVideoService } from '../../services/vertex-image-video.service';
|
|
2
|
+
import { GenerateVideoDto } from '../../dto/generate-video.dto';
|
|
3
|
+
import { GetVeoVideoStatusDto } from '../../dto/get-veo-video-status.dto';
|
|
4
4
|
import { GenerateVideosOperation } from '@google/genai';
|
|
5
|
-
import { VertexVeoGcpService } from '
|
|
6
|
-
import { GeneratedAsset } from '
|
|
7
|
-
import { GeneratedAssetService } from '
|
|
8
|
-
import { ComfyVideoService } from '
|
|
9
|
-
import { VertexVeoGenaiService } from '
|
|
10
|
-
import { ComfySDKService } from '
|
|
5
|
+
import { VertexVeoGcpService } from '../../services/vertex-veo-gcp.service';
|
|
6
|
+
import { GeneratedAsset } from '../../models/generated-asset.entity';
|
|
7
|
+
import { GeneratedAssetService } from '../../services/generated-asset.service';
|
|
8
|
+
import { ComfyVideoService } from '../../comfyui/services/comfy-video.service';
|
|
9
|
+
import { VertexVeoGenaiService } from '../../services/vertex-veo-genai.service';
|
|
10
|
+
import { ComfySDKService } from '../../comfyui/services/comfy-sdk.service';
|
|
11
11
|
export declare class VertexVideoImageAdapterController {
|
|
12
12
|
private readonly vertexImageVideoService;
|
|
13
13
|
private readonly vertexVeoGcpService;
|
|
@@ -22,7 +22,7 @@ export declare class VertexVideoImageAdapterController {
|
|
|
22
22
|
id: string;
|
|
23
23
|
}[] | undefined>;
|
|
24
24
|
generateVideo(generateVideoDto: GenerateVideoDto, provider?: string): Promise<any>;
|
|
25
|
-
generateVideoFromAsset(id: string): Promise<import("
|
|
25
|
+
generateVideoFromAsset(id: string): Promise<import("../../models/generated-asset.entity").GeneratedAssetDocument | {
|
|
26
26
|
status: string;
|
|
27
27
|
message: string;
|
|
28
28
|
} | null>;
|
package/controllers/{video-gen-adapter.controller.js → video/video-gen-adapter.controller.js}
RENAMED
|
@@ -15,15 +15,15 @@ var VertexVideoImageAdapterController_1;
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.VertexVideoImageAdapterController = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
|
-
const vertex_image_video_service_1 = require("
|
|
19
|
-
const generate_video_dto_1 = require("
|
|
20
|
-
const get_veo_video_status_dto_1 = require("
|
|
21
|
-
const vertex_veo_gcp_service_1 = require("
|
|
18
|
+
const vertex_image_video_service_1 = require("../../services/vertex-image-video.service");
|
|
19
|
+
const generate_video_dto_1 = require("../../dto/generate-video.dto");
|
|
20
|
+
const get_veo_video_status_dto_1 = require("../../dto/get-veo-video-status.dto");
|
|
21
|
+
const vertex_veo_gcp_service_1 = require("../../services/vertex-veo-gcp.service");
|
|
22
22
|
const swagger_1 = require("@nestjs/swagger");
|
|
23
|
-
const generated_asset_service_1 = require("
|
|
24
|
-
const comfy_video_service_1 = require("
|
|
25
|
-
const vertex_veo_genai_service_1 = require("
|
|
26
|
-
const comfy_sdk_service_1 = require("
|
|
23
|
+
const generated_asset_service_1 = require("../../services/generated-asset.service");
|
|
24
|
+
const comfy_video_service_1 = require("../../comfyui/services/comfy-video.service");
|
|
25
|
+
const vertex_veo_genai_service_1 = require("../../services/vertex-veo-genai.service");
|
|
26
|
+
const comfy_sdk_service_1 = require("../../comfyui/services/comfy-sdk.service");
|
|
27
27
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
28
28
|
let VertexVideoImageAdapterController = VertexVideoImageAdapterController_1 = class VertexVideoImageAdapterController {
|
|
29
29
|
vertexImageVideoService;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChatMessageDict, IAIModel } from '../models/adapter.models';
|
|
2
|
+
import { TierType } from '../models/key-balancer.models';
|
|
3
|
+
export declare class ConversationDTO {
|
|
4
|
+
id?: string;
|
|
5
|
+
entityId?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
createdAt?: Date;
|
|
8
|
+
messages: Array<ChatMessageDict>;
|
|
9
|
+
transcription?: boolean;
|
|
10
|
+
model?: IAIModel;
|
|
11
|
+
tierType?: TierType;
|
|
12
|
+
returnJson?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationDTO = void 0;
|
|
4
|
+
class ConversationDTO {
|
|
5
|
+
id;
|
|
6
|
+
entityId;
|
|
7
|
+
type;
|
|
8
|
+
createdAt;
|
|
9
|
+
messages;
|
|
10
|
+
transcription;
|
|
11
|
+
model;
|
|
12
|
+
tierType;
|
|
13
|
+
returnJson;
|
|
14
|
+
}
|
|
15
|
+
exports.ConversationDTO = ConversationDTO;
|
|
16
|
+
//# sourceMappingURL=conversation.dto.js.map
|
package/dto/generate-text.dto.js
CHANGED
|
@@ -15,14 +15,22 @@ const message_llm_dto_1 = require("./message-llm.dto");
|
|
|
15
15
|
class GenerateTextDto {
|
|
16
16
|
messages;
|
|
17
17
|
keyType;
|
|
18
|
+
model;
|
|
18
19
|
}
|
|
19
20
|
exports.GenerateTextDto = GenerateTextDto;
|
|
20
21
|
__decorate([
|
|
21
|
-
(0, swagger_1.ApiProperty)({
|
|
22
|
+
(0, swagger_1.ApiProperty)({
|
|
23
|
+
type: [message_llm_dto_1.MessageLLMDto],
|
|
24
|
+
default: [{ role: 'user', content: 'tell me 5 contries in latin america' }],
|
|
25
|
+
}),
|
|
22
26
|
__metadata("design:type", Array)
|
|
23
27
|
], GenerateTextDto.prototype, "messages", void 0);
|
|
24
28
|
__decorate([
|
|
25
29
|
(0, swagger_1.ApiProperty)({ required: false }),
|
|
26
30
|
__metadata("design:type", String)
|
|
27
31
|
], GenerateTextDto.prototype, "keyType", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, swagger_1.ApiProperty)({ required: false, description: 'The model to use for the chat completion.' }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], GenerateTextDto.prototype, "model", void 0);
|
|
28
36
|
//# sourceMappingURL=generate-text.dto.js.map
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './nest-vertex.module';
|
|
2
|
-
export * from './controllers/vertex-tts-adapter.controller';
|
|
2
|
+
export * from './controllers/tts/vertex-tts-adapter.controller';
|
|
3
3
|
export * from './controllers/generated-assets.controller';
|
|
4
4
|
export * from './services/vertex-image-video.service';
|
|
5
5
|
export * from './services/vertex-tts.service';
|
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./nest-vertex.module"), exports);
|
|
18
|
-
__exportStar(require("./controllers/vertex-tts-adapter.controller"), exports);
|
|
18
|
+
__exportStar(require("./controllers/tts/vertex-tts-adapter.controller"), exports);
|
|
19
19
|
__exportStar(require("./controllers/generated-assets.controller"), exports);
|
|
20
20
|
__exportStar(require("./services/vertex-image-video.service"), exports);
|
|
21
21
|
__exportStar(require("./services/vertex-tts.service"), exports);
|
package/models/adapter.models.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.EModelQuality = exports.DescribeImageRequestAdapter = exports.ImageGenRequestAdapter = exports.ImageGenAdapterResponseWithDebug = exports.ImageGenAdapterResponse = exports.ChatMessageDict = exports.ChatRole = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const gemini_models_1 = require("./gemini-models");
|
|
15
16
|
var ChatRole;
|
|
16
17
|
(function (ChatRole) {
|
|
17
18
|
ChatRole["System"] = "system";
|
|
@@ -50,21 +51,64 @@ class ImageGenRequestAdapter {
|
|
|
50
51
|
}
|
|
51
52
|
exports.ImageGenRequestAdapter = ImageGenRequestAdapter;
|
|
52
53
|
__decorate([
|
|
54
|
+
(0, swagger_1.ApiProperty)({ example: 'google', description: 'The provider for the image generation service (e.g., "local", "google")' }),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], ImageGenRequestAdapter.prototype, "provider", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, swagger_1.ApiProperty)({ example: gemini_models_1.GeminiImageModels.Image3_0, description: 'The model to use for image generation.', required: false }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], ImageGenRequestAdapter.prototype, "model", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, swagger_1.ApiProperty)({ example: 'A beautiful landscape with a river and mountains.', description: 'The prompt for image generation.' }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], ImageGenRequestAdapter.prototype, "prompt", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({ example: 1, description: 'The number of images to generate.', default: 1, required: false }),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], ImageGenRequestAdapter.prototype, "numberOfImages", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, swagger_1.ApiProperty)({
|
|
71
|
+
example: '16:9',
|
|
72
|
+
description: 'The aspect ratio of the generated images.',
|
|
73
|
+
enum: ['1:1', '16:9', '9:16', '3:4', '4:3'],
|
|
74
|
+
default: '16:9',
|
|
75
|
+
required: false,
|
|
76
|
+
}),
|
|
53
77
|
(0, class_validator_1.IsEnum)(['1:1', '16:9', '9:16', '3:4', '4:3'], { message: 'aspectRatio must be one of "1:1", "16:9", "9:16", "3:4", "4:3"' }),
|
|
54
78
|
__metadata("design:type", String)
|
|
55
79
|
], ImageGenRequestAdapter.prototype, "aspectRatio", void 0);
|
|
56
80
|
__decorate([
|
|
57
|
-
(0, swagger_1.ApiProperty)({ example: 'bad art, ugly', description: 'The negative prompt for image generation.' }),
|
|
81
|
+
(0, swagger_1.ApiProperty)({ example: 'bad art, ugly', description: 'The negative prompt for image generation.', required: false }),
|
|
58
82
|
__metadata("design:type", String)
|
|
59
83
|
], ImageGenRequestAdapter.prototype, "negativePrompt", void 0);
|
|
60
84
|
__decorate([
|
|
61
|
-
(0, swagger_1.ApiProperty)({ example:
|
|
85
|
+
(0, swagger_1.ApiProperty)({ example: 12345, description: 'The seed for image generation.', required: false }),
|
|
86
|
+
__metadata("design:type", Number)
|
|
87
|
+
], ImageGenRequestAdapter.prototype, "seed", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, swagger_1.ApiProperty)({ example: 1024, description: 'The width of the image.', required: false }),
|
|
90
|
+
__metadata("design:type", Number)
|
|
91
|
+
], ImageGenRequestAdapter.prototype, "width", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, swagger_1.ApiProperty)({ example: 1024, description: 'The height of the image.', required: false }),
|
|
94
|
+
__metadata("design:type", Number)
|
|
95
|
+
], ImageGenRequestAdapter.prototype, "height", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, swagger_1.ApiProperty)({ example: 'dpmpp_2m', description: 'The sampler name for image generation (for local provider).', required: false }),
|
|
62
98
|
__metadata("design:type", String)
|
|
63
99
|
], ImageGenRequestAdapter.prototype, "samplerName", void 0);
|
|
64
100
|
__decorate([
|
|
65
|
-
(0, swagger_1.ApiProperty)({ example: '', description: 'The scheduler for image generation.' }),
|
|
101
|
+
(0, swagger_1.ApiProperty)({ example: 'karras', description: 'The scheduler for image generation (for local provider).', required: false }),
|
|
66
102
|
__metadata("design:type", String)
|
|
67
103
|
], ImageGenRequestAdapter.prototype, "scheduler", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, swagger_1.ApiProperty)({ example: 20, description: 'The number of steps for image generation (for local provider).', required: false }),
|
|
106
|
+
__metadata("design:type", Number)
|
|
107
|
+
], ImageGenRequestAdapter.prototype, "steps", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, swagger_1.ApiProperty)({ example: 7, description: 'The CFG scale for image generation (for local provider).', required: false }),
|
|
110
|
+
__metadata("design:type", Number)
|
|
111
|
+
], ImageGenRequestAdapter.prototype, "cfg", void 0);
|
|
68
112
|
class DescribeImageRequestAdapter {
|
|
69
113
|
url;
|
|
70
114
|
prompt;
|
package/nest-vertex.module.js
CHANGED
|
@@ -9,18 +9,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.NestVertexModule = void 0;
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
11
|
const vertex_image_video_service_1 = require("./services/vertex-image-video.service");
|
|
12
|
-
const vertex_image_adapter_controller_1 = require("./controllers/vertex-image-adapter.controller");
|
|
12
|
+
const vertex_image_adapter_controller_1 = require("./controllers/image/vertex-image-adapter.controller");
|
|
13
13
|
const vertex_tts_service_1 = require("./services/vertex-tts.service");
|
|
14
|
-
const vertex_tts_adapter_controller_1 = require("./controllers/vertex-tts-adapter.controller");
|
|
14
|
+
const vertex_tts_adapter_controller_1 = require("./controllers/tts/vertex-tts-adapter.controller");
|
|
15
15
|
const vertex_gemini_chat_service_1 = require("./services/vertex-gemini-chat.service");
|
|
16
|
-
const
|
|
16
|
+
const llm_gemini_chat_controller_1 = require("./controllers/llm/llm-gemini-chat.controller");
|
|
17
17
|
const vertex_image_service_1 = require("./services/vertex-image.service");
|
|
18
18
|
const ai_sdk_chat_service_1 = require("./services/ai-sdk-chat.service");
|
|
19
19
|
const adapter_llm_service_1 = require("./services/adapter-llm.service");
|
|
20
20
|
const adapter_image_gen_service_1 = require("./services/adapter-image-gen.service");
|
|
21
21
|
const adapter_audio_gen_service_1 = require("./services/adapter-audio-gen.service");
|
|
22
|
-
const
|
|
23
|
-
const vertex_llm_adapter_controller_1 = require("./controllers/vertex-llm-adapter.controller");
|
|
22
|
+
const llm_adapter_controller_1 = require("./controllers/llm/llm-adapter.controller");
|
|
24
23
|
const vertex_veo_gcp_service_1 = require("./services/vertex-veo-gcp.service");
|
|
25
24
|
const axios_1 = require("@nestjs/axios");
|
|
26
25
|
const nest_mongo_1 = require("@dataclouder/nest-mongo");
|
|
@@ -33,16 +32,19 @@ const vertex_comfy_controller_1 = require("./controllers/vertex-comfy.controller
|
|
|
33
32
|
const key_balancer_api_service_1 = require("./services/key-balancer-api.service");
|
|
34
33
|
const comfyui_module_1 = require("./comfyui/comfyui.module");
|
|
35
34
|
const vertex_veo_genai_service_1 = require("./services/vertex-veo-genai.service");
|
|
36
|
-
const veo_video_controller_1 = require("./controllers/veo-video.controller");
|
|
35
|
+
const veo_video_controller_1 = require("./controllers/video/veo-video.controller");
|
|
37
36
|
const google_genai_service_1 = require("./services/google-genai.service");
|
|
38
|
-
const groq_stt_controller_1 = require("./controllers/groq-stt.controller");
|
|
37
|
+
const groq_stt_controller_1 = require("./controllers/stt/groq-stt.controller");
|
|
39
38
|
const groq_service_1 = require("./services/whisper/groq.service");
|
|
40
39
|
const comfy_sdk_service_1 = require("./comfyui/services/comfy-sdk.service");
|
|
41
|
-
const vertex_gemini_tts_controller_1 = require("./controllers/vertex-gemini-tts.controller");
|
|
40
|
+
const vertex_gemini_tts_controller_1 = require("./controllers/tts/vertex-gemini-tts.controller");
|
|
42
41
|
const vertex_gemini_tts_service_1 = require("./services/vertex-gemini-tts.service");
|
|
43
42
|
const drizzle_module_1 = require("./drizzle/drizzle.module");
|
|
44
43
|
const nest_auth_1 = require("@dataclouder/nest-auth");
|
|
45
44
|
const metric_ai_service_1 = require("./services/metric-ai.service");
|
|
45
|
+
const groq_llm_service_1 = require("./services/llm/groq-llm.service");
|
|
46
|
+
const groq_llm_controller_1 = require("./controllers/llm/groq-llm.controller");
|
|
47
|
+
const video_gen_adapter_controller_1 = require("./controllers/video/video-gen-adapter.controller");
|
|
46
48
|
let NestVertexModule = class NestVertexModule {
|
|
47
49
|
};
|
|
48
50
|
exports.NestVertexModule = NestVertexModule;
|
|
@@ -75,6 +77,7 @@ exports.NestVertexModule = NestVertexModule = __decorate([
|
|
|
75
77
|
comfy_sdk_service_1.ComfySDKService,
|
|
76
78
|
vertex_gemini_tts_service_1.VertexGeminiTtsService,
|
|
77
79
|
metric_ai_service_1.MetricAIService,
|
|
80
|
+
groq_llm_service_1.GroqLlmService,
|
|
78
81
|
],
|
|
79
82
|
exports: [
|
|
80
83
|
vertex_image_video_service_1.VertexImageVideoService,
|
|
@@ -96,13 +99,15 @@ exports.NestVertexModule = NestVertexModule = __decorate([
|
|
|
96
99
|
vertex_gemini_tts_service_1.VertexGeminiTtsService,
|
|
97
100
|
drizzle_module_1.DrizzleModule,
|
|
98
101
|
metric_ai_service_1.MetricAIService,
|
|
102
|
+
groq_llm_service_1.GroqLlmService,
|
|
99
103
|
],
|
|
100
104
|
controllers: [
|
|
101
105
|
vertex_image_adapter_controller_1.VertexImageVideoAdapterController,
|
|
102
|
-
|
|
106
|
+
llm_gemini_chat_controller_1.GeminiChatController,
|
|
107
|
+
groq_llm_controller_1.GroqLlmController,
|
|
103
108
|
video_gen_adapter_controller_1.VertexVideoImageAdapterController,
|
|
104
109
|
vertex_tts_adapter_controller_1.VertexTtsAdapterController,
|
|
105
|
-
|
|
110
|
+
llm_adapter_controller_1.VertexAdapterLLMController,
|
|
106
111
|
generated_assets_controller_1.GeneratedAssetsController,
|
|
107
112
|
vertex_comfy_controller_1.VertexComfyController,
|
|
108
113
|
veo_video_controller_1.VertexVeoGenerationController,
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeminiChatService } from './vertex-gemini-chat.service';
|
|
2
2
|
import { ChatLLMRequestAdapter, ChatMessageDict, DescribeImageRequestAdapter, GeneratedTextAdapter, IModelAdapterMethods } from '../models/adapter.models';
|
|
3
|
+
import { ConversationDTO } from '../dto/conversation.dto';
|
|
3
4
|
export declare class LLMAdapterService implements IModelAdapterMethods {
|
|
4
5
|
private geminiChatService;
|
|
5
6
|
private readonly logger;
|
|
@@ -7,7 +8,7 @@ export declare class LLMAdapterService implements IModelAdapterMethods {
|
|
|
7
8
|
listModels(provider?: string): Promise<Record<string, string>[]>;
|
|
8
9
|
generate(request: ChatLLMRequestAdapter): Promise<any>;
|
|
9
10
|
private getDefaultModel;
|
|
10
|
-
chat(request: ChatLLMRequestAdapter): Promise<ChatMessageDict>;
|
|
11
|
+
chat(request: ChatLLMRequestAdapter | ConversationDTO): Promise<ChatMessageDict>;
|
|
11
12
|
chatAndExtractJson(request: ChatLLMRequestAdapter): Promise<{
|
|
12
13
|
json: any;
|
|
13
14
|
metadata: any;
|
|
@@ -45,12 +45,16 @@ let LLMAdapterService = LLMAdapterService_1 = class LLMAdapterService {
|
|
|
45
45
|
return '';
|
|
46
46
|
}
|
|
47
47
|
chat(request) {
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
return this.geminiChatService.chat(request.messages, model, request.keyType);
|
|
48
|
+
const provider = request.model?.provider || 'google';
|
|
49
|
+
if (provider !== 'google') {
|
|
50
|
+
throw new Error('Provider not supported');
|
|
52
51
|
}
|
|
53
|
-
|
|
52
|
+
if ('id' in request || 'entityId' in request || 'transcription' in request) {
|
|
53
|
+
return this.geminiChatService.chatWithConversation(request);
|
|
54
|
+
}
|
|
55
|
+
const chatRequest = request;
|
|
56
|
+
const model = this.getDefaultModel(chatRequest?.model);
|
|
57
|
+
return this.geminiChatService.chat(chatRequest.messages, model, chatRequest.keyType);
|
|
54
58
|
}
|
|
55
59
|
async chatAndExtractJson(request) {
|
|
56
60
|
const response = await this.chat(request);
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AvailableKeyResult, ModelType, TierType } from '../models/key-balancer.models';
|
|
1
|
+
import { ModelType, TierType } from '../models/key-balancer.models';
|
|
3
2
|
import { KeyBalancerClientService } from './key-balancer-api.service';
|
|
4
3
|
interface GeminiClientRequest {
|
|
5
4
|
model: string;
|
|
6
5
|
keyTierType: TierType;
|
|
7
|
-
aiType
|
|
6
|
+
aiType?: ModelType;
|
|
7
|
+
}
|
|
8
|
+
interface GeminiClientRequest {
|
|
9
|
+
model: string;
|
|
10
|
+
keyTierType: TierType;
|
|
11
|
+
aiType?: ModelType;
|
|
8
12
|
}
|
|
9
13
|
export declare class GoogleGenaiService {
|
|
10
14
|
private readonly keyBalancerClient;
|
|
11
15
|
private readonly logger;
|
|
12
16
|
private readonly defaultApiKey;
|
|
13
17
|
constructor(keyBalancerClient: KeyBalancerClientService);
|
|
14
|
-
getGoogleGenAIClient(request: GeminiClientRequest): Promise<
|
|
15
|
-
client: GoogleGenAI;
|
|
16
|
-
balancedKey?: AvailableKeyResult;
|
|
17
|
-
}>;
|
|
18
|
+
getGoogleGenAIClient(request: GeminiClientRequest): Promise<any>;
|
|
18
19
|
}
|
|
19
20
|
export {};
|
|
@@ -28,25 +28,39 @@ let GoogleGenaiService = GoogleGenaiService_1 = class GoogleGenaiService {
|
|
|
28
28
|
}
|
|
29
29
|
async getGoogleGenAIClient(request) {
|
|
30
30
|
this.logger.warn('⚖️ getGoogleGenAIClient() Requesting key from Balancer 🗝️ ');
|
|
31
|
-
if (process.env.KEY_BALANCER_HOST
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
if (process.env.KEY_BALANCER_HOST) {
|
|
32
|
+
try {
|
|
33
|
+
const balancedKey = await this.keyBalancerClient.getBestKey({
|
|
34
|
+
provider: 'google',
|
|
35
|
+
service: request.model,
|
|
36
|
+
tierType: request.keyTierType,
|
|
37
|
+
}, null);
|
|
38
|
+
if (balancedKey?.key) {
|
|
39
|
+
this.logger.debug(`⚖️ Using balanced key: ${balancedKey.id}) ${balancedKey.name} - ${balancedKey.key} `);
|
|
40
|
+
return {
|
|
41
|
+
client: new genai_1.GoogleGenAI({ apiKey: balancedKey.key }),
|
|
42
|
+
balancedKey: balancedKey,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
40
45
|
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.logger.error(`Failed to get balanced key: ${error.message}`);
|
|
48
|
+
const randomKey = process.env.GEMINI_API_KEY;
|
|
49
|
+
console.log(`⚖️ Using random key ::::::::: ${randomKey} 🚨🚨🚨🚨🚨🚨`);
|
|
50
|
+
return {
|
|
51
|
+
client: new genai_1.GoogleGenAI({ apiKey: randomKey }),
|
|
52
|
+
balancedKey: null,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!this.defaultApiKey) {
|
|
56
|
+
throw new nest_core_1.AppException({
|
|
57
|
+
error_message: 'No API keys available',
|
|
58
|
+
explanation: 'All balanced keys are rate-limited or failing, and no default GEMINI_API_KEY is configured.',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
this.logger.warn('No balanced keys available. Falling back to default API key.');
|
|
62
|
+
return { client: new genai_1.GoogleGenAI({ apiKey: this.defaultApiKey }), balancedKey: null };
|
|
41
63
|
}
|
|
42
|
-
if (!this.defaultApiKey) {
|
|
43
|
-
throw new nest_core_1.AppException({
|
|
44
|
-
error_message: 'No API keys available',
|
|
45
|
-
explanation: 'All balanced keys are rate-limited or failing, and no default GEMINI_API_KEY is configured.',
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
this.logger.warn('No balanced keys available. Falling back to default API key.');
|
|
49
|
-
return { client: new genai_1.GoogleGenAI({ apiKey: this.defaultApiKey }), balancedKey: null };
|
|
50
64
|
}
|
|
51
65
|
};
|
|
52
66
|
exports.GoogleGenaiService = GoogleGenaiService;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Groq from 'groq-sdk';
|
|
2
|
+
import { KeyBalancerClientService } from '../key-balancer-api.service';
|
|
3
|
+
export declare class GroqLlmService {
|
|
4
|
+
private readonly keyBalancer;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(keyBalancer: KeyBalancerClientService);
|
|
7
|
+
private getClientWithKey;
|
|
8
|
+
getGroqChatCompletion(messages: Groq.Chat.Completions.ChatCompletionMessageParam[], model?: string): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var GroqLlmService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.GroqLlmService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const groq_sdk_1 = __importDefault(require("groq-sdk"));
|
|
19
|
+
const key_balancer_api_service_1 = require("../key-balancer-api.service");
|
|
20
|
+
const GroqModels = {
|
|
21
|
+
Llama_4_Maverick_17B_128E_INSTRUCT: 'meta-llama/llama-4-maverick-17b-128e-instruct',
|
|
22
|
+
Llama_4_Scout_17B_16E_INSTRUCT: 'meta-llama/llama-4-scout-17b-16e-instruct',
|
|
23
|
+
GPT_OSS_20B: 'openai/gpt-oss-20b',
|
|
24
|
+
GPT_OSS_120B: 'openai/gpt-oss-120b',
|
|
25
|
+
QWEN_3_32B: 'qwen/qwen3-32b',
|
|
26
|
+
Llama_3_3_70B_Versatile: 'llama-3.3-70b-versatile',
|
|
27
|
+
};
|
|
28
|
+
let GroqLlmService = GroqLlmService_1 = class GroqLlmService {
|
|
29
|
+
keyBalancer;
|
|
30
|
+
logger = new common_1.Logger(GroqLlmService_1.name);
|
|
31
|
+
constructor(keyBalancer) {
|
|
32
|
+
this.keyBalancer = keyBalancer;
|
|
33
|
+
}
|
|
34
|
+
getClientWithKey(key) {
|
|
35
|
+
return new groq_sdk_1.default({ apiKey: key });
|
|
36
|
+
}
|
|
37
|
+
async getGroqChatCompletion(messages, model = 'mixtral-8x7b-32768') {
|
|
38
|
+
this.logger.log(`Getting chat completion with model: ${model}`);
|
|
39
|
+
try {
|
|
40
|
+
const groq = this.getClientWithKey('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');
|
|
41
|
+
const chatCompletion = await groq.chat.completions.create({
|
|
42
|
+
messages,
|
|
43
|
+
model: GroqModels.Llama_4_Scout_17B_16E_INSTRUCT,
|
|
44
|
+
});
|
|
45
|
+
console.log('Groq Chat Completion:');
|
|
46
|
+
console.log(chatCompletion.choices[0].message);
|
|
47
|
+
return { ...chatCompletion.choices[0].message, metadata: {} };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
this.logger.error(`Error during chat completion:`, error?.error || error);
|
|
51
|
+
const errorMessage = error?.error?.message || (error instanceof Error ? error.message : 'Unknown error during chat completion');
|
|
52
|
+
throw new Error(`Failed to get chat completion: ${errorMessage}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.GroqLlmService = GroqLlmService;
|
|
57
|
+
exports.GroqLlmService = GroqLlmService = GroqLlmService_1 = __decorate([
|
|
58
|
+
(0, common_1.Injectable)(),
|
|
59
|
+
__metadata("design:paramtypes", [key_balancer_api_service_1.KeyBalancerClientService])
|
|
60
|
+
], GroqLlmService);
|
|
61
|
+
//# sourceMappingURL=groq-llm.service.js.map
|
|
@@ -2,6 +2,7 @@ import { ChatMessageDict, MessageLLM, EModelQuality, DescribeImageRequestAdapter
|
|
|
2
2
|
import { TierType } from '../models/key-balancer.models';
|
|
3
3
|
import { KeyBalancerClientService } from './key-balancer-api.service';
|
|
4
4
|
import { GoogleGenaiService } from './google-genai.service';
|
|
5
|
+
import { ConversationDTO } from '../dto/conversation.dto';
|
|
5
6
|
export declare class GeminiChatService {
|
|
6
7
|
private readonly keyBalancer;
|
|
7
8
|
private readonly googleGenaiService;
|
|
@@ -17,4 +18,5 @@ export declare class GeminiChatService {
|
|
|
17
18
|
private _extractJsonWithRecovery;
|
|
18
19
|
chatAndExtractJson(messages: MessageLLM[], model?: string, keyType?: TierType): Promise<ChatJsonResponse>;
|
|
19
20
|
describeImageByUrl(dto: DescribeImageRequestAdapter): Promise<any>;
|
|
21
|
+
chatWithConversation(conversation: ConversationDTO): Promise<ChatMessageDict>;
|
|
20
22
|
}
|
|
@@ -60,7 +60,6 @@ let GeminiChatService = GeminiChatService_1 = class GeminiChatService {
|
|
|
60
60
|
const { client, balancedKey } = await this.googleGenaiService.getGoogleGenAIClient({
|
|
61
61
|
model: model,
|
|
62
62
|
keyTierType: keyType || key_balancer_models_1.TierType.FREE_TIER,
|
|
63
|
-
aiType: key_balancer_models_1.ModelType.LLM,
|
|
64
63
|
});
|
|
65
64
|
try {
|
|
66
65
|
const systemMessage = messages
|
|
@@ -105,6 +104,7 @@ let GeminiChatService = GeminiChatService_1 = class GeminiChatService {
|
|
|
105
104
|
};
|
|
106
105
|
}
|
|
107
106
|
catch (error) {
|
|
107
|
+
this.logger.error(`First Error Gemini Gemini {${balancedKey?.key} chat.sendMessage failed: ${error.message}`, client['apiClient']);
|
|
108
108
|
if (error instanceof nest_core_1.AppException) {
|
|
109
109
|
throw error;
|
|
110
110
|
}
|
|
@@ -210,7 +210,7 @@ let GeminiChatService = GeminiChatService_1 = class GeminiChatService {
|
|
|
210
210
|
return json;
|
|
211
211
|
}
|
|
212
212
|
catch (initialError) {
|
|
213
|
-
this.logger.warn(
|
|
213
|
+
this.logger.warn(`👩🔧 Initial JSON extraction failed: 🧑🔧 ${initialError.message}. Attempting recovery.`);
|
|
214
214
|
try {
|
|
215
215
|
const fixPrompt = `I cant extract the json from the following text, something is wrong, please analyze the following text, correct any JSON formatting errors invalid characters or whatever thing is wrong, change or complete the text if needed, and return ONLY the valid JSON object or array. Do not include any explanatory text before or after the JSON itself. JSON to fix: ${responseText}`;
|
|
216
216
|
const fixResponse = await this.chat([{ role: adapter_models_1.ChatRole.User, content: fixPrompt }], model, keyType);
|
|
@@ -284,6 +284,41 @@ let GeminiChatService = GeminiChatService_1 = class GeminiChatService {
|
|
|
284
284
|
}
|
|
285
285
|
return this._extractJsonWithRecovery(visionResponseText, textModelForFix);
|
|
286
286
|
}
|
|
287
|
+
async chatWithConversation(conversation) {
|
|
288
|
+
const startTime = Date.now();
|
|
289
|
+
if (!conversation?.model) {
|
|
290
|
+
conversation.model = { provider: 'google', modelName: gemini_models_1.GeminiModels.Gemini2_5Lite, id: 'no-id' };
|
|
291
|
+
}
|
|
292
|
+
const tierType = conversation.tierType || key_balancer_models_1.TierType.TIER_1;
|
|
293
|
+
if (conversation?.model?.quality) {
|
|
294
|
+
conversation.model.provider = 'google';
|
|
295
|
+
conversation.model.modelName = this.getDefaultQualityModel(conversation.model.quality);
|
|
296
|
+
}
|
|
297
|
+
const returnJson = conversation.returnJson;
|
|
298
|
+
if (returnJson) {
|
|
299
|
+
const obj = await this.chatAndExtractJson(conversation.messages, conversation.model.modelName, tierType);
|
|
300
|
+
const endTime = Date.now();
|
|
301
|
+
const processTime = (endTime - startTime) / 1000;
|
|
302
|
+
const metadata = {
|
|
303
|
+
type: 'json',
|
|
304
|
+
provider: conversation.model.provider,
|
|
305
|
+
model: conversation.model.modelName,
|
|
306
|
+
processTime,
|
|
307
|
+
...obj?.metadata,
|
|
308
|
+
};
|
|
309
|
+
return { content: obj.json, role: adapter_models_1.ChatRole.Assistant, metadata };
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const response = await this.chat(conversation.messages, conversation.model.modelName, tierType);
|
|
313
|
+
const endTime = Date.now();
|
|
314
|
+
const processTime = (endTime - startTime) / 1000;
|
|
315
|
+
return {
|
|
316
|
+
content: response.content,
|
|
317
|
+
role: response.role,
|
|
318
|
+
metadata: { provider: conversation.model.provider, model: conversation.model.modelName, processTime, tokens: response.metadata.tokens },
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
}
|
|
287
322
|
};
|
|
288
323
|
exports.GeminiChatService = GeminiChatService;
|
|
289
324
|
exports.GeminiChatService = GeminiChatService = GeminiChatService_1 = __decorate([
|
|
@@ -21,7 +21,7 @@ let ImageVertexService = ImageVertexService_1 = class ImageVertexService {
|
|
|
21
21
|
keyBalancerApiService;
|
|
22
22
|
logger = new common_1.Logger(ImageVertexService_1.name);
|
|
23
23
|
imageModelName = gemini_models_1.GeminiImageModels.Image3_0;
|
|
24
|
-
gemini_key = '';
|
|
24
|
+
gemini_key = process.env.GEMINI_API_KEY || '';
|
|
25
25
|
constructor(keyBalancerApiService) {
|
|
26
26
|
this.keyBalancerApiService = keyBalancerApiService;
|
|
27
27
|
if (this.gemini_key) {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { GeminiChatService } from '../services/vertex-gemini-chat.service';
|
|
2
|
-
import { GenerateTextDto } from '../dto/generate-text.dto';
|
|
3
|
-
import { ChatMessageDict, IAIModel } from '../models/adapter.models';
|
|
4
|
-
export declare class ConversationDTO {
|
|
5
|
-
id?: string;
|
|
6
|
-
entityId?: string;
|
|
7
|
-
type?: string;
|
|
8
|
-
createdAt?: Date;
|
|
9
|
-
messages: Array<ChatMessageDict>;
|
|
10
|
-
transcription?: boolean;
|
|
11
|
-
model?: IAIModel;
|
|
12
|
-
returnJson?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class GeminiChatController {
|
|
15
|
-
private readonly geminiChatService;
|
|
16
|
-
private readonly logger;
|
|
17
|
-
constructor(geminiChatService: GeminiChatService);
|
|
18
|
-
generateText(generateTextDto: GenerateTextDto): Promise<ChatMessageDict>;
|
|
19
|
-
continueConversation(conversation: ConversationDTO): Promise<ChatMessageDict>;
|
|
20
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ChatLLMRequestAdapter, DescribeImageRequestAdapter } from '../models/adapter.models';
|
|
2
|
-
import { LLMAdapterService } from '../services/adapter-llm.service';
|
|
3
|
-
export declare class VertexAdapterLLMController {
|
|
4
|
-
private readonly llmAdapterService;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
constructor(llmAdapterService: LLMAdapterService);
|
|
7
|
-
generateText(request: ChatLLMRequestAdapter): Promise<any>;
|
|
8
|
-
describeImage(request: DescribeImageRequestAdapter): Promise<import("../models/adapter.models").GeneratedTextAdapter>;
|
|
9
|
-
}
|