@purpleschool/gptbot-tools 0.2.43 → 0.2.45
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/build/image-recognition/commands/delete-all-image-recognition-jobs.command.js +13 -0
- package/build/image-recognition/commands/delete-image-recognition-job-by-uuid.command.js +14 -0
- package/build/image-recognition/commands/get-image-recognition-price.command.js +15 -0
- package/build/image-recognition/commands/image-recognition.command.js +24 -0
- package/build/image-recognition/commands/index.js +24 -0
- package/build/image-recognition/commands/retry-image-recognition-job.command.js +28 -0
- package/build/image-recognition/commands/set-reaction-to-image-recognition-job.command.js +27 -0
- package/build/image-recognition/commands/update-image-recognition-job-favorite.command.js +16 -0
- package/build/image-recognition/commands/update-image-recognition-job-title.command.js +16 -0
- package/build/image-recognition/index.js +20 -0
- package/build/image-recognition/models/image-recognition-category.schema.js +15 -0
- package/build/image-recognition/models/image-recognition-config.schema.js +10 -0
- package/build/image-recognition/models/image-recognition-job.schema.js +34 -0
- package/build/image-recognition/models/image-recognition-model.schema.js +25 -0
- package/build/image-recognition/models/index.js +20 -0
- package/build/image-recognition/queries/find-image-recognition-job-by-id.query.js +15 -0
- package/build/image-recognition/queries/find-image-recognition-jobs.query.js +33 -0
- package/build/image-recognition/queries/get-image-recognition-config.query.js +10 -0
- package/build/image-recognition/queries/index.js +19 -0
- package/build/image-recognition/routes/image-recognition.amqp.routes.js +16 -0
- package/build/image-recognition/routes/index.js +17 -0
- package/build/index.js +3 -0
- package/build/tools/enums/tool-content-type.enum.js +1 -0
- package/build/tools/enums/tool-type.enum.js +1 -0
- package/build/tools/models/global-tools-config.schema.js +2 -0
- package/build/tools/models/tools-with-configs.schema.js +5 -0
- package/image-recognition/commands/delete-all-image-recognition-jobs.command.ts +13 -0
- package/image-recognition/commands/delete-image-recognition-job-by-uuid.command.ts +14 -0
- package/image-recognition/commands/get-image-recognition-price.command.ts +17 -0
- package/image-recognition/commands/image-recognition.command.ts +24 -0
- package/image-recognition/commands/index.ts +8 -0
- package/image-recognition/commands/retry-image-recognition-job.command.ts +28 -0
- package/image-recognition/commands/set-reaction-to-image-recognition-job.command.ts +31 -0
- package/image-recognition/commands/update-image-recognition-job-favorite.command.ts +16 -0
- package/image-recognition/commands/update-image-recognition-job-title.command.ts +16 -0
- package/image-recognition/index.ts +4 -0
- package/image-recognition/models/image-recognition-category.schema.ts +15 -0
- package/image-recognition/models/image-recognition-config.schema.ts +10 -0
- package/image-recognition/models/image-recognition-job.schema.ts +37 -0
- package/image-recognition/models/image-recognition-model.schema.ts +28 -0
- package/image-recognition/models/index.ts +4 -0
- package/image-recognition/queries/find-image-recognition-job-by-id.query.ts +16 -0
- package/image-recognition/queries/find-image-recognition-jobs.query.ts +38 -0
- package/image-recognition/queries/get-image-recognition-config.query.ts +11 -0
- package/image-recognition/queries/index.ts +3 -0
- package/image-recognition/routes/image-recognition.amqp.routes.ts +13 -0
- package/image-recognition/routes/index.ts +1 -0
- package/index.ts +3 -0
- package/package.json +2 -2
- package/tools/enums/tool-content-type.enum.ts +1 -0
- package/tools/enums/tool-type.enum.ts +1 -0
- package/tools/models/global-tools-config.schema.ts +2 -0
- package/tools/models/tools-with-configs.schema.ts +7 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteAllImageRecognitionJobsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
var DeleteAllImageRecognitionJobsCommand;
|
|
7
|
+
(function (DeleteAllImageRecognitionJobsCommand) {
|
|
8
|
+
DeleteAllImageRecognitionJobsCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
});
|
|
12
|
+
DeleteAllImageRecognitionJobsCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.boolean());
|
|
13
|
+
})(DeleteAllImageRecognitionJobsCommand || (exports.DeleteAllImageRecognitionJobsCommand = DeleteAllImageRecognitionJobsCommand = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteImageRecognitionJobByUuidCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
var DeleteImageRecognitionJobByUuidCommand;
|
|
7
|
+
(function (DeleteImageRecognitionJobByUuidCommand) {
|
|
8
|
+
DeleteImageRecognitionJobByUuidCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
uuid: zod_1.z.string().uuid(),
|
|
12
|
+
});
|
|
13
|
+
DeleteImageRecognitionJobByUuidCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.boolean());
|
|
14
|
+
})(DeleteImageRecognitionJobByUuidCommand || (exports.DeleteImageRecognitionJobByUuidCommand = DeleteImageRecognitionJobByUuidCommand = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetImageRecognitionPriceCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
var GetImageRecognitionPriceCommand;
|
|
7
|
+
(function (GetImageRecognitionPriceCommand) {
|
|
8
|
+
GetImageRecognitionPriceCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
modelId: zod_1.z.string().uuid(),
|
|
10
|
+
});
|
|
11
|
+
GetImageRecognitionPriceCommand.ResponseDataSchema = zod_1.z.object({
|
|
12
|
+
price: zod_1.z.number(),
|
|
13
|
+
});
|
|
14
|
+
GetImageRecognitionPriceCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(GetImageRecognitionPriceCommand.ResponseDataSchema);
|
|
15
|
+
})(GetImageRecognitionPriceCommand || (exports.GetImageRecognitionPriceCommand = GetImageRecognitionPriceCommand = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageRecognitionCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const models_1 = require("../models");
|
|
7
|
+
const common_1 = require("../../common");
|
|
8
|
+
var ImageRecognitionCommand;
|
|
9
|
+
(function (ImageRecognitionCommand) {
|
|
10
|
+
ImageRecognitionCommand.RequestSchema = zod_1.z.object({
|
|
11
|
+
locale: common_1.LocaleSchema,
|
|
12
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
14
|
+
prompt: zod_1.z.string().optional(),
|
|
15
|
+
categoryId: zod_1.z.string().uuid(),
|
|
16
|
+
modelId: zod_1.z.string().uuid(),
|
|
17
|
+
params: zod_1.z.object({
|
|
18
|
+
attachedFiles: zod_1.z.array(common_1.AttachedFileSchema),
|
|
19
|
+
}),
|
|
20
|
+
tokenReservationId: zod_1.z.string().uuid().optional(),
|
|
21
|
+
precalculatedPrice: zod_1.z.number().optional(),
|
|
22
|
+
});
|
|
23
|
+
ImageRecognitionCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.ImageRecognitionJobSchema);
|
|
24
|
+
})(ImageRecognitionCommand || (exports.ImageRecognitionCommand = ImageRecognitionCommand = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
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("./get-image-recognition-price.command"), exports);
|
|
18
|
+
__exportStar(require("./image-recognition.command"), exports);
|
|
19
|
+
__exportStar(require("./retry-image-recognition-job.command"), exports);
|
|
20
|
+
__exportStar(require("./set-reaction-to-image-recognition-job.command"), exports);
|
|
21
|
+
__exportStar(require("./update-image-recognition-job-title.command"), exports);
|
|
22
|
+
__exportStar(require("./update-image-recognition-job-favorite.command"), exports);
|
|
23
|
+
__exportStar(require("./delete-image-recognition-job-by-uuid.command"), exports);
|
|
24
|
+
__exportStar(require("./delete-all-image-recognition-jobs.command"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RetryImageRecognitionJobCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const locale_schema_1 = require("../../common/models/locale.schema");
|
|
7
|
+
const models_1 = require("../models");
|
|
8
|
+
const common_1 = require("../../common");
|
|
9
|
+
var RetryImageRecognitionJobCommand;
|
|
10
|
+
(function (RetryImageRecognitionJobCommand) {
|
|
11
|
+
RetryImageRecognitionJobCommand.RequestSchema = zod_1.z.object({
|
|
12
|
+
locale: locale_schema_1.LocaleSchema,
|
|
13
|
+
uuid: zod_1.z.string().uuid(),
|
|
14
|
+
tokenReservationId: zod_1.z.string().uuid().optional(),
|
|
15
|
+
precalculatedPrice: zod_1.z.number().optional(),
|
|
16
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
17
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
18
|
+
prompt: zod_1.z.string().optional(),
|
|
19
|
+
categoryId: zod_1.z.string().uuid().optional(),
|
|
20
|
+
modelId: zod_1.z.string().uuid().optional(),
|
|
21
|
+
params: zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
attachedFiles: zod_1.z.array(common_1.AttachedFileSchema),
|
|
24
|
+
})
|
|
25
|
+
.optional(),
|
|
26
|
+
});
|
|
27
|
+
RetryImageRecognitionJobCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.ImageRecognitionJobSchema);
|
|
28
|
+
})(RetryImageRecognitionJobCommand || (exports.RetryImageRecognitionJobCommand = RetryImageRecognitionJobCommand = {}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetReactionToImageRecognitionJobCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
7
|
+
const models_1 = require("../models");
|
|
8
|
+
var SetReactionToImageRecognitionJobCommand;
|
|
9
|
+
(function (SetReactionToImageRecognitionJobCommand) {
|
|
10
|
+
SetReactionToImageRecognitionJobCommand.RequestSchema = zod_1.z
|
|
11
|
+
.object({
|
|
12
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
14
|
+
uuid: zod_1.z.string().uuid(),
|
|
15
|
+
reaction: zod_1.z.nativeEnum(common_1.USER_REACTION).nullable(),
|
|
16
|
+
dislikeReason: zod_1.z.string().nullable().default(null),
|
|
17
|
+
})
|
|
18
|
+
.refine((data) => {
|
|
19
|
+
if (data.reaction !== common_1.USER_REACTION.DISLIKED && data.dislikeReason) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}, {
|
|
24
|
+
message: 'Dislike reason is not allowed when reaction is not disliked',
|
|
25
|
+
});
|
|
26
|
+
SetReactionToImageRecognitionJobCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(models_1.ImageRecognitionJobSchema);
|
|
27
|
+
})(SetReactionToImageRecognitionJobCommand || (exports.SetReactionToImageRecognitionJobCommand = SetReactionToImageRecognitionJobCommand = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateImageRecognitionJobFavoriteCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const image_recognition_job_schema_1 = require("../models/image-recognition-job.schema");
|
|
7
|
+
var UpdateImageRecognitionJobFavoriteCommand;
|
|
8
|
+
(function (UpdateImageRecognitionJobFavoriteCommand) {
|
|
9
|
+
UpdateImageRecognitionJobFavoriteCommand.RequestSchema = zod_1.z.object({
|
|
10
|
+
uuid: zod_1.z.string().uuid(),
|
|
11
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
isFavorite: zod_1.z.boolean(),
|
|
14
|
+
});
|
|
15
|
+
UpdateImageRecognitionJobFavoriteCommand.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(image_recognition_job_schema_1.ImageRecognitionJobSchema);
|
|
16
|
+
})(UpdateImageRecognitionJobFavoriteCommand || (exports.UpdateImageRecognitionJobFavoriteCommand = UpdateImageRecognitionJobFavoriteCommand = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateImageRecognitionJobTitleCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
var UpdateImageRecognitionJobTitleCommand;
|
|
8
|
+
(function (UpdateImageRecognitionJobTitleCommand) {
|
|
9
|
+
UpdateImageRecognitionJobTitleCommand.RequestSchema = zod_1.z.object({
|
|
10
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
11
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
uuid: zod_1.z.string().uuid(),
|
|
13
|
+
title: zod_1.z.string(),
|
|
14
|
+
});
|
|
15
|
+
UpdateImageRecognitionJobTitleCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.ImageRecognitionJobSchema);
|
|
16
|
+
})(UpdateImageRecognitionJobTitleCommand || (exports.UpdateImageRecognitionJobTitleCommand = UpdateImageRecognitionJobTitleCommand = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./commands"), exports);
|
|
18
|
+
__exportStar(require("./models"), exports);
|
|
19
|
+
__exportStar(require("./queries"), exports);
|
|
20
|
+
__exportStar(require("./routes"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageRecognitionCategorySchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
exports.ImageRecognitionCategorySchema = zod_1.z.object({
|
|
7
|
+
uuid: zod_1.z.string(),
|
|
8
|
+
parentId: zod_1.z.string().nullable(),
|
|
9
|
+
title: zod_1.z.string(),
|
|
10
|
+
systemPrompt: zod_1.z.string(),
|
|
11
|
+
order: zod_1.z.number(),
|
|
12
|
+
status: zod_1.z.nativeEnum(common_1.TOOL_MODEL_STATUS),
|
|
13
|
+
createdAt: zod_1.z.date(),
|
|
14
|
+
updatedAt: zod_1.z.date(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageRecognitionConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const image_recognition_model_schema_1 = require("./image-recognition-model.schema");
|
|
6
|
+
const image_recognition_category_schema_1 = require("./image-recognition-category.schema");
|
|
7
|
+
exports.ImageRecognitionConfigSchema = zod_1.z.object({
|
|
8
|
+
models: zod_1.z.array(image_recognition_model_schema_1.ImageRecognitionModelSchema),
|
|
9
|
+
categories: zod_1.z.array(image_recognition_category_schema_1.ImageRecognitionCategorySchema),
|
|
10
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageRecognitionJobSchema = exports.ImageRecognitionJobParamsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tools_1 = require("../../tools");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
exports.ImageRecognitionJobParamsSchema = zod_1.z.object({
|
|
8
|
+
attachedFiles: zod_1.z.array(common_1.AttachedFileSchema),
|
|
9
|
+
});
|
|
10
|
+
exports.ImageRecognitionJobSchema = zod_1.z.object({
|
|
11
|
+
uuid: zod_1.z.string(),
|
|
12
|
+
prompt: zod_1.z.string().nullable(),
|
|
13
|
+
categoryId: zod_1.z.string(),
|
|
14
|
+
aiOutput: zod_1.z.string().nullable().optional(),
|
|
15
|
+
reaction: zod_1.z.nativeEnum(common_1.USER_REACTION).nullable(),
|
|
16
|
+
dislikeReason: zod_1.z.string().nullable(),
|
|
17
|
+
externalId: zod_1.z.string().nullable(),
|
|
18
|
+
title: zod_1.z.string(),
|
|
19
|
+
status: zod_1.z.nativeEnum(tools_1.JOB_STATUS),
|
|
20
|
+
error: zod_1.z.string().nullable(),
|
|
21
|
+
internalError: zod_1.z.string().nullable().optional(),
|
|
22
|
+
modelId: zod_1.z.string(),
|
|
23
|
+
price: zod_1.z.number(),
|
|
24
|
+
params: exports.ImageRecognitionJobParamsSchema,
|
|
25
|
+
attempts: zod_1.z.array(zod_1.z.any()),
|
|
26
|
+
userId: zod_1.z.string().nullable().optional(),
|
|
27
|
+
unregisteredUserId: zod_1.z.string().nullable().optional(),
|
|
28
|
+
tokenReservationId: zod_1.z.string().nullable().optional(),
|
|
29
|
+
isDeleted: zod_1.z.boolean(),
|
|
30
|
+
isFavorite: zod_1.z.boolean(),
|
|
31
|
+
createdAt: zod_1.z.date(),
|
|
32
|
+
completedAt: zod_1.z.date().nullable().optional(),
|
|
33
|
+
updatedAt: zod_1.z.date(),
|
|
34
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageRecognitionModelSchema = exports.ImageRecognitionModelParamsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
exports.ImageRecognitionModelParamsSchema = zod_1.z.object({
|
|
7
|
+
imageAttachment: zod_1.z.object({
|
|
8
|
+
supported: zod_1.z.boolean(),
|
|
9
|
+
maxImages: zod_1.z.number(),
|
|
10
|
+
acceptedTypes: zod_1.z.array(zod_1.z.string()),
|
|
11
|
+
}),
|
|
12
|
+
});
|
|
13
|
+
exports.ImageRecognitionModelSchema = zod_1.z.object({
|
|
14
|
+
uuid: zod_1.z.string(),
|
|
15
|
+
title: zod_1.z.string(),
|
|
16
|
+
description: zod_1.z.string(),
|
|
17
|
+
aiModel: zod_1.z.string(),
|
|
18
|
+
price: zod_1.z.number(),
|
|
19
|
+
order: zod_1.z.number(),
|
|
20
|
+
status: zod_1.z.nativeEnum(common_1.TOOL_MODEL_STATUS),
|
|
21
|
+
icons: common_1.IconVariantsSchema,
|
|
22
|
+
params: exports.ImageRecognitionModelParamsSchema,
|
|
23
|
+
createdAt: zod_1.z.date(),
|
|
24
|
+
updatedAt: zod_1.z.date(),
|
|
25
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./image-recognition-category.schema"), exports);
|
|
18
|
+
__exportStar(require("./image-recognition-config.schema"), exports);
|
|
19
|
+
__exportStar(require("./image-recognition-job.schema"), exports);
|
|
20
|
+
__exportStar(require("./image-recognition-model.schema"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindImageRecognitionJobByIdQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const models_1 = require("../models");
|
|
7
|
+
var FindImageRecognitionJobByIdQuery;
|
|
8
|
+
(function (FindImageRecognitionJobByIdQuery) {
|
|
9
|
+
FindImageRecognitionJobByIdQuery.RequestSchema = zod_1.z.object({
|
|
10
|
+
uuid: zod_1.z.string().uuid(),
|
|
11
|
+
userId: zod_1.z.string().uuid().nullable().optional(),
|
|
12
|
+
unregisteredUserId: zod_1.z.string().uuid().nullable().optional(),
|
|
13
|
+
});
|
|
14
|
+
FindImageRecognitionJobByIdQuery.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.ImageRecognitionJobSchema);
|
|
15
|
+
})(FindImageRecognitionJobByIdQuery || (exports.FindImageRecognitionJobByIdQuery = FindImageRecognitionJobByIdQuery = {}));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindImageRecognitionJobsQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const command_response_schema_1 = require("../../common/models/command-response.schema");
|
|
6
|
+
const models_1 = require("../models");
|
|
7
|
+
const tools_1 = require("../../tools");
|
|
8
|
+
var FindImageRecognitionJobsQuery;
|
|
9
|
+
(function (FindImageRecognitionJobsQuery) {
|
|
10
|
+
FindImageRecognitionJobsQuery.RequestSchema = zod_1.z
|
|
11
|
+
.object({
|
|
12
|
+
userId: zod_1.z.string().uuid().optional(),
|
|
13
|
+
unregisteredUserId: zod_1.z.string().uuid().optional(),
|
|
14
|
+
title: zod_1.z.string().optional(),
|
|
15
|
+
isFavorite: zod_1.z.coerce.boolean().optional(),
|
|
16
|
+
createdAtSortOrder: zod_1.z.nativeEnum(tools_1.JOB_SORT).optional().default(tools_1.JOB_SORT.DESC),
|
|
17
|
+
status: zod_1.z.nativeEnum(tools_1.JOB_STATUS).optional(),
|
|
18
|
+
limit: zod_1.z.coerce.number().min(1).optional(),
|
|
19
|
+
offset: zod_1.z.coerce.number().min(0).default(0).optional(),
|
|
20
|
+
})
|
|
21
|
+
.refine((data) => {
|
|
22
|
+
return !(data.userId && data.unregisteredUserId);
|
|
23
|
+
}, {
|
|
24
|
+
message: 'userId and unregisteredUserId cannot be used together',
|
|
25
|
+
path: ['userId', 'unregisteredUserId'],
|
|
26
|
+
});
|
|
27
|
+
FindImageRecognitionJobsQuery.ResponseSchema = (0, command_response_schema_1.ICommandResponseSchema)(zod_1.z.object({
|
|
28
|
+
data: zod_1.z.array(models_1.ImageRecognitionJobSchema),
|
|
29
|
+
page: zod_1.z.number(),
|
|
30
|
+
totalPages: zod_1.z.number(),
|
|
31
|
+
total: zod_1.z.number(),
|
|
32
|
+
}));
|
|
33
|
+
})(FindImageRecognitionJobsQuery || (exports.FindImageRecognitionJobsQuery = FindImageRecognitionJobsQuery = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetImageRecognitionConfigQuery = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
var GetImageRecognitionConfigQuery;
|
|
7
|
+
(function (GetImageRecognitionConfigQuery) {
|
|
8
|
+
GetImageRecognitionConfigQuery.RequestSchema = common_1.LocaleRequestSchema;
|
|
9
|
+
GetImageRecognitionConfigQuery.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.ImageRecognitionConfigSchema);
|
|
10
|
+
})(GetImageRecognitionConfigQuery || (exports.GetImageRecognitionConfigQuery = GetImageRecognitionConfigQuery = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./get-image-recognition-config.query"), exports);
|
|
18
|
+
__exportStar(require("./find-image-recognition-job-by-id.query"), exports);
|
|
19
|
+
__exportStar(require("./find-image-recognition-jobs.query"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IMAGE_RECOGNITION_AMQP_ROUTES = void 0;
|
|
4
|
+
exports.IMAGE_RECOGNITION_AMQP_ROUTES = {
|
|
5
|
+
EXECUTE: 'tools.image-recognition.execute.rpc',
|
|
6
|
+
GET_PRICE: 'tools.image-recognition.get-price.rpc',
|
|
7
|
+
CONFIG: 'tools.image-recognition.config.rpc',
|
|
8
|
+
GET_JOB: 'tools.image-recognition.jobs.get.rpc',
|
|
9
|
+
LIST_JOBS: 'tools.image-recognition.jobs.list.rpc',
|
|
10
|
+
SET_REACTION: 'tools.image-recognition.jobs.set-reaction.rpc',
|
|
11
|
+
UPDATE_TITLE: 'tools.image-recognition.jobs.update-title.rpc',
|
|
12
|
+
UPDATE_FAVORITE: 'tools.image-recognition.jobs.update-favorite.rpc',
|
|
13
|
+
SOFT_DELETE: 'tools.image-recognition.jobs.soft-delete.rpc',
|
|
14
|
+
SOFT_DELETE_ALL: 'tools.image-recognition.jobs.soft-delete-all.rpc',
|
|
15
|
+
RETRY: 'tools.image-recognition.jobs.retry.rpc',
|
|
16
|
+
};
|
|
@@ -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("./image-recognition.amqp.routes"), exports);
|
package/build/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __exportStar(require("./spell-corrector"), exports);
|
|
|
60
60
|
__exportStar(require("./html-page-builder"), exports);
|
|
61
61
|
__exportStar(require("./tool-workspace"), exports);
|
|
62
62
|
__exportStar(require("./diagrams"), exports);
|
|
63
|
+
__exportStar(require("./image-recognition"), exports);
|
|
63
64
|
const common = __importStar(require("./common"));
|
|
64
65
|
const paraphrase = __importStar(require("./paraphrase"));
|
|
65
66
|
const tools = __importStar(require("./tools"));
|
|
@@ -83,6 +84,7 @@ const htmlPageBuilder = __importStar(require("./html-page-builder"));
|
|
|
83
84
|
const accountMerge = __importStar(require("./account-merge"));
|
|
84
85
|
const toolWorkspace = __importStar(require("./tool-workspace"));
|
|
85
86
|
const diagrams = __importStar(require("./diagrams"));
|
|
87
|
+
const imageRecognition = __importStar(require("./image-recognition"));
|
|
86
88
|
var ToolService;
|
|
87
89
|
(function (ToolService) {
|
|
88
90
|
ToolService.Common = common;
|
|
@@ -108,4 +110,5 @@ var ToolService;
|
|
|
108
110
|
ToolService.AccountMerge = accountMerge;
|
|
109
111
|
ToolService.ToolWorkspace = toolWorkspace;
|
|
110
112
|
ToolService.Diagrams = diagrams;
|
|
113
|
+
ToolService.ImageRecognition = imageRecognition;
|
|
111
114
|
})(ToolService || (exports.ToolService = ToolService = {}));
|
|
@@ -20,4 +20,5 @@ var TOOL_CONTENT_TYPE;
|
|
|
20
20
|
TOOL_CONTENT_TYPE["SPELL_CORRECTOR"] = "SPELL_CORRECTOR";
|
|
21
21
|
TOOL_CONTENT_TYPE["DIAGRAMS"] = "DIAGRAMS";
|
|
22
22
|
TOOL_CONTENT_TYPE["HTML_PAGE_BUILDER"] = "HTML_PAGE_BUILDER";
|
|
23
|
+
TOOL_CONTENT_TYPE["IMAGE_RECOGNITION"] = "IMAGE_RECOGNITION";
|
|
23
24
|
})(TOOL_CONTENT_TYPE || (exports.TOOL_CONTENT_TYPE = TOOL_CONTENT_TYPE = {}));
|
|
@@ -22,4 +22,5 @@ var TOOL_TYPE;
|
|
|
22
22
|
TOOL_TYPE["SOLVING_EDU_TASK"] = "SOLVING_EDU_TASK";
|
|
23
23
|
TOOL_TYPE["DIAGRAMS"] = "DIAGRAMS";
|
|
24
24
|
TOOL_TYPE["HTML_PAGE_BUILDER"] = "HTML_PAGE_BUILDER";
|
|
25
|
+
TOOL_TYPE["IMAGE_RECOGNITION"] = "IMAGE_RECOGNITION";
|
|
25
26
|
})(TOOL_TYPE || (exports.TOOL_TYPE = TOOL_TYPE = {}));
|
|
@@ -19,6 +19,7 @@ const solving_edu_task_1 = require("../../solving-edu-task");
|
|
|
19
19
|
const spell_corrector_1 = require("../../spell-corrector");
|
|
20
20
|
const diagrams_1 = require("../../diagrams");
|
|
21
21
|
const models_2 = require("../../html-page-builder/models");
|
|
22
|
+
const image_recognition_1 = require("../../image-recognition");
|
|
22
23
|
exports.GlobalToolsConfigSchema = zod_1.z.object({
|
|
23
24
|
[enums_1.TOOL_CONTENT_TYPE.VIDEO]: video_1.VideoConfigSchema,
|
|
24
25
|
[enums_1.TOOL_CONTENT_TYPE.MUSIC]: music_1.MusicConfigSchema,
|
|
@@ -36,4 +37,5 @@ exports.GlobalToolsConfigSchema = zod_1.z.object({
|
|
|
36
37
|
[enums_1.TOOL_CONTENT_TYPE.SPELL_CORRECTOR]: spell_corrector_1.SpellCorrectorToolConfigSchema,
|
|
37
38
|
[enums_1.TOOL_CONTENT_TYPE.DIAGRAMS]: diagrams_1.DiagramsConfigSchema,
|
|
38
39
|
[enums_1.TOOL_CONTENT_TYPE.HTML_PAGE_BUILDER]: models_2.HtmlPageBuilderConfigSchema,
|
|
40
|
+
[enums_1.TOOL_CONTENT_TYPE.IMAGE_RECOGNITION]: image_recognition_1.ImageRecognitionConfigSchema,
|
|
39
41
|
});
|
|
@@ -20,6 +20,7 @@ const solving_edu_task_1 = require("../../solving-edu-task");
|
|
|
20
20
|
const spell_corrector_1 = require("../../spell-corrector");
|
|
21
21
|
const diagrams_1 = require("../../diagrams");
|
|
22
22
|
const models_2 = require("../../html-page-builder/models");
|
|
23
|
+
const image_recognition_1 = require("../../image-recognition");
|
|
23
24
|
// Discriminated union array: Tools with their configs
|
|
24
25
|
exports.ToolWithConfigSchema = zod_1.z.discriminatedUnion('contentType', [
|
|
25
26
|
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
@@ -86,5 +87,9 @@ exports.ToolWithConfigSchema = zod_1.z.discriminatedUnion('contentType', [
|
|
|
86
87
|
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.HTML_PAGE_BUILDER),
|
|
87
88
|
config: models_2.HtmlPageBuilderConfigSchema,
|
|
88
89
|
})),
|
|
90
|
+
tool_schema_1.ToolSchema.merge(zod_1.z.object({
|
|
91
|
+
contentType: zod_1.z.literal(enums_1.TOOL_CONTENT_TYPE.IMAGE_RECOGNITION),
|
|
92
|
+
config: image_recognition_1.ImageRecognitionConfigSchema,
|
|
93
|
+
})),
|
|
89
94
|
]);
|
|
90
95
|
exports.ToolsWithConfigsSchema = zod_1.z.array(exports.ToolWithConfigSchema);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteAllImageRecognitionJobsCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
});
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = ICommandResponseSchema(z.boolean());
|
|
12
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace DeleteImageRecognitionJobByUuidCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
userId: z.string().uuid().nullable().optional(),
|
|
7
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
8
|
+
uuid: z.string().uuid(),
|
|
9
|
+
});
|
|
10
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
11
|
+
|
|
12
|
+
export const ResponseSchema = ICommandResponseSchema(z.boolean());
|
|
13
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
|
|
4
|
+
export namespace GetImageRecognitionPriceCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
modelId: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
9
|
+
|
|
10
|
+
export const ResponseDataSchema = z.object({
|
|
11
|
+
price: z.number(),
|
|
12
|
+
});
|
|
13
|
+
export type ResponseData = z.infer<typeof ResponseDataSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = ICommandResponseSchema(ResponseDataSchema);
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageRecognitionJobSchema } from '../models';
|
|
4
|
+
import { AttachedFileSchema, LocaleSchema } from '../../common';
|
|
5
|
+
|
|
6
|
+
export namespace ImageRecognitionCommand {
|
|
7
|
+
export const RequestSchema = z.object({
|
|
8
|
+
locale: LocaleSchema,
|
|
9
|
+
userId: z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
11
|
+
prompt: z.string().optional(),
|
|
12
|
+
categoryId: z.string().uuid(),
|
|
13
|
+
modelId: z.string().uuid(),
|
|
14
|
+
params: z.object({
|
|
15
|
+
attachedFiles: z.array(AttachedFileSchema),
|
|
16
|
+
}),
|
|
17
|
+
tokenReservationId: z.string().uuid().optional(),
|
|
18
|
+
precalculatedPrice: z.number().optional(),
|
|
19
|
+
});
|
|
20
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
21
|
+
|
|
22
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionJobSchema);
|
|
23
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './get-image-recognition-price.command';
|
|
2
|
+
export * from './image-recognition.command';
|
|
3
|
+
export * from './retry-image-recognition-job.command';
|
|
4
|
+
export * from './set-reaction-to-image-recognition-job.command';
|
|
5
|
+
export * from './update-image-recognition-job-title.command';
|
|
6
|
+
export * from './update-image-recognition-job-favorite.command';
|
|
7
|
+
export * from './delete-image-recognition-job-by-uuid.command';
|
|
8
|
+
export * from './delete-all-image-recognition-jobs.command';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { LocaleSchema } from '../../common/models/locale.schema';
|
|
4
|
+
import { ImageRecognitionJobSchema } from '../models';
|
|
5
|
+
import { AttachedFileSchema } from '../../common';
|
|
6
|
+
|
|
7
|
+
export namespace RetryImageRecognitionJobCommand {
|
|
8
|
+
export const RequestSchema = z.object({
|
|
9
|
+
locale: LocaleSchema,
|
|
10
|
+
uuid: z.string().uuid(),
|
|
11
|
+
tokenReservationId: z.string().uuid().optional(),
|
|
12
|
+
precalculatedPrice: z.number().optional(),
|
|
13
|
+
userId: z.string().uuid().nullable().optional(),
|
|
14
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
15
|
+
prompt: z.string().optional(),
|
|
16
|
+
categoryId: z.string().uuid().optional(),
|
|
17
|
+
modelId: z.string().uuid().optional(),
|
|
18
|
+
params: z
|
|
19
|
+
.object({
|
|
20
|
+
attachedFiles: z.array(AttachedFileSchema),
|
|
21
|
+
})
|
|
22
|
+
.optional(),
|
|
23
|
+
});
|
|
24
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
25
|
+
|
|
26
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionJobSchema);
|
|
27
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { USER_REACTION } from '../../common';
|
|
3
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
4
|
+
import { ImageRecognitionJobSchema } from '../models';
|
|
5
|
+
|
|
6
|
+
export namespace SetReactionToImageRecognitionJobCommand {
|
|
7
|
+
export const RequestSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
userId: z.string().uuid().nullable().optional(),
|
|
10
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
11
|
+
uuid: z.string().uuid(),
|
|
12
|
+
reaction: z.nativeEnum(USER_REACTION).nullable(),
|
|
13
|
+
dislikeReason: z.string().nullable().default(null),
|
|
14
|
+
})
|
|
15
|
+
.refine(
|
|
16
|
+
(data) => {
|
|
17
|
+
if (data.reaction !== USER_REACTION.DISLIKED && data.dislikeReason) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
message: 'Dislike reason is not allowed when reaction is not disliked',
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
28
|
+
|
|
29
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionJobSchema);
|
|
30
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageRecognitionJobSchema } from '../models/image-recognition-job.schema';
|
|
4
|
+
|
|
5
|
+
export namespace UpdateImageRecognitionJobFavoriteCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
uuid: z.string().uuid(),
|
|
8
|
+
userId: z.string().uuid().nullable().optional(),
|
|
9
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
10
|
+
isFavorite: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionJobSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ImageRecognitionJobSchema } from '../models';
|
|
3
|
+
import { ICommandResponseSchema } from '../../common';
|
|
4
|
+
|
|
5
|
+
export namespace UpdateImageRecognitionJobTitleCommand {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
userId: z.string().uuid().nullable().optional(),
|
|
8
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
9
|
+
uuid: z.string().uuid(),
|
|
10
|
+
title: z.string(),
|
|
11
|
+
});
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionJobSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TOOL_MODEL_STATUS } from '../../common';
|
|
3
|
+
|
|
4
|
+
export const ImageRecognitionCategorySchema = z.object({
|
|
5
|
+
uuid: z.string(),
|
|
6
|
+
parentId: z.string().nullable(),
|
|
7
|
+
title: z.string(),
|
|
8
|
+
systemPrompt: z.string(),
|
|
9
|
+
order: z.number(),
|
|
10
|
+
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
11
|
+
createdAt: z.date(),
|
|
12
|
+
updatedAt: z.date(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type ImageRecognitionCategory = z.infer<typeof ImageRecognitionCategorySchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ImageRecognitionModelSchema } from './image-recognition-model.schema';
|
|
3
|
+
import { ImageRecognitionCategorySchema } from './image-recognition-category.schema';
|
|
4
|
+
|
|
5
|
+
export const ImageRecognitionConfigSchema = z.object({
|
|
6
|
+
models: z.array(ImageRecognitionModelSchema),
|
|
7
|
+
categories: z.array(ImageRecognitionCategorySchema),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type ImageRecognitionConfig = z.infer<typeof ImageRecognitionConfigSchema>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { JOB_STATUS } from '../../tools';
|
|
3
|
+
import { AttachedFileSchema, USER_REACTION } from '../../common';
|
|
4
|
+
|
|
5
|
+
export const ImageRecognitionJobParamsSchema = z.object({
|
|
6
|
+
attachedFiles: z.array(AttachedFileSchema),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type ImageRecognitionJobParams = z.infer<typeof ImageRecognitionJobParamsSchema>;
|
|
10
|
+
|
|
11
|
+
export const ImageRecognitionJobSchema = z.object({
|
|
12
|
+
uuid: z.string(),
|
|
13
|
+
prompt: z.string().nullable(),
|
|
14
|
+
categoryId: z.string(),
|
|
15
|
+
aiOutput: z.string().nullable().optional(),
|
|
16
|
+
reaction: z.nativeEnum(USER_REACTION).nullable(),
|
|
17
|
+
dislikeReason: z.string().nullable(),
|
|
18
|
+
externalId: z.string().nullable(),
|
|
19
|
+
title: z.string(),
|
|
20
|
+
status: z.nativeEnum(JOB_STATUS),
|
|
21
|
+
error: z.string().nullable(),
|
|
22
|
+
internalError: z.string().nullable().optional(),
|
|
23
|
+
modelId: z.string(),
|
|
24
|
+
price: z.number(),
|
|
25
|
+
params: ImageRecognitionJobParamsSchema,
|
|
26
|
+
attempts: z.array(z.any()),
|
|
27
|
+
userId: z.string().nullable().optional(),
|
|
28
|
+
unregisteredUserId: z.string().nullable().optional(),
|
|
29
|
+
tokenReservationId: z.string().nullable().optional(),
|
|
30
|
+
isDeleted: z.boolean(),
|
|
31
|
+
isFavorite: z.boolean(),
|
|
32
|
+
createdAt: z.date(),
|
|
33
|
+
completedAt: z.date().nullable().optional(),
|
|
34
|
+
updatedAt: z.date(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export type ImageRecognitionJob = z.infer<typeof ImageRecognitionJobSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IconVariantsSchema, TOOL_MODEL_STATUS } from '../../common';
|
|
3
|
+
|
|
4
|
+
export const ImageRecognitionModelParamsSchema = z.object({
|
|
5
|
+
imageAttachment: z.object({
|
|
6
|
+
supported: z.boolean(),
|
|
7
|
+
maxImages: z.number(),
|
|
8
|
+
acceptedTypes: z.array(z.string()),
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type ImageRecognitionModelParams = z.infer<typeof ImageRecognitionModelParamsSchema>;
|
|
13
|
+
|
|
14
|
+
export const ImageRecognitionModelSchema = z.object({
|
|
15
|
+
uuid: z.string(),
|
|
16
|
+
title: z.string(),
|
|
17
|
+
description: z.string(),
|
|
18
|
+
aiModel: z.string(),
|
|
19
|
+
price: z.number(),
|
|
20
|
+
order: z.number(),
|
|
21
|
+
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
22
|
+
icons: IconVariantsSchema,
|
|
23
|
+
params: ImageRecognitionModelParamsSchema,
|
|
24
|
+
createdAt: z.date(),
|
|
25
|
+
updatedAt: z.date(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type ImageRecognitionModel = z.infer<typeof ImageRecognitionModelSchema>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common';
|
|
3
|
+
import { ImageRecognitionJobSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace FindImageRecognitionJobByIdQuery {
|
|
6
|
+
export const RequestSchema = z.object({
|
|
7
|
+
uuid: z.string().uuid(),
|
|
8
|
+
userId: z.string().uuid().nullable().optional(),
|
|
9
|
+
unregisteredUserId: z.string().uuid().nullable().optional(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionJobSchema);
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema } from '../../common/models/command-response.schema';
|
|
3
|
+
import { ImageRecognitionJobSchema } from '../models';
|
|
4
|
+
import { JOB_SORT, JOB_STATUS } from '../../tools';
|
|
5
|
+
|
|
6
|
+
export namespace FindImageRecognitionJobsQuery {
|
|
7
|
+
export const RequestSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
userId: z.string().uuid().optional(),
|
|
10
|
+
unregisteredUserId: z.string().uuid().optional(),
|
|
11
|
+
title: z.string().optional(),
|
|
12
|
+
isFavorite: z.coerce.boolean().optional(),
|
|
13
|
+
createdAtSortOrder: z.nativeEnum(JOB_SORT).optional().default(JOB_SORT.DESC),
|
|
14
|
+
status: z.nativeEnum(JOB_STATUS).optional(),
|
|
15
|
+
limit: z.coerce.number().min(1).optional(),
|
|
16
|
+
offset: z.coerce.number().min(0).default(0).optional(),
|
|
17
|
+
})
|
|
18
|
+
.refine(
|
|
19
|
+
(data) => {
|
|
20
|
+
return !(data.userId && data.unregisteredUserId);
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
message: 'userId and unregisteredUserId cannot be used together',
|
|
24
|
+
path: ['userId', 'unregisteredUserId'],
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
28
|
+
|
|
29
|
+
export const ResponseSchema = ICommandResponseSchema(
|
|
30
|
+
z.object({
|
|
31
|
+
data: z.array(ImageRecognitionJobSchema),
|
|
32
|
+
page: z.number(),
|
|
33
|
+
totalPages: z.number(),
|
|
34
|
+
total: z.number(),
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ICommandResponseSchema, LocaleRequestSchema } from '../../common';
|
|
3
|
+
import { ImageRecognitionConfigSchema } from '../models';
|
|
4
|
+
|
|
5
|
+
export namespace GetImageRecognitionConfigQuery {
|
|
6
|
+
export const RequestSchema = LocaleRequestSchema;
|
|
7
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
8
|
+
|
|
9
|
+
export const ResponseSchema = ICommandResponseSchema(ImageRecognitionConfigSchema);
|
|
10
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const IMAGE_RECOGNITION_AMQP_ROUTES = {
|
|
2
|
+
EXECUTE: 'tools.image-recognition.execute.rpc',
|
|
3
|
+
GET_PRICE: 'tools.image-recognition.get-price.rpc',
|
|
4
|
+
CONFIG: 'tools.image-recognition.config.rpc',
|
|
5
|
+
GET_JOB: 'tools.image-recognition.jobs.get.rpc',
|
|
6
|
+
LIST_JOBS: 'tools.image-recognition.jobs.list.rpc',
|
|
7
|
+
SET_REACTION: 'tools.image-recognition.jobs.set-reaction.rpc',
|
|
8
|
+
UPDATE_TITLE: 'tools.image-recognition.jobs.update-title.rpc',
|
|
9
|
+
UPDATE_FAVORITE: 'tools.image-recognition.jobs.update-favorite.rpc',
|
|
10
|
+
SOFT_DELETE: 'tools.image-recognition.jobs.soft-delete.rpc',
|
|
11
|
+
SOFT_DELETE_ALL: 'tools.image-recognition.jobs.soft-delete-all.rpc',
|
|
12
|
+
RETRY: 'tools.image-recognition.jobs.retry.rpc',
|
|
13
|
+
} as const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './image-recognition.amqp.routes';
|
package/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './spell-corrector';
|
|
|
21
21
|
export * from './html-page-builder';
|
|
22
22
|
export * from './tool-workspace';
|
|
23
23
|
export * from './diagrams';
|
|
24
|
+
export * from './image-recognition';
|
|
24
25
|
|
|
25
26
|
import * as common from './common';
|
|
26
27
|
import * as paraphrase from './paraphrase';
|
|
@@ -45,6 +46,7 @@ import * as htmlPageBuilder from './html-page-builder';
|
|
|
45
46
|
import * as accountMerge from './account-merge';
|
|
46
47
|
import * as toolWorkspace from './tool-workspace';
|
|
47
48
|
import * as diagrams from './diagrams';
|
|
49
|
+
import * as imageRecognition from './image-recognition';
|
|
48
50
|
|
|
49
51
|
export namespace ToolService {
|
|
50
52
|
export import Common = common;
|
|
@@ -70,4 +72,5 @@ export namespace ToolService {
|
|
|
70
72
|
export import AccountMerge = accountMerge;
|
|
71
73
|
export import ToolWorkspace = toolWorkspace;
|
|
72
74
|
export import Diagrams = diagrams;
|
|
75
|
+
export import ImageRecognition = imageRecognition;
|
|
73
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpleschool/gptbot-tools",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
"@purpleschool/rugpt-lib-common": "^0.0.21",
|
|
16
16
|
"zod": "^3.25.67"
|
|
17
17
|
}
|
|
18
|
-
}
|
|
18
|
+
}
|
|
@@ -16,6 +16,7 @@ import { SolvingEduTaskConfigSchema } from '../../solving-edu-task';
|
|
|
16
16
|
import { SpellCorrectorToolConfigSchema } from '../../spell-corrector';
|
|
17
17
|
import { DiagramsConfigSchema } from '../../diagrams';
|
|
18
18
|
import { HtmlPageBuilderConfigSchema } from '../../html-page-builder/models';
|
|
19
|
+
import { ImageRecognitionConfigSchema } from '../../image-recognition';
|
|
19
20
|
|
|
20
21
|
export const GlobalToolsConfigSchema = z.object({
|
|
21
22
|
[TOOL_CONTENT_TYPE.VIDEO]: VideoConfigSchema,
|
|
@@ -34,6 +35,7 @@ export const GlobalToolsConfigSchema = z.object({
|
|
|
34
35
|
[TOOL_CONTENT_TYPE.SPELL_CORRECTOR]: SpellCorrectorToolConfigSchema,
|
|
35
36
|
[TOOL_CONTENT_TYPE.DIAGRAMS]: DiagramsConfigSchema,
|
|
36
37
|
[TOOL_CONTENT_TYPE.HTML_PAGE_BUILDER]: HtmlPageBuilderConfigSchema,
|
|
38
|
+
[TOOL_CONTENT_TYPE.IMAGE_RECOGNITION]: ImageRecognitionConfigSchema,
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
export type GlobalToolsConfig = z.infer<typeof GlobalToolsConfigSchema>;
|
|
@@ -17,6 +17,7 @@ import { SolvingEduTaskConfigSchema } from '../../solving-edu-task';
|
|
|
17
17
|
import { SpellCorrectorToolConfigSchema } from '../../spell-corrector';
|
|
18
18
|
import { DiagramsConfigSchema } from '../../diagrams';
|
|
19
19
|
import { HtmlPageBuilderConfigSchema } from '../../html-page-builder/models';
|
|
20
|
+
import { ImageRecognitionConfigSchema } from '../../image-recognition';
|
|
20
21
|
|
|
21
22
|
// Discriminated union array: Tools with their configs
|
|
22
23
|
export const ToolWithConfigSchema = z.discriminatedUnion('contentType', [
|
|
@@ -116,6 +117,12 @@ export const ToolWithConfigSchema = z.discriminatedUnion('contentType', [
|
|
|
116
117
|
config: HtmlPageBuilderConfigSchema,
|
|
117
118
|
}),
|
|
118
119
|
),
|
|
120
|
+
ToolSchema.merge(
|
|
121
|
+
z.object({
|
|
122
|
+
contentType: z.literal(TOOL_CONTENT_TYPE.IMAGE_RECOGNITION),
|
|
123
|
+
config: ImageRecognitionConfigSchema,
|
|
124
|
+
}),
|
|
125
|
+
),
|
|
119
126
|
]);
|
|
120
127
|
|
|
121
128
|
export type ToolWithConfig = z.infer<typeof ToolWithConfigSchema>;
|