@purpleschool/gptbot 0.5.98 → 0.6.0
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/api/controllers/http/prompt-category.ts +1 -0
- package/api/controllers/http/prompt-topic.ts +2 -0
- package/api/controllers/http/prompt.ts +3 -0
- package/api/routes.ts +12 -0
- package/build/api/controllers/http/prompt-category.js +1 -0
- package/build/api/controllers/http/prompt-topic.js +2 -0
- package/build/api/controllers/http/prompt.js +3 -0
- package/build/api/routes.js +8 -0
- package/build/commands/prompt/find-all-prompts.command.js +11 -0
- package/build/commands/prompt/find-prompt-by-uuid.command.js +14 -0
- package/build/commands/prompt/find-prompts-by-topic.command.js +17 -0
- package/build/commands/prompt/index.js +3 -0
- package/build/commands/prompt-category/find-prompt-category-by-uuid.command.js +14 -0
- package/build/commands/prompt-category/index.js +1 -0
- package/build/commands/prompt-topic/find-all-prompt-topics.command.js +11 -0
- package/build/commands/prompt-topic/find-prompt-topic-by-uuid.command.js +14 -0
- package/build/commands/prompt-topic/index.js +2 -0
- package/build/constants/ai-model/enums/ai-model-config-selector-type.enum.js +1 -0
- package/build/helpers/ai-model/calc-base-text-generation-price.helper.js +15 -0
- package/build/helpers/ai-model/index.js +17 -0
- package/build/helpers/index.js +1 -0
- package/build/models/ai-model-config.schema.js +8 -1
- package/commands/prompt/find-all-prompts.command.ts +12 -0
- package/commands/prompt/find-prompt-by-uuid.command.ts +16 -0
- package/commands/prompt/find-prompts-by-topic.command.ts +16 -0
- package/commands/prompt/index.ts +3 -0
- package/commands/prompt-category/find-prompt-category-by-uuid.command.ts +16 -0
- package/commands/prompt-category/index.ts +1 -0
- package/commands/prompt-topic/find-all-prompt-topics.command.ts +12 -0
- package/commands/prompt-topic/find-prompt-topic-by-uuid.command.ts +16 -0
- package/commands/prompt-topic/index.ts +2 -0
- package/constants/ai-model/enums/ai-model-config-selector-type.enum.ts +1 -0
- package/helpers/ai-model/calc-base-text-generation-price.helper.ts +24 -0
- package/helpers/ai-model/index.ts +1 -0
- package/helpers/index.ts +1 -0
- package/models/ai-model-config.schema.ts +12 -0
- package/package.json +1 -1
package/api/routes.ts
CHANGED
|
@@ -200,6 +200,8 @@ export const REST_API = {
|
|
|
200
200
|
},
|
|
201
201
|
PROMPT_CATEGORY_PUBLIC: {
|
|
202
202
|
FIND_ALL: `${ROOT}/${CONTROLLERS.PROMPT_CATEGORY_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_CATEGORY_ROUTES.FIND_ALL}`,
|
|
203
|
+
FIND_BY_UUID: (uuid: string) =>
|
|
204
|
+
`${ROOT}/${CONTROLLERS.PROMPT_CATEGORY_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_CATEGORY_ROUTES.FIND_BY_UUID(uuid)}`,
|
|
203
205
|
},
|
|
204
206
|
PROMPT_TOPIC_PRIVATE: {
|
|
205
207
|
CREATE: `${ROOT}/${CONTROLLERS.PROMPT_TOPIC_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.CREATE}`,
|
|
@@ -211,6 +213,9 @@ export const REST_API = {
|
|
|
211
213
|
PROMPT_TOPIC_PUBLIC: {
|
|
212
214
|
FIND: (categoryId: string) =>
|
|
213
215
|
`${ROOT}/${CONTROLLERS.PROMPT_TOPIC_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.FIND(categoryId)}`,
|
|
216
|
+
FIND_BY_UUID: (uuid: string) =>
|
|
217
|
+
`${ROOT}/${CONTROLLERS.PROMPT_TOPIC_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.FIND_BY_UUID(uuid)}`,
|
|
218
|
+
FIND_ALL: `${ROOT}/${CONTROLLERS.PROMPT_TOPIC_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.FIND_ALL}`,
|
|
214
219
|
},
|
|
215
220
|
PROMPT_PRIVATE: {
|
|
216
221
|
CREATE: `${ROOT}/${CONTROLLERS.PROMPT_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.CREATE}`,
|
|
@@ -219,4 +224,11 @@ export const REST_API = {
|
|
|
219
224
|
DELETE: (uuid: string) =>
|
|
220
225
|
`${ROOT}/${CONTROLLERS.PROMPT_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.DELETE(uuid)}`,
|
|
221
226
|
},
|
|
227
|
+
PROMPT_PUBLIC: {
|
|
228
|
+
FIND_BY_UUID: (uuid: string) =>
|
|
229
|
+
`${ROOT}/${CONTROLLERS.PROMPT_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.FIND_BY_UUID(uuid)}`,
|
|
230
|
+
FIND_ALL: `${ROOT}/${CONTROLLERS.PROMPT_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.FIND_ALL}`,
|
|
231
|
+
FIND: (topicId: string) =>
|
|
232
|
+
`${ROOT}/${CONTROLLERS.PROMPT_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.FIND(topicId)}`,
|
|
233
|
+
},
|
|
222
234
|
} as const;
|
package/build/api/routes.js
CHANGED
|
@@ -199,6 +199,7 @@ exports.REST_API = {
|
|
|
199
199
|
},
|
|
200
200
|
PROMPT_CATEGORY_PUBLIC: {
|
|
201
201
|
FIND_ALL: `${exports.ROOT}/${CONTROLLERS.PROMPT_CATEGORY_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_CATEGORY_ROUTES.FIND_ALL}`,
|
|
202
|
+
FIND_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMPT_CATEGORY_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_CATEGORY_ROUTES.FIND_BY_UUID(uuid)}`,
|
|
202
203
|
},
|
|
203
204
|
PROMPT_TOPIC_PRIVATE: {
|
|
204
205
|
CREATE: `${exports.ROOT}/${CONTROLLERS.PROMPT_TOPIC_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.CREATE}`,
|
|
@@ -207,10 +208,17 @@ exports.REST_API = {
|
|
|
207
208
|
},
|
|
208
209
|
PROMPT_TOPIC_PUBLIC: {
|
|
209
210
|
FIND: (categoryId) => `${exports.ROOT}/${CONTROLLERS.PROMPT_TOPIC_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.FIND(categoryId)}`,
|
|
211
|
+
FIND_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMPT_TOPIC_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.FIND_BY_UUID(uuid)}`,
|
|
212
|
+
FIND_ALL: `${exports.ROOT}/${CONTROLLERS.PROMPT_TOPIC_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_TOPIC_ROUTES.FIND_ALL}`,
|
|
210
213
|
},
|
|
211
214
|
PROMPT_PRIVATE: {
|
|
212
215
|
CREATE: `${exports.ROOT}/${CONTROLLERS.PROMPT_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.CREATE}`,
|
|
213
216
|
PATCH: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMPT_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.UPDATE(uuid)}`,
|
|
214
217
|
DELETE: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMPT_PRIVATE_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.DELETE(uuid)}`,
|
|
215
218
|
},
|
|
219
|
+
PROMPT_PUBLIC: {
|
|
220
|
+
FIND_BY_UUID: (uuid) => `${exports.ROOT}/${CONTROLLERS.PROMPT_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.FIND_BY_UUID(uuid)}`,
|
|
221
|
+
FIND_ALL: `${exports.ROOT}/${CONTROLLERS.PROMPT_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.FIND_ALL}`,
|
|
222
|
+
FIND: (topicId) => `${exports.ROOT}/${CONTROLLERS.PROMPT_PUBLIC_CONTROLLER}/${CONTROLLERS.PROMPT_ROUTES.FIND(topicId)}`,
|
|
223
|
+
},
|
|
216
224
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindAllPromptsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var FindAllPromptsCommand;
|
|
7
|
+
(function (FindAllPromptsCommand) {
|
|
8
|
+
FindAllPromptsCommand.ResponseSchema = zod_1.z.object({
|
|
9
|
+
data: zod_1.z.array(models_1.PromptSchema),
|
|
10
|
+
});
|
|
11
|
+
})(FindAllPromptsCommand || (exports.FindAllPromptsCommand = FindAllPromptsCommand = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindPromptByUuidCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var FindPromptByUuidCommand;
|
|
7
|
+
(function (FindPromptByUuidCommand) {
|
|
8
|
+
FindPromptByUuidCommand.RequestSchema = models_1.PromptSchema.pick({
|
|
9
|
+
uuid: true,
|
|
10
|
+
});
|
|
11
|
+
FindPromptByUuidCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
+
data: models_1.PromptSchema,
|
|
13
|
+
});
|
|
14
|
+
})(FindPromptByUuidCommand || (exports.FindPromptByUuidCommand = FindPromptByUuidCommand = {}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FindPromptsByTopicCommand = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const models_1 = require("../../models");
|
|
9
|
+
var FindPromptsByTopicCommand;
|
|
10
|
+
(function (FindPromptsByTopicCommand) {
|
|
11
|
+
FindPromptsByTopicCommand.RequestSchema = zod_1.default.object({
|
|
12
|
+
topicId: zod_1.default.string().uuid(),
|
|
13
|
+
});
|
|
14
|
+
FindPromptsByTopicCommand.ResponseSchema = zod_1.default.object({
|
|
15
|
+
data: zod_1.default.array(models_1.PromptSchema),
|
|
16
|
+
});
|
|
17
|
+
})(FindPromptsByTopicCommand || (exports.FindPromptsByTopicCommand = FindPromptsByTopicCommand = {}));
|
|
@@ -17,3 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./create-prompt.command"), exports);
|
|
18
18
|
__exportStar(require("./delete-prompt.command"), exports);
|
|
19
19
|
__exportStar(require("./update-prompt.command"), exports);
|
|
20
|
+
__exportStar(require("./find-prompt-by-uuid.command"), exports);
|
|
21
|
+
__exportStar(require("./find-all-prompts.command"), exports);
|
|
22
|
+
__exportStar(require("./find-prompts-by-topic.command"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindPromptCategoryByUuidCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var FindPromptCategoryByUuidCommand;
|
|
7
|
+
(function (FindPromptCategoryByUuidCommand) {
|
|
8
|
+
FindPromptCategoryByUuidCommand.RequestSchema = models_1.PromptCategorySchema.pick({
|
|
9
|
+
uuid: true,
|
|
10
|
+
});
|
|
11
|
+
FindPromptCategoryByUuidCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
+
data: models_1.PromptCategorySchema,
|
|
13
|
+
});
|
|
14
|
+
})(FindPromptCategoryByUuidCommand || (exports.FindPromptCategoryByUuidCommand = FindPromptCategoryByUuidCommand = {}));
|
|
@@ -18,3 +18,4 @@ __exportStar(require("./create-prompt-category.command"), exports);
|
|
|
18
18
|
__exportStar(require("./delete-prompt-category.command"), exports);
|
|
19
19
|
__exportStar(require("./update-prompt-category.command"), exports);
|
|
20
20
|
__exportStar(require("./find-all-prompt-categories.command"), exports);
|
|
21
|
+
__exportStar(require("./find-prompt-category-by-uuid.command"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindAllPromptTopicsCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var FindAllPromptTopicsCommand;
|
|
7
|
+
(function (FindAllPromptTopicsCommand) {
|
|
8
|
+
FindAllPromptTopicsCommand.ResponseSchema = zod_1.z.object({
|
|
9
|
+
data: zod_1.z.array(models_1.PromptTopicSchema),
|
|
10
|
+
});
|
|
11
|
+
})(FindAllPromptTopicsCommand || (exports.FindAllPromptTopicsCommand = FindAllPromptTopicsCommand = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindPromptTopicByUuidCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var FindPromptTopicByUuidCommand;
|
|
7
|
+
(function (FindPromptTopicByUuidCommand) {
|
|
8
|
+
FindPromptTopicByUuidCommand.RequestSchema = models_1.PromptTopicSchema.pick({
|
|
9
|
+
uuid: true,
|
|
10
|
+
});
|
|
11
|
+
FindPromptTopicByUuidCommand.ResponseSchema = zod_1.z.object({
|
|
12
|
+
data: models_1.PromptTopicSchema,
|
|
13
|
+
});
|
|
14
|
+
})(FindPromptTopicByUuidCommand || (exports.FindPromptTopicByUuidCommand = FindPromptTopicByUuidCommand = {}));
|
|
@@ -18,3 +18,5 @@ __exportStar(require("./create-prompt-topic.command"), exports);
|
|
|
18
18
|
__exportStar(require("./delete-prompt-topic.command"), exports);
|
|
19
19
|
__exportStar(require("./update-prompt-topic.command"), exports);
|
|
20
20
|
__exportStar(require("./find-prompt-topic-by-category.command"), exports);
|
|
21
|
+
__exportStar(require("./find-prompt-topic-by-uuid.command"), exports);
|
|
22
|
+
__exportStar(require("./find-all-prompt-topics.command"), exports);
|
|
@@ -6,4 +6,5 @@ var AI_MODEL_CONFIG_PARAM;
|
|
|
6
6
|
AI_MODEL_CONFIG_PARAM["IMAGE_SIZE"] = "image-size";
|
|
7
7
|
AI_MODEL_CONFIG_PARAM["IMAGE_STYLE"] = "image-style";
|
|
8
8
|
AI_MODEL_CONFIG_PARAM["WEB_SEARCH"] = "web-search";
|
|
9
|
+
AI_MODEL_CONFIG_PARAM["EXTRA_SYMBOLS_PRICING"] = "extra-symbols-pricing";
|
|
9
10
|
})(AI_MODEL_CONFIG_PARAM || (exports.AI_MODEL_CONFIG_PARAM = AI_MODEL_CONFIG_PARAM = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calcBaseTextGenerationPrice = calcBaseTextGenerationPrice;
|
|
4
|
+
function calcBaseTextGenerationPrice({ symbolsInRequest, defaultPrice, config, }) {
|
|
5
|
+
if (!config) {
|
|
6
|
+
return defaultPrice;
|
|
7
|
+
}
|
|
8
|
+
const { stepSize, stepPrice } = config;
|
|
9
|
+
if (symbolsInRequest <= stepSize) {
|
|
10
|
+
return defaultPrice;
|
|
11
|
+
}
|
|
12
|
+
const symbolsBeyondFirstStep = symbolsInRequest - stepSize;
|
|
13
|
+
const additionalSteps = Math.ceil(symbolsBeyondFirstStep / stepSize);
|
|
14
|
+
return defaultPrice + Math.ceil(additionalSteps * stepPrice);
|
|
15
|
+
}
|
|
@@ -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("./calc-base-text-generation-price.helper"), exports);
|
package/build/helpers/index.js
CHANGED
|
@@ -14,6 +14,7 @@ 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("./ai-model"), exports);
|
|
17
18
|
__exportStar(require("./stt"), exports);
|
|
18
19
|
__exportStar(require("./subscription"), exports);
|
|
19
20
|
__exportStar(require("./tts"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AiModelConfigSchema = exports.AiModelWebSearchParameter = exports.AiModelImageStyleParameter = exports.AiModelImageStyleOptionSchema = exports.AiModelImageSizeParameter = exports.AiModelImageSizeOptionSchema = exports.AiModelConfigParameterSchema = void 0;
|
|
3
|
+
exports.AiModelConfigSchema = exports.AiModelExtraSymbolsPricingParameter = exports.AiModelWebSearchParameter = exports.AiModelImageStyleParameter = exports.AiModelImageStyleOptionSchema = exports.AiModelImageSizeParameter = exports.AiModelImageSizeOptionSchema = exports.AiModelConfigParameterSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
exports.AiModelConfigParameterSchema = zod_1.z.object({
|
|
@@ -32,6 +32,12 @@ exports.AiModelImageStyleParameter = zod_1.z.object({
|
|
|
32
32
|
exports.AiModelWebSearchParameter = zod_1.z.object({
|
|
33
33
|
webSearchPrice: zod_1.z.number(),
|
|
34
34
|
});
|
|
35
|
+
// EXTRA SYMBOLS PRICING
|
|
36
|
+
exports.AiModelExtraSymbolsPricingParameter = zod_1.z.object({
|
|
37
|
+
stepSize: zod_1.z.number(),
|
|
38
|
+
stepPrice: zod_1.z.number(),
|
|
39
|
+
isActive: zod_1.z.boolean(),
|
|
40
|
+
});
|
|
35
41
|
// CONFIG
|
|
36
42
|
exports.AiModelConfigSchema = zod_1.z.object({
|
|
37
43
|
parameters: zod_1.z
|
|
@@ -39,6 +45,7 @@ exports.AiModelConfigSchema = zod_1.z.object({
|
|
|
39
45
|
[constants_1.AI_MODEL_CONFIG_PARAM.IMAGE_SIZE]: exports.AiModelImageSizeParameter.optional(),
|
|
40
46
|
[constants_1.AI_MODEL_CONFIG_PARAM.IMAGE_STYLE]: exports.AiModelImageStyleParameter.optional(),
|
|
41
47
|
[constants_1.AI_MODEL_CONFIG_PARAM.WEB_SEARCH]: exports.AiModelWebSearchParameter.optional(),
|
|
48
|
+
[constants_1.AI_MODEL_CONFIG_PARAM.EXTRA_SYMBOLS_PRICING]: exports.AiModelExtraSymbolsPricingParameter.optional(),
|
|
42
49
|
})
|
|
43
50
|
.strict(),
|
|
44
51
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PromptSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindAllPromptsCommand {
|
|
5
|
+
export type Request = void;
|
|
6
|
+
|
|
7
|
+
export const ResponseSchema = z.object({
|
|
8
|
+
data: z.array(PromptSchema),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PromptSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindPromptByUuidCommand {
|
|
5
|
+
export const RequestSchema = PromptSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: PromptSchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { PromptSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindPromptsByTopicCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
topicId: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: z.array(PromptSchema),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
package/commands/prompt/index.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export * from './create-prompt.command';
|
|
2
2
|
export * from './delete-prompt.command';
|
|
3
3
|
export * from './update-prompt.command';
|
|
4
|
+
export * from './find-prompt-by-uuid.command';
|
|
5
|
+
export * from './find-all-prompts.command';
|
|
6
|
+
export * from './find-prompts-by-topic.command';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PromptCategorySchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindPromptCategoryByUuidCommand {
|
|
5
|
+
export const RequestSchema = PromptCategorySchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: PromptCategorySchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PromptTopicSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindAllPromptTopicsCommand {
|
|
5
|
+
export type Request = void;
|
|
6
|
+
|
|
7
|
+
export const ResponseSchema = z.object({
|
|
8
|
+
data: z.array(PromptTopicSchema),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PromptTopicSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace FindPromptTopicByUuidCommand {
|
|
5
|
+
export const RequestSchema = PromptTopicSchema.pick({
|
|
6
|
+
uuid: true,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
data: PromptTopicSchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
|
+
}
|
|
@@ -2,3 +2,5 @@ export * from './create-prompt-topic.command';
|
|
|
2
2
|
export * from './delete-prompt-topic.command';
|
|
3
3
|
export * from './update-prompt-topic.command';
|
|
4
4
|
export * from './find-prompt-topic-by-category.command';
|
|
5
|
+
export * from './find-prompt-topic-by-uuid.command';
|
|
6
|
+
export * from './find-all-prompt-topics.command';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function calcBaseTextGenerationPrice({
|
|
2
|
+
symbolsInRequest,
|
|
3
|
+
defaultPrice,
|
|
4
|
+
config,
|
|
5
|
+
}: {
|
|
6
|
+
symbolsInRequest: number;
|
|
7
|
+
defaultPrice: number;
|
|
8
|
+
config: { stepSize: number; stepPrice: number } | null;
|
|
9
|
+
}) {
|
|
10
|
+
if (!config) {
|
|
11
|
+
return defaultPrice;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { stepSize, stepPrice } = config;
|
|
15
|
+
|
|
16
|
+
if (symbolsInRequest <= stepSize) {
|
|
17
|
+
return defaultPrice;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const symbolsBeyondFirstStep = symbolsInRequest - stepSize;
|
|
21
|
+
const additionalSteps = Math.ceil(symbolsBeyondFirstStep / stepSize);
|
|
22
|
+
|
|
23
|
+
return defaultPrice + Math.ceil(additionalSteps * stepPrice);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './calc-base-text-generation-price.helper';
|
package/helpers/index.ts
CHANGED
|
@@ -39,6 +39,13 @@ export const AiModelWebSearchParameter = z.object({
|
|
|
39
39
|
webSearchPrice: z.number(),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
// EXTRA SYMBOLS PRICING
|
|
43
|
+
export const AiModelExtraSymbolsPricingParameter = z.object({
|
|
44
|
+
stepSize: z.number(),
|
|
45
|
+
stepPrice: z.number(),
|
|
46
|
+
isActive: z.boolean(),
|
|
47
|
+
});
|
|
48
|
+
|
|
42
49
|
// CONFIG
|
|
43
50
|
|
|
44
51
|
export const AiModelConfigSchema = z.object({
|
|
@@ -47,6 +54,8 @@ export const AiModelConfigSchema = z.object({
|
|
|
47
54
|
[AI_MODEL_CONFIG_PARAM.IMAGE_SIZE]: AiModelImageSizeParameter.optional(),
|
|
48
55
|
[AI_MODEL_CONFIG_PARAM.IMAGE_STYLE]: AiModelImageStyleParameter.optional(),
|
|
49
56
|
[AI_MODEL_CONFIG_PARAM.WEB_SEARCH]: AiModelWebSearchParameter.optional(),
|
|
57
|
+
[AI_MODEL_CONFIG_PARAM.EXTRA_SYMBOLS_PRICING]:
|
|
58
|
+
AiModelExtraSymbolsPricingParameter.optional(),
|
|
50
59
|
})
|
|
51
60
|
.strict(),
|
|
52
61
|
});
|
|
@@ -57,4 +66,7 @@ export type AiModelImageSizeParameter = z.infer<typeof AiModelImageSizeParameter
|
|
|
57
66
|
export type AiModelImageStyleOption = z.infer<typeof AiModelImageStyleOptionSchema>;
|
|
58
67
|
export type AiModelImageStyleParameter = z.infer<typeof AiModelImageStyleParameter>;
|
|
59
68
|
export type AiModelWebSeachParameter = z.infer<typeof AiModelWebSearchParameter>;
|
|
69
|
+
export type AiModelExtraSymbolsPricingParameter = z.infer<
|
|
70
|
+
typeof AiModelExtraSymbolsPricingParameter
|
|
71
|
+
>;
|
|
60
72
|
export type AiModelConfig = z.infer<typeof AiModelConfigSchema>;
|