@dataclouder/nest-vertex 0.0.63 → 0.0.66
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/comfyui/services/comfy-sdk.service.js +0 -1
- package/controllers/llm/groq-llm.controller.d.ts +2 -2
- package/controllers/llm/groq-llm.controller.js +6 -6
- package/controllers/llm/llm-adapter.controller.d.ts +1 -2
- package/controllers/llm/llm-adapter.controller.js +5 -2
- package/controllers/llm/llm-gemini-chat.controller.d.ts +3 -4
- package/controllers/llm/llm-gemini-chat.controller.js +7 -8
- package/controllers/tts/vertex-tts-adapter.controller.js +1 -0
- package/models/adapter.models.d.ts +10 -0
- package/models/adapter.models.js +39 -1
- package/package.json +1 -1
- package/services/adapter-llm.service.d.ts +2 -6
- package/services/adapter-llm.service.js +4 -8
- package/services/ai-services.client.d.ts +2 -2
- package/services/ai-services.client.js +0 -1
- package/services/key-balancer-api.service.js +8 -2
- package/services/vertex-gemini-chat.service.d.ts +2 -3
- package/services/vertex-veo-genai.service.js +2 -0
- package/services/whisper/groq.service.js +1 -1
- package/dto/conversation.dto.d.ts +0 -13
- package/dto/conversation.dto.js +0 -16
- package/dto/generate-text.dto.d.ts +0 -6
- package/dto/generate-text.dto.js +0 -36
|
@@ -184,7 +184,6 @@ let ComfySDKService = ComfySDKService_1 = class ComfySDKService {
|
|
|
184
184
|
const storageFinalPath = `${storageFolder}/${storageFileName}`;
|
|
185
185
|
console.log(' -> 📼 Saving video to storage path:', storageFinalPath);
|
|
186
186
|
const storageService = this.storageFactory.getStorageService('CLOUDFLARE');
|
|
187
|
-
console.log(' -> USING STORAGE SERVICE:', storageService);
|
|
188
187
|
const options = { fileName: storageFinalPath, fileBuffer: videoBuffer, contentType: 'video/mp4' };
|
|
189
188
|
const uploadResult = await storageService.uploadPublicFile(options);
|
|
190
189
|
this.logger.log(`Successfully uploaded video to: ${uploadResult.url}`);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GroqLlmService } from '../../services/llm/groq-llm.service';
|
|
2
|
-
import {
|
|
2
|
+
import { ChatLLMRequestAdapterDto } from '../../models/adapter.models';
|
|
3
3
|
import Groq from 'groq-sdk';
|
|
4
4
|
export declare class GroqLlmController {
|
|
5
5
|
private readonly groqLlmService;
|
|
6
6
|
private readonly logger;
|
|
7
7
|
constructor(groqLlmService: GroqLlmService);
|
|
8
|
-
generateText(
|
|
8
|
+
generateText(ChatLLMRequestAdapterDto: ChatLLMRequestAdapterDto): Promise<Groq.Chat.Completions.ChatCompletion>;
|
|
9
9
|
}
|
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.GroqLlmController = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const groq_llm_service_1 = require("../../services/llm/groq-llm.service");
|
|
19
|
-
const
|
|
19
|
+
const adapter_models_1 = require("../../models/adapter.models");
|
|
20
20
|
const swagger_1 = require("@nestjs/swagger");
|
|
21
21
|
let GroqLlmController = GroqLlmController_1 = class GroqLlmController {
|
|
22
22
|
groqLlmService;
|
|
@@ -24,15 +24,15 @@ let GroqLlmController = GroqLlmController_1 = class GroqLlmController {
|
|
|
24
24
|
constructor(groqLlmService) {
|
|
25
25
|
this.groqLlmService = groqLlmService;
|
|
26
26
|
}
|
|
27
|
-
async generateText(
|
|
28
|
-
this.logger.log(`Received request to generate text with model: ${
|
|
29
|
-
const messages =
|
|
27
|
+
async generateText(ChatLLMRequestAdapterDto) {
|
|
28
|
+
this.logger.log(`Received request to generate text with model: ${ChatLLMRequestAdapterDto.model}`);
|
|
29
|
+
const messages = ChatLLMRequestAdapterDto.messages
|
|
30
30
|
.filter(message => ['system', 'user', 'assistant'].includes(message.role))
|
|
31
31
|
.map(message => ({
|
|
32
32
|
role: message.role,
|
|
33
33
|
content: message.content,
|
|
34
34
|
}));
|
|
35
|
-
return this.groqLlmService.getGroqChatCompletion(messages,
|
|
35
|
+
return this.groqLlmService.getGroqChatCompletion(messages, ChatLLMRequestAdapterDto.model?.modelName);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
exports.GroqLlmController = GroqLlmController;
|
|
@@ -40,7 +40,7 @@ __decorate([
|
|
|
40
40
|
(0, common_1.Post)('chat'),
|
|
41
41
|
__param(0, (0, common_1.Body)()),
|
|
42
42
|
__metadata("design:type", Function),
|
|
43
|
-
__metadata("design:paramtypes", [
|
|
43
|
+
__metadata("design:paramtypes", [adapter_models_1.ChatLLMRequestAdapterDto]),
|
|
44
44
|
__metadata("design:returntype", Promise)
|
|
45
45
|
], GroqLlmController.prototype, "generateText", null);
|
|
46
46
|
exports.GroqLlmController = GroqLlmController = GroqLlmController_1 = __decorate([
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type ChatLLMRequestAdapter, ChatMessageDict, DescribeImageRequestAdapter } from '../../models/adapter.models';
|
|
2
2
|
import { LLMAdapterService } from '../../services/adapter-llm.service';
|
|
3
|
-
import { ConversationDTO } from '../../dto/conversation.dto';
|
|
4
3
|
export declare class VertexAdapterLLMController {
|
|
5
4
|
private readonly llmAdapterService;
|
|
6
5
|
private readonly logger;
|
|
7
6
|
constructor(llmAdapterService: LLMAdapterService);
|
|
8
7
|
generateText(request: ChatLLMRequestAdapter): Promise<any>;
|
|
9
8
|
describeImage(request: DescribeImageRequestAdapter): Promise<import("../../models/adapter.models").GeneratedTextAdapter>;
|
|
10
|
-
continueConversation(conversation:
|
|
9
|
+
continueConversation(conversation: ChatLLMRequestAdapter): Promise<ChatMessageDict>;
|
|
11
10
|
}
|
|
@@ -20,7 +20,6 @@ const adapter_models_1 = require("../../models/adapter.models");
|
|
|
20
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");
|
|
24
23
|
let VertexAdapterLLMController = VertexAdapterLLMController_1 = class VertexAdapterLLMController {
|
|
25
24
|
llmAdapterService;
|
|
26
25
|
logger = new common_1.Logger(VertexAdapterLLMController_1.name);
|
|
@@ -38,6 +37,10 @@ let VertexAdapterLLMController = VertexAdapterLLMController_1 = class VertexAdap
|
|
|
38
37
|
return result;
|
|
39
38
|
}
|
|
40
39
|
async continueConversation(conversation) {
|
|
40
|
+
if (conversation.returnJson) {
|
|
41
|
+
const result = await this.llmAdapterService.chatAndExtractJson(conversation);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
41
44
|
return this.llmAdapterService.chat(conversation);
|
|
42
45
|
}
|
|
43
46
|
};
|
|
@@ -62,7 +65,7 @@ __decorate([
|
|
|
62
65
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Return the conversation.' }),
|
|
63
66
|
__param(0, (0, common_1.Body)()),
|
|
64
67
|
__metadata("design:type", Function),
|
|
65
|
-
__metadata("design:paramtypes", [
|
|
68
|
+
__metadata("design:paramtypes", [Object]),
|
|
66
69
|
__metadata("design:returntype", Promise)
|
|
67
70
|
], VertexAdapterLLMController.prototype, "continueConversation", null);
|
|
68
71
|
exports.VertexAdapterLLMController = VertexAdapterLLMController = VertexAdapterLLMController_1 = __decorate([
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { GeminiChatService } from '../../services/vertex-gemini-chat.service';
|
|
2
|
-
import {
|
|
2
|
+
import { ChatLLMRequestAdapterDto } from '../../models/adapter.models';
|
|
3
3
|
import { ChatMessageDict } from '../../models/adapter.models';
|
|
4
|
-
import { ConversationDTO } from '../../dto/conversation.dto';
|
|
5
4
|
export declare class GeminiChatController {
|
|
6
5
|
private readonly geminiChatService;
|
|
7
6
|
private readonly logger;
|
|
8
7
|
constructor(geminiChatService: GeminiChatService);
|
|
9
|
-
generateText(
|
|
10
|
-
continueConversation(conversation:
|
|
8
|
+
generateText(ChatLLMRequestAdapterDto: ChatLLMRequestAdapterDto): Promise<ChatMessageDict>;
|
|
9
|
+
continueConversation(conversation: ChatLLMRequestAdapterDto): Promise<ChatMessageDict>;
|
|
11
10
|
}
|
|
@@ -17,19 +17,18 @@ exports.GeminiChatController = void 0;
|
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const vertex_gemini_chat_service_1 = require("../../services/vertex-gemini-chat.service");
|
|
19
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
20
|
-
const
|
|
20
|
+
const adapter_models_1 = require("../../models/adapter.models");
|
|
21
21
|
const key_balancer_models_1 = require("../../models/key-balancer.models");
|
|
22
22
|
const nest_core_1 = require("@dataclouder/nest-core");
|
|
23
|
-
const conversation_dto_1 = require("../../dto/conversation.dto");
|
|
24
23
|
let GeminiChatController = GeminiChatController_1 = class GeminiChatController {
|
|
25
24
|
geminiChatService;
|
|
26
25
|
logger = new common_1.Logger(GeminiChatController_1.name);
|
|
27
26
|
constructor(geminiChatService) {
|
|
28
27
|
this.geminiChatService = geminiChatService;
|
|
29
28
|
}
|
|
30
|
-
async generateText(
|
|
31
|
-
this.logger.log(`Received request for text generation with keyType: ${
|
|
32
|
-
const result = await this.geminiChatService.chat(
|
|
29
|
+
async generateText(ChatLLMRequestAdapterDto) {
|
|
30
|
+
this.logger.log(`Received request for text generation with keyType: ${ChatLLMRequestAdapterDto.keyType}`);
|
|
31
|
+
const result = await this.geminiChatService.chat(ChatLLMRequestAdapterDto.messages, undefined, ChatLLMRequestAdapterDto?.keyType);
|
|
33
32
|
return result;
|
|
34
33
|
}
|
|
35
34
|
async continueConversation(conversation) {
|
|
@@ -38,7 +37,7 @@ let GeminiChatController = GeminiChatController_1 = class GeminiChatController {
|
|
|
38
37
|
}
|
|
39
38
|
catch (error) {
|
|
40
39
|
this.logger.warn(` 🎀 Error trying with tier 1 ....`);
|
|
41
|
-
conversation.
|
|
40
|
+
conversation.keyType = key_balancer_models_1.TierType.TIER_1;
|
|
42
41
|
return this.geminiChatService.chatWithConversation(conversation);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -48,7 +47,7 @@ __decorate([
|
|
|
48
47
|
(0, common_1.Post)('generate-text'),
|
|
49
48
|
__param(0, (0, common_1.Body)()),
|
|
50
49
|
__metadata("design:type", Function),
|
|
51
|
-
__metadata("design:paramtypes", [
|
|
50
|
+
__metadata("design:paramtypes", [adapter_models_1.ChatLLMRequestAdapterDto]),
|
|
52
51
|
__metadata("design:returntype", Promise)
|
|
53
52
|
], GeminiChatController.prototype, "generateText", null);
|
|
54
53
|
__decorate([
|
|
@@ -57,7 +56,7 @@ __decorate([
|
|
|
57
56
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Return the conversation.' }),
|
|
58
57
|
__param(0, (0, common_1.Body)()),
|
|
59
58
|
__metadata("design:type", Function),
|
|
60
|
-
__metadata("design:paramtypes", [
|
|
59
|
+
__metadata("design:paramtypes", [adapter_models_1.ChatLLMRequestAdapterDto]),
|
|
61
60
|
__metadata("design:returntype", Promise)
|
|
62
61
|
], GeminiChatController.prototype, "continueConversation", null);
|
|
63
62
|
exports.GeminiChatController = GeminiChatController = GeminiChatController_1 = __decorate([
|
|
@@ -104,6 +104,7 @@ __decorate([
|
|
|
104
104
|
__metadata("design:returntype", Promise)
|
|
105
105
|
], VertexTtsAdapterController.prototype, "listVoices", null);
|
|
106
106
|
exports.VertexTtsAdapterController = VertexTtsAdapterController = __decorate([
|
|
107
|
+
(0, common_1.UseGuards)(nest_auth_1.AuthGuard),
|
|
107
108
|
(0, swagger_1.ApiTags)('[TTS] Adapter'),
|
|
108
109
|
(0, common_1.Controller)('api/ai-services/adapter/tts'),
|
|
109
110
|
(0, common_2.UseFilters)(nest_core_1.AllExceptionsHandler),
|
|
@@ -23,12 +23,22 @@ export interface ChatLLMRequestAdapter {
|
|
|
23
23
|
provider?: string;
|
|
24
24
|
model?: Partial<IAIModel>;
|
|
25
25
|
returnJson?: boolean;
|
|
26
|
+
tierType?: TierType;
|
|
27
|
+
}
|
|
28
|
+
export declare class MessageLLMDto implements MessageLLM {
|
|
29
|
+
role: ChatRole;
|
|
30
|
+
content: string;
|
|
31
|
+
}
|
|
32
|
+
export declare class ChatLLMRequestAdapterDto implements ChatLLMRequestAdapter {
|
|
33
|
+
messages: MessageLLMDto[];
|
|
26
34
|
keyType?: TierType;
|
|
35
|
+
model?: Partial<IAIModel>;
|
|
27
36
|
}
|
|
28
37
|
export declare class ChatMessageDict {
|
|
29
38
|
content: string;
|
|
30
39
|
role: ChatRole;
|
|
31
40
|
metadata?: any;
|
|
41
|
+
json?: any;
|
|
32
42
|
}
|
|
33
43
|
export interface GeneratedTextAdapter {
|
|
34
44
|
text: string;
|
package/models/adapter.models.js
CHANGED
|
@@ -9,9 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EModelQuality = exports.DescribeImageRequestAdapter = exports.ImageGenRequestAdapter = exports.ImageGenAdapterResponseWithDebug = exports.ImageGenAdapterResponse = exports.ChatMessageDict = exports.ChatRole = void 0;
|
|
12
|
+
exports.EModelQuality = exports.DescribeImageRequestAdapter = exports.ImageGenRequestAdapter = exports.ImageGenAdapterResponseWithDebug = exports.ImageGenAdapterResponse = exports.ChatMessageDict = exports.ChatLLMRequestAdapterDto = exports.MessageLLMDto = exports.ChatRole = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const key_balancer_models_1 = require("./key-balancer.models");
|
|
15
16
|
const gemini_models_1 = require("./gemini-models");
|
|
16
17
|
var ChatRole;
|
|
17
18
|
(function (ChatRole) {
|
|
@@ -20,10 +21,47 @@ var ChatRole;
|
|
|
20
21
|
ChatRole["Assistant"] = "assistant";
|
|
21
22
|
ChatRole["AssistantHelper"] = "assistantHelper";
|
|
22
23
|
})(ChatRole || (exports.ChatRole = ChatRole = {}));
|
|
24
|
+
class MessageLLMDto {
|
|
25
|
+
role;
|
|
26
|
+
content;
|
|
27
|
+
}
|
|
28
|
+
exports.MessageLLMDto = MessageLLMDto;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ enum: ChatRole, description: 'The role of the message author.' }),
|
|
31
|
+
(0, class_validator_1.IsEnum)(ChatRole),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], MessageLLMDto.prototype, "role", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, swagger_1.ApiProperty)({ description: 'The content of the message.' }),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], MessageLLMDto.prototype, "content", void 0);
|
|
39
|
+
class ChatLLMRequestAdapterDto {
|
|
40
|
+
messages;
|
|
41
|
+
keyType;
|
|
42
|
+
model;
|
|
43
|
+
}
|
|
44
|
+
exports.ChatLLMRequestAdapterDto = ChatLLMRequestAdapterDto;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, swagger_1.ApiProperty)({
|
|
47
|
+
type: [MessageLLMDto],
|
|
48
|
+
default: [{ role: 'user', content: 'tell me 5 contries in latin america' }],
|
|
49
|
+
}),
|
|
50
|
+
__metadata("design:type", Array)
|
|
51
|
+
], ChatLLMRequestAdapterDto.prototype, "messages", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], ChatLLMRequestAdapterDto.prototype, "keyType", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, swagger_1.ApiProperty)({ required: false, description: 'The model to use for the chat completion.' }),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], ChatLLMRequestAdapterDto.prototype, "model", void 0);
|
|
23
60
|
class ChatMessageDict {
|
|
24
61
|
content;
|
|
25
62
|
role;
|
|
26
63
|
metadata;
|
|
64
|
+
json;
|
|
27
65
|
}
|
|
28
66
|
exports.ChatMessageDict = ChatMessageDict;
|
|
29
67
|
class ImageGenAdapterResponse {
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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';
|
|
4
3
|
export declare class LLMAdapterService implements IModelAdapterMethods {
|
|
5
4
|
private geminiChatService;
|
|
6
5
|
private readonly logger;
|
|
@@ -8,11 +7,8 @@ export declare class LLMAdapterService implements IModelAdapterMethods {
|
|
|
8
7
|
listModels(provider?: string): Promise<Record<string, string>[]>;
|
|
9
8
|
generate(request: ChatLLMRequestAdapter): Promise<any>;
|
|
10
9
|
private getDefaultModel;
|
|
11
|
-
chat(request: ChatLLMRequestAdapter
|
|
12
|
-
chatAndExtractJson(request: ChatLLMRequestAdapter): Promise<
|
|
13
|
-
json: any;
|
|
14
|
-
metadata: any;
|
|
15
|
-
}>;
|
|
10
|
+
chat(request: ChatLLMRequestAdapter): Promise<ChatMessageDict>;
|
|
11
|
+
chatAndExtractJson(request: ChatLLMRequestAdapter): Promise<ChatMessageDict>;
|
|
16
12
|
private getQualityModel;
|
|
17
13
|
describeImage(request: DescribeImageRequestAdapter): Promise<GeneratedTextAdapter>;
|
|
18
14
|
}
|
|
@@ -49,12 +49,8 @@ let LLMAdapterService = LLMAdapterService_1 = class LLMAdapterService {
|
|
|
49
49
|
if (provider !== 'google') {
|
|
50
50
|
throw new Error('Provider not supported');
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const chatRequest = request;
|
|
56
|
-
const model = this.getDefaultModel(chatRequest?.model);
|
|
57
|
-
return this.geminiChatService.chat(chatRequest.messages, model, chatRequest.keyType);
|
|
52
|
+
const model = this.getDefaultModel(request?.model);
|
|
53
|
+
return this.geminiChatService.chat(request.messages, model, request.tierType);
|
|
58
54
|
}
|
|
59
55
|
async chatAndExtractJson(request) {
|
|
60
56
|
const response = await this.chat(request);
|
|
@@ -63,7 +59,7 @@ let LLMAdapterService = LLMAdapterService_1 = class LLMAdapterService {
|
|
|
63
59
|
if (json === null) {
|
|
64
60
|
throw new Error('No JSON found in the initial response.');
|
|
65
61
|
}
|
|
66
|
-
return {
|
|
62
|
+
return { ...response, json };
|
|
67
63
|
}
|
|
68
64
|
catch (initialError) {
|
|
69
65
|
const warningMessage = `Initial JSON extraction failed: ${initialError.message}. Attempting recovery.`;
|
|
@@ -84,7 +80,7 @@ let LLMAdapterService = LLMAdapterService_1 = class LLMAdapterService {
|
|
|
84
80
|
}
|
|
85
81
|
response.metadata.recovered = true;
|
|
86
82
|
this.logger.log('Successfully recovered JSON on second attempt.');
|
|
87
|
-
return { json: fixedJson
|
|
83
|
+
return { ...response, json: fixedJson };
|
|
88
84
|
}
|
|
89
85
|
catch (recoveryError) {
|
|
90
86
|
this.logger.error(`Recovery attempt also failed: ${recoveryError.message}`, recoveryError.stack);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpService } from '@nestjs/axios';
|
|
2
|
-
import { GenerateTextDto } from '../dto/generate-text.dto';
|
|
3
2
|
import { GenerateVideoDto } from '../dto/generate-video.dto';
|
|
4
3
|
import { PromptDto } from '../dto/prompt.dto';
|
|
4
|
+
import { ChatLLMRequestAdapter } from '../models/adapter.models';
|
|
5
5
|
export declare const AI_SERVICES_CLIENT_OPTIONS = "AI_SERVICES_CLIENT_OPTIONS";
|
|
6
6
|
export interface AiServicesClientOptions {
|
|
7
7
|
apiBaseUrl: string;
|
|
@@ -32,7 +32,7 @@ declare class Video extends BaseService {
|
|
|
32
32
|
getVeoStatus(operationName: string): Promise<any>;
|
|
33
33
|
}
|
|
34
34
|
declare class Llm extends BaseService {
|
|
35
|
-
chat(dto:
|
|
35
|
+
chat(dto: ChatLLMRequestAdapter): Promise<any>;
|
|
36
36
|
}
|
|
37
37
|
declare class Image extends BaseService {
|
|
38
38
|
generate(dto: PromptDto): Promise<any>;
|
|
@@ -74,7 +74,6 @@ class Video extends BaseService {
|
|
|
74
74
|
}
|
|
75
75
|
async generateFromAssetId(id) {
|
|
76
76
|
const endpoint = '/api/vertex-adapter/video/generate-video-from-asset-id/' + id;
|
|
77
|
-
console.log('Requesting to.. ' + endpoint);
|
|
78
77
|
return this.post(endpoint, {});
|
|
79
78
|
}
|
|
80
79
|
async generateVeo(dto) {
|
|
@@ -44,8 +44,14 @@ let KeyBalancerClientService = KeyBalancerClientService_1 = class KeyBalancerCli
|
|
|
44
44
|
};
|
|
45
45
|
const keyBalancerHost = process.env.KEY_BALANCER_HOST || 'http://localhost:8085';
|
|
46
46
|
const url = `${keyBalancerHost}/api/key-usage/best-key-balanced`;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
try {
|
|
48
|
+
const { data } = await (0, rxjs_1.firstValueFrom)(this.httpService.post(url, finalRquest));
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.logger.error(`Failed to get ${keyRequest.aiType} key for model ${keyRequest.service} from the external service.`, error.stack);
|
|
53
|
+
return this.getUnavailableServiceResult();
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
async getKeys() {
|
|
51
57
|
const appFilter = {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ChatMessageDict, MessageLLM, EModelQuality, DescribeImageRequestAdapter, ChatJsonResponse } from '../models/adapter.models';
|
|
1
|
+
import { ChatMessageDict, MessageLLM, EModelQuality, DescribeImageRequestAdapter, ChatJsonResponse, ChatLLMRequestAdapter } from '../models/adapter.models';
|
|
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';
|
|
6
5
|
export declare class GeminiChatService {
|
|
7
6
|
private readonly keyBalancer;
|
|
8
7
|
private readonly googleGenaiService;
|
|
@@ -19,5 +18,5 @@ export declare class GeminiChatService {
|
|
|
19
18
|
private _extractJsonWithRecovery;
|
|
20
19
|
chatAndExtractJson(messages: MessageLLM[], model?: string, keyType?: TierType): Promise<ChatJsonResponse>;
|
|
21
20
|
describeImageByUrl(dto: DescribeImageRequestAdapter): Promise<any>;
|
|
22
|
-
chatWithConversation(conversation:
|
|
21
|
+
chatWithConversation(conversation: ChatLLMRequestAdapter): Promise<ChatMessageDict>;
|
|
23
22
|
}
|
|
@@ -111,6 +111,7 @@ let VertexVeoGenaiService = class VertexVeoGenaiService {
|
|
|
111
111
|
prompt: genAsset.prompt || genAsset?.description || 'Random movement for video',
|
|
112
112
|
config: {
|
|
113
113
|
aspectRatio: '9:16',
|
|
114
|
+
durationSeconds: 4,
|
|
114
115
|
},
|
|
115
116
|
image: {
|
|
116
117
|
imageBytes: imageBufferBytes.toString('base64'),
|
|
@@ -132,6 +133,7 @@ let VertexVeoGenaiService = class VertexVeoGenaiService {
|
|
|
132
133
|
keyTierType: key_balancer_models_1.TierType.TIER_1,
|
|
133
134
|
aiType: key_balancer_models_1.ModelType.VIDEO,
|
|
134
135
|
});
|
|
136
|
+
videoRequest.model = 'veo-3.1-fast-generate-preview';
|
|
135
137
|
console.log('the balance key for video is ', balancedKey);
|
|
136
138
|
let operation = await client.models.generateVideos(videoRequest);
|
|
137
139
|
const filename = `veo_video_${(0, uuid_1.v4)()}.mp4`;
|
|
@@ -113,7 +113,7 @@ let GroqService = GroqService_1 = class GroqService {
|
|
|
113
113
|
tierType: key_balancer_models_1.TierType.FREE_TIER,
|
|
114
114
|
aiType: key_balancer_models_1.ModelType.AUDIO,
|
|
115
115
|
}, null);
|
|
116
|
-
|
|
116
|
+
this.logger.verbose(`Using key: ${keyResult.name} {${keyResult?.service}}`);
|
|
117
117
|
const transcription = await this.getClientWithKey(keyResult.key).audio.transcriptions.create({
|
|
118
118
|
file: file,
|
|
119
119
|
model: 'whisper-large-v3-turbo',
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
package/dto/conversation.dto.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.GenerateTextDto = void 0;
|
|
13
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
-
const message_llm_dto_1 = require("./message-llm.dto");
|
|
15
|
-
class GenerateTextDto {
|
|
16
|
-
messages;
|
|
17
|
-
keyType;
|
|
18
|
-
model;
|
|
19
|
-
}
|
|
20
|
-
exports.GenerateTextDto = GenerateTextDto;
|
|
21
|
-
__decorate([
|
|
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
|
-
}),
|
|
26
|
-
__metadata("design:type", Array)
|
|
27
|
-
], GenerateTextDto.prototype, "messages", void 0);
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, swagger_1.ApiProperty)({ required: false }),
|
|
30
|
-
__metadata("design:type", String)
|
|
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);
|
|
36
|
-
//# sourceMappingURL=generate-text.dto.js.map
|