@purpleschool/ai-proxy 0.0.2 → 0.1.4

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.
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./job-status.enum"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JOB_STATUS = void 0;
4
+ var JOB_STATUS;
5
+ (function (JOB_STATUS) {
6
+ JOB_STATUS["PENDING"] = "pending";
7
+ JOB_STATUS["PROCESSING"] = "processing";
8
+ JOB_STATUS["COMPLETED"] = "completed";
9
+ JOB_STATUS["FAILED"] = "failed";
10
+ })(JOB_STATUS || (exports.JOB_STATUS = JOB_STATUS = {}));
@@ -129,4 +129,99 @@ exports.ERRORS = {
129
129
  message: 'Вложения файлов и веб-поиск нельзя использовать вместе',
130
130
  httpCode: 400,
131
131
  },
132
+ VIDEO_MISSING_PARAMS_ERROR: {
133
+ code: 'A026',
134
+ message: 'Не переданы параметры при запросе генерации видео',
135
+ httpCode: 400,
136
+ },
137
+ VIDEO_JOB_SAVE_ERROR: {
138
+ code: 'A027',
139
+ message: 'Произошла ошибка при сохранении задания на генерацию видео',
140
+ httpCode: 500,
141
+ },
142
+ VIDEO_JOB_NOT_FOUND: {
143
+ code: 'A028',
144
+ message: 'Задание на генерацию видео не найдено',
145
+ httpCode: 404,
146
+ },
147
+ EXTERNAL_PROVIDER_CONTENT_POLICY: {
148
+ code: 'A029',
149
+ message: 'Запрос был отклонен, т.к. он не соответствует требованиям политики безопасности поставщика модели',
150
+ httpCode: 400,
151
+ },
152
+ GOOGLE_CONTENT_POLICY: {
153
+ code: 'A030',
154
+ message: 'Запрос был отклонен, т.к. он не соответствует требованиям политики безопасности Google.',
155
+ httpCode: 400,
156
+ },
157
+ VIDEO_EDITOR_SAVE_ERROR: {
158
+ code: 'A031',
159
+ message: 'Произошла ошибка при сохранении задания на редактирование видео',
160
+ httpCode: 500,
161
+ },
162
+ VIDEO_EDITOR_FIND_ERROR: {
163
+ code: 'A032',
164
+ message: 'Произошла ошибка при поиске задания на редактирование видео',
165
+ httpCode: 500,
166
+ },
167
+ STT_JOB_SAVE_ERROR: {
168
+ code: 'A033',
169
+ message: 'Произошла ошибка при сохранении задания STT',
170
+ httpCode: 500,
171
+ },
172
+ STT_JOB_FIND_ERROR: {
173
+ code: 'A034',
174
+ message: 'Произошла ошибка при поиске задания STT',
175
+ httpCode: 500,
176
+ },
177
+ TTS_JOB_SAVE_ERROR: {
178
+ code: 'A035',
179
+ message: 'Произошла ошибка при сохранении задания TTS',
180
+ httpCode: 500,
181
+ },
182
+ TTS_JOB_FIND_ERROR: {
183
+ code: 'A036',
184
+ message: 'Произошла ошибка при поиске задания TTS',
185
+ httpCode: 500,
186
+ },
187
+ MUSIC_JOB_SAVE_ERROR: {
188
+ code: 'A037',
189
+ message: 'Произошла ошибка при сохранении задания на генерацию музыки',
190
+ httpCode: 500,
191
+ },
192
+ MUSIC_JOB_FIND_ERROR: {
193
+ code: 'A038',
194
+ message: 'Произошла ошибка при поиске задания на генерацию музыки',
195
+ httpCode: 500,
196
+ },
197
+ MUSIC_JOB_NOT_FOUND: {
198
+ code: 'A039',
199
+ message: 'Задание на генерацию музыки не найдено',
200
+ httpCode: 404,
201
+ },
202
+ SUNO_CONTENT_POLICY: {
203
+ code: 'A040',
204
+ message: 'Запрос на создание музыки был отклонен, т.к. он не соответствует требованиям политики безопасности Suno.',
205
+ httpCode: 400,
206
+ },
207
+ GENERATE_LYRICS_ERROR: {
208
+ code: 'A041',
209
+ message: 'Произошла ошибка при генерации текста музыки',
210
+ httpCode: 500,
211
+ },
212
+ CONVERT_TO_WAV_ERROR: {
213
+ code: 'A042',
214
+ message: 'Произошла ошибка при конвертации mp3 в wav',
215
+ httpCode: 500,
216
+ },
217
+ POLL_TIMEOUT: {
218
+ code: 'A043',
219
+ message: 'Превышено время ожидания генерации музыки',
220
+ httpCode: 500,
221
+ },
222
+ MUSIC_JOB_NOT_AN_OWNER: {
223
+ code: 'A044',
224
+ message: 'Пользователь не является владельцем задания на генерацию музыки',
225
+ httpCode: 403,
226
+ },
132
227
  };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./errors"), exports);
18
+ __exportStar(require("./enums"), exports);
package/build/index.js CHANGED
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./errors"), exports);
17
+ __exportStar(require("./constants"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/ai-proxy",
3
- "version": "0.0.2",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -17,5 +17,8 @@
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
19
  "zod": "^3.22.4"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^24.3.0"
20
23
  }
21
24
  }
@@ -0,0 +1,250 @@
1
+ syntax = "proto3";
2
+ import "google/protobuf/timestamp.proto";
3
+ import "google/protobuf/struct.proto";
4
+ package AiProxy;
5
+
6
+ service AiProxyService {
7
+ rpc TextGeneration (TextGenerationRequest) returns (stream TextGenerationResponse);
8
+ rpc TextGenerationUnary (TextGenerationUnaryRequest) returns (TextGenerationUnaryResponse);
9
+
10
+ rpc ImageGeneration (ImageGenerationRequest) returns (ImageGenerationResponse);
11
+
12
+ rpc VideoGeneration (VideoGenerationRequest) returns (VideoGenerationResponse);
13
+ rpc VideoEditor (VideoEditorRequest) returns (VideoEditorResponse);
14
+
15
+ rpc SpeechToText (SpeechToTextRequest) returns (SpeechToTextResponse);
16
+ rpc TextToSpeech (TextToSpeechRequest) returns (stream TextToSpeechResponse);
17
+
18
+ rpc EmbeddingsGeneration (EmbeddingsGenerationRequest) returns (EmbeddingsGenerationResponse);
19
+
20
+ rpc MusicGeneration (MusicGenerationRequest) returns (MusicGenerationResponse);
21
+ rpc GenerateLyrics (GenerateLyricsRequest) returns (GenerateLyricsResponse);
22
+ rpc ConvertToWav (ConvertToWavRequest) returns (ConvertToWavResponse);
23
+
24
+ rpc GetAllAiModels(GetAllAiModelsRequest) returns (GetAllAiModelsResponse);
25
+ rpc GetAiModel(GetAiModelRequest) returns (GetAiModelResponse);
26
+ }
27
+
28
+ // Text Generation (stream)
29
+ message TextGenerationRequest {
30
+ string model = 1;
31
+ repeated Message messages = 2;
32
+ repeated string features = 3;
33
+ WebSearchParams webSearchParams = 4;
34
+ }
35
+
36
+ message Message {
37
+ optional string uuid = 1;
38
+ string role = 2;
39
+ string text = 3;
40
+ repeated File files = 4;
41
+ optional string status = 5;
42
+ optional string externalId = 6;
43
+ google.protobuf.Timestamp createdAt = 7;
44
+ google.protobuf.Timestamp updatedAt = 8;
45
+ }
46
+
47
+ message WebSearchParams {
48
+ UserLocation userLocation = 1;
49
+ }
50
+
51
+ message UserLocation {
52
+ string country = 1;
53
+ string city = 2;
54
+ string region = 3;
55
+ }
56
+
57
+ message File {
58
+ string url = 1;
59
+ string type = 2;
60
+ string mimeType = 3;
61
+ }
62
+
63
+ message TextGenerationResponse {
64
+ optional string delta = 1;
65
+ optional int32 inputTokens = 2;
66
+ optional int32 outputTokens = 3;
67
+ bool isFinish = 4;
68
+ }
69
+
70
+ // TextGenerationUnary
71
+ message TextGenerationUnaryRequest {
72
+ string model = 1;
73
+ repeated Message messages = 2;
74
+ repeated string features = 3;
75
+ WebSearchParams webSearchParams = 4;
76
+ string responseSchema = 5;
77
+ }
78
+
79
+ message TextGenerationUnaryResponse {
80
+ string text = 1;
81
+ int32 inputTokens = 2;
82
+ int32 outputTokens = 3;
83
+ }
84
+
85
+ // Image Generation
86
+ message ImageGenerationRequest {
87
+ string model = 1;
88
+ string prompt = 2;
89
+ int32 width = 3;
90
+ int32 height = 4;
91
+ repeated Message messages = 5;
92
+ }
93
+
94
+ message ImageGenerationResponse {
95
+ string model = 1;
96
+ ImageGenerationData data = 2;
97
+ }
98
+
99
+ message ImageGenerationData {
100
+ optional string url = 1;
101
+ optional string base64 = 2;
102
+ optional string externalId = 3;
103
+ string type = 4;
104
+ }
105
+
106
+ // Video Generation
107
+ message VideoGenerationRequest {
108
+ string model = 1;
109
+ string prompt = 2;
110
+ string callbackUrl = 3;
111
+ VideoParams params = 4;
112
+ }
113
+
114
+ message VideoParams {
115
+ repeated string imageUrls = 1;
116
+ int32 duration = 2;
117
+ optional string aspectRatio = 3;
118
+ optional string quality = 4;
119
+ }
120
+
121
+ message VideoGenerationResponse {
122
+ string jobId = 1;
123
+ }
124
+
125
+ // Video Editor
126
+ message VideoEditorRequest {
127
+ string model = 1;
128
+ string prompt = 2;
129
+ string callbackUrl = 3;
130
+ string inputVideoUrl = 4;
131
+ int32 duration = 5;
132
+ }
133
+
134
+ message VideoEditorResponse {
135
+ string jobId = 1;
136
+ }
137
+
138
+ // Speech To Text
139
+ message SpeechToTextRequest {
140
+ string model = 1;
141
+ string fileId = 2;
142
+ string fileKey = 3;
143
+ string fileUrl = 4;
144
+ int32 durationInSeconds = 5;
145
+ string callbackUrl = 6;
146
+ }
147
+
148
+ message SpeechToTextResponse {
149
+ string jobId = 1;
150
+ optional SpeechToTextAiResponse aiResponse = 2;
151
+ }
152
+
153
+ message SpeechToTextAiResponse {
154
+ google.protobuf.Struct raw = 1;
155
+ string md = 2;
156
+ }
157
+
158
+ // Text To Speech
159
+ message TextToSpeechRequest {
160
+ string model = 1;
161
+ string voiceId = 2;
162
+ string input = 3;
163
+ TextToSpeechParams params = 4;
164
+ }
165
+
166
+ message TextToSpeechResponse {
167
+ bytes audioChunk = 1;
168
+ }
169
+
170
+ message TextToSpeechParams {
171
+ int32 speed = 1;
172
+ int32 similarity = 2;
173
+ int32 stability = 3;
174
+ int32 style = 4;
175
+ }
176
+
177
+ // Music Generation
178
+ message MusicGenerationRequest {
179
+ string model = 1;
180
+ string callbackUrl = 2;
181
+ MusicGenerationParams params = 3;
182
+ }
183
+
184
+ message MusicGenerationResponse {
185
+ string jobId = 1;
186
+ }
187
+
188
+ message MusicGenerationParams {
189
+ string mode = 1;
190
+ string style = 2;
191
+ optional string prompt = 3;
192
+ optional string title = 4;
193
+ optional string vocalGender = 5;
194
+ }
195
+
196
+ // Generate Lyrics
197
+ message GenerateLyricsRequest {
198
+ string prompt = 1;
199
+ }
200
+
201
+ message GenerateLyricsResponse {
202
+ string title = 1;
203
+ string lyrics = 2;
204
+ }
205
+
206
+ // Convert To Wav
207
+ message ConvertToWavRequest {
208
+ string taskId = 1;
209
+ string audioId = 2;
210
+ }
211
+
212
+ message ConvertToWavResponse {
213
+ string url = 1;
214
+ }
215
+
216
+ // GetAllAiModels
217
+ message GetAllAiModelsRequest {
218
+ }
219
+
220
+ message GetAllAiModelsResponse {
221
+ repeated AiModel data = 1;
222
+ }
223
+
224
+ message AiModel {
225
+ string model = 1;
226
+ string contentType = 2;
227
+ repeated string features = 3;
228
+ }
229
+
230
+ // GetAiModel
231
+ message GetAiModelRequest {
232
+ string model = 1;
233
+ }
234
+
235
+ message GetAiModelResponse {
236
+ AiModel data = 1;
237
+ }
238
+
239
+ // GenerateEmbeddings
240
+ message EmbeddingsGenerationRequest {
241
+ repeated string queries = 1;
242
+ }
243
+
244
+ message Embedding {
245
+ repeated double embedding = 1;
246
+ }
247
+
248
+ message EmbeddingsGenerationResponse {
249
+ repeated Embedding data = 1;
250
+ }
@@ -1,92 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package AiApi;
4
-
5
- service AiApiService {
6
- rpc ChatCompletions (ChatCompletionsRequest) returns (stream ChatCompletionsResponse);
7
- rpc ImageGeneration (ImageGenerationRequest) returns (ImageGenerationResponse);
8
- rpc GetAllAiModels(GetAllAiModelsRequest) returns (GetAllAiModelsResponse);
9
- rpc GetAiModel(GetAiModelRequest) returns (GetAiModelResponse);
10
- }
11
-
12
- // Chat Completions
13
- message ChatCompletionsRequest {
14
- string model = 1;
15
- repeated Message messages = 2;
16
- repeated string features = 3;
17
- UserLocation userLocation = 4;
18
- }
19
-
20
- message Message {
21
- string role = 1;
22
- string text = 2;
23
- repeated File files = 3;
24
- }
25
-
26
- message UserLocation {
27
- string country = 1;
28
- string city = 2;
29
- string region = 3;
30
- }
31
-
32
- message File {
33
- string url = 1;
34
- string type = 2;
35
- }
36
-
37
- message ChatCompletionsResponse {
38
- optional string delta = 1;
39
- bool isFinish = 2;
40
- }
41
-
42
- // Image Generation
43
- message ImageGenerationRequest {
44
- string model = 1;
45
- string prompt = 2;
46
- int32 width = 3;
47
- int32 height = 4;
48
- }
49
-
50
- message ImageGenerationResponse {
51
- string model = 1;
52
- ImageGenerationData data = 2;
53
- }
54
-
55
- message ImageGenerationData {
56
- string url = 1;
57
- }
58
-
59
- // GetAllAiModels
60
- message GetAllAiModelsRequest {
61
- }
62
-
63
- message GetAllAiModelsResponse {
64
- repeated AiModel data = 1;
65
- }
66
-
67
- message AiModel {
68
- string model = 1;
69
- string contentType = 2;
70
- repeated string features = 3;
71
- int32 maxInputLength = 4;
72
- int32 maxInputTokens = 5;
73
- AiModelConfig config = 6;
74
- }
75
-
76
- message AiModelConfig {
77
- repeated ImageSizeOption supportedResolutions = 1;
78
- }
79
-
80
- message ImageSizeOption {
81
- int32 width = 1;
82
- int32 height = 2;
83
- }
84
-
85
- // GetAiModel
86
- message GetAiModelRequest {
87
- string model = 1;
88
- }
89
-
90
- message GetAiModelResponse {
91
- AiModel data = 1;
92
- }
File without changes