@purpleschool/gptbot-tools 0.0.57 → 0.0.59
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/common/errors/errors.js +17 -0
- package/build/writer/commands/create-writer-document.command.js +1 -0
- package/build/writer/enums/index.js +1 -0
- package/build/writer/enums/writer-content-generation-strategy.enum.js +8 -0
- package/build/writer/index.js +1 -0
- package/build/writer/models/index.js +1 -0
- package/build/writer/models/writer-config.schema.js +2 -0
- package/build/writer/models/writer-document-type.schema.js +1 -0
- package/build/writer/models/writer-document.schema.js +1 -0
- package/build/writer/models/writer-model.schema.js +21 -0
- package/build/writer/utils/calculate-writer-content-generation-price.util.js +2 -2
- package/common/errors/errors.ts +17 -0
- package/package.json +1 -1
- package/writer/commands/create-writer-document.command.ts +1 -0
- package/writer/enums/index.ts +1 -0
- package/writer/enums/writer-content-generation-strategy.enum.ts +4 -0
- package/writer/index.ts +1 -0
- package/writer/models/index.ts +1 -0
- package/writer/models/writer-config.schema.ts +2 -0
- package/writer/models/writer-document-type.schema.ts +1 -0
- package/writer/models/writer-document.schema.ts +1 -0
- package/writer/models/writer-model.schema.ts +21 -0
- package/writer/utils/calculate-writer-content-generation-price.util.ts +4 -2
|
@@ -670,6 +670,23 @@ exports.ERRORS = {
|
|
|
670
670
|
httpCode: 404,
|
|
671
671
|
},
|
|
672
672
|
},
|
|
673
|
+
WRITER_MODEL: {
|
|
674
|
+
MODEL_NOT_ACTIVE: {
|
|
675
|
+
code: 'WRITER_MODEL.MODEL_NOT_ACTIVE',
|
|
676
|
+
message: 'Модель для генерации текста не активна',
|
|
677
|
+
httpCode: 400,
|
|
678
|
+
},
|
|
679
|
+
FIND_ERROR: {
|
|
680
|
+
code: 'WRITER_MODEL.FIND_ERROR',
|
|
681
|
+
message: 'Произошла ошибка при поиске модели для генерации текста',
|
|
682
|
+
httpCode: 500,
|
|
683
|
+
},
|
|
684
|
+
SAVE_ERROR: {
|
|
685
|
+
code: 'WRITER_MODEL.SAVE_ERROR',
|
|
686
|
+
message: 'Произошла ошибка при сохранении модели для генерации текста',
|
|
687
|
+
httpCode: 500,
|
|
688
|
+
},
|
|
689
|
+
},
|
|
673
690
|
PROMPT_MODERATION: {
|
|
674
691
|
AI_ERROR: {
|
|
675
692
|
code: 'PROMPT_MODERATION.AI_ERROR',
|
|
@@ -12,6 +12,7 @@ var CreateWriterDocumentCommand;
|
|
|
12
12
|
prompt: zod_1.z.string(),
|
|
13
13
|
numPages: zod_1.z.number(),
|
|
14
14
|
documentTypeId: zod_1.z.string().uuid(),
|
|
15
|
+
modelId: zod_1.z.string().uuid(),
|
|
15
16
|
});
|
|
16
17
|
CreateWriterDocumentCommand.ResponseSchema = (0, common_1.ICommandResponseSchema)(models_1.WriterDocumentSchema);
|
|
17
18
|
})(CreateWriterDocumentCommand || (exports.CreateWriterDocumentCommand = CreateWriterDocumentCommand = {}));
|
|
@@ -19,3 +19,4 @@ __exportStar(require("./writer-ai-action-pricing-type.enum"), exports);
|
|
|
19
19
|
__exportStar(require("./writer-ai-action-type.enum"), exports);
|
|
20
20
|
__exportStar(require("./writer-document-section-type.enum"), exports);
|
|
21
21
|
__exportStar(require("./writer-document-stage.enum"), exports);
|
|
22
|
+
__exportStar(require("./writer-content-generation-strategy.enum"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WRITER_CONTENT_GENERATION_STRATEGY = void 0;
|
|
4
|
+
var WRITER_CONTENT_GENERATION_STRATEGY;
|
|
5
|
+
(function (WRITER_CONTENT_GENERATION_STRATEGY) {
|
|
6
|
+
WRITER_CONTENT_GENERATION_STRATEGY["OPENAI"] = "openai";
|
|
7
|
+
WRITER_CONTENT_GENERATION_STRATEGY["PERPLEXITY"] = "perplexity";
|
|
8
|
+
})(WRITER_CONTENT_GENERATION_STRATEGY || (exports.WRITER_CONTENT_GENERATION_STRATEGY = WRITER_CONTENT_GENERATION_STRATEGY = {}));
|
package/build/writer/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("./writer-model.schema"), exports);
|
|
17
18
|
__exportStar(require("./writer-config.schema"), exports);
|
|
18
19
|
__exportStar(require("./writer-ai-action.schema"), exports);
|
|
19
20
|
__exportStar(require("./writer-document-outline.schema"), exports);
|
|
@@ -4,8 +4,10 @@ exports.WriterConfigSchema = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const writer_document_type_schema_1 = require("./writer-document-type.schema");
|
|
6
6
|
const writer_ai_action_schema_1 = require("./writer-ai-action.schema");
|
|
7
|
+
const writer_model_schema_1 = require("./writer-model.schema");
|
|
7
8
|
exports.WriterConfigSchema = zod_1.z.object({
|
|
8
9
|
maxPromptLength: zod_1.z.number(),
|
|
9
10
|
documentTypes: zod_1.z.array(writer_document_type_schema_1.WriterDocumentTypeSchema),
|
|
10
11
|
aiActions: zod_1.z.array(writer_ai_action_schema_1.WriterAiActionSchema),
|
|
12
|
+
models: zod_1.z.array(writer_model_schema_1.WriterModelSchema),
|
|
11
13
|
});
|
|
@@ -12,6 +12,7 @@ exports.WriterDocumentTypeSchema = zod_1.z.object({
|
|
|
12
12
|
maxPages: zod_1.z.number(),
|
|
13
13
|
pageRange: zod_1.z.array(zod_1.z.number()),
|
|
14
14
|
needsTableOfContents: zod_1.z.boolean(),
|
|
15
|
+
needsCitations: zod_1.z.boolean(),
|
|
15
16
|
createdAt: zod_1.z.date(),
|
|
16
17
|
updatedAt: zod_1.z.date(),
|
|
17
18
|
});
|
|
@@ -16,6 +16,7 @@ exports.WriterDocumentSchema = zod_1.z.object({
|
|
|
16
16
|
finalMd: zod_1.z.string().nullable(),
|
|
17
17
|
userId: zod_1.z.string().nullable(),
|
|
18
18
|
unregisteredUserId: zod_1.z.string().nullable(),
|
|
19
|
+
modelId: zod_1.z.string(),
|
|
19
20
|
reaction: zod_1.z.nativeEnum(common_1.USER_REACTION).nullable(),
|
|
20
21
|
pages: zod_1.z.number(),
|
|
21
22
|
isDeleted: zod_1.z.boolean(),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriterModelSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const common_2 = require("../../common");
|
|
7
|
+
const writer_content_generation_strategy_enum_1 = require("../enums/writer-content-generation-strategy.enum");
|
|
8
|
+
exports.WriterModelSchema = zod_1.z.object({
|
|
9
|
+
uuid: zod_1.z.string(),
|
|
10
|
+
title: zod_1.z.string(),
|
|
11
|
+
description: zod_1.z.string(),
|
|
12
|
+
aiModel: zod_1.z.string(),
|
|
13
|
+
pricePerPage: zod_1.z.number(),
|
|
14
|
+
order: zod_1.z.number(),
|
|
15
|
+
status: zod_1.z.nativeEnum(common_1.TOOL_MODEL_STATUS),
|
|
16
|
+
icons: common_2.IconVariantsSchema,
|
|
17
|
+
strategy: zod_1.z.nativeEnum(writer_content_generation_strategy_enum_1.WRITER_CONTENT_GENERATION_STRATEGY),
|
|
18
|
+
maxInputLength: zod_1.z.number(),
|
|
19
|
+
createdAt: zod_1.z.date(),
|
|
20
|
+
updatedAt: zod_1.z.date(),
|
|
21
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateWriterContentGenerationPrice = calculateWriterContentGenerationPrice;
|
|
4
|
-
function calculateWriterContentGenerationPrice(pages) {
|
|
5
|
-
return Math.max(1, pages);
|
|
4
|
+
function calculateWriterContentGenerationPrice(pages, model) {
|
|
5
|
+
return Math.max(1, pages * model.pricePerPage);
|
|
6
6
|
}
|
package/common/errors/errors.ts
CHANGED
|
@@ -671,6 +671,23 @@ export const ERRORS = {
|
|
|
671
671
|
httpCode: 404,
|
|
672
672
|
},
|
|
673
673
|
},
|
|
674
|
+
WRITER_MODEL: {
|
|
675
|
+
MODEL_NOT_ACTIVE: {
|
|
676
|
+
code: 'WRITER_MODEL.MODEL_NOT_ACTIVE',
|
|
677
|
+
message: 'Модель для генерации текста не активна',
|
|
678
|
+
httpCode: 400,
|
|
679
|
+
},
|
|
680
|
+
FIND_ERROR: {
|
|
681
|
+
code: 'WRITER_MODEL.FIND_ERROR',
|
|
682
|
+
message: 'Произошла ошибка при поиске модели для генерации текста',
|
|
683
|
+
httpCode: 500,
|
|
684
|
+
},
|
|
685
|
+
SAVE_ERROR: {
|
|
686
|
+
code: 'WRITER_MODEL.SAVE_ERROR',
|
|
687
|
+
message: 'Произошла ошибка при сохранении модели для генерации текста',
|
|
688
|
+
httpCode: 500,
|
|
689
|
+
},
|
|
690
|
+
},
|
|
674
691
|
PROMPT_MODERATION: {
|
|
675
692
|
AI_ERROR: {
|
|
676
693
|
code: 'PROMPT_MODERATION.AI_ERROR',
|
package/package.json
CHANGED
package/writer/enums/index.ts
CHANGED
package/writer/index.ts
CHANGED
package/writer/models/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { WriterDocumentTypeSchema } from './writer-document-type.schema';
|
|
3
3
|
import { WriterAiActionSchema } from './writer-ai-action.schema';
|
|
4
|
+
import { WriterModelSchema } from './writer-model.schema';
|
|
4
5
|
|
|
5
6
|
export const WriterConfigSchema = z.object({
|
|
6
7
|
maxPromptLength: z.number(),
|
|
7
8
|
documentTypes: z.array(WriterDocumentTypeSchema),
|
|
8
9
|
aiActions: z.array(WriterAiActionSchema),
|
|
10
|
+
models: z.array(WriterModelSchema),
|
|
9
11
|
});
|
|
10
12
|
export type WriterConfig = z.infer<typeof WriterConfigSchema>;
|
|
@@ -14,6 +14,7 @@ export const WriterDocumentSchema = z.object({
|
|
|
14
14
|
finalMd: z.string().nullable(),
|
|
15
15
|
userId: z.string().nullable(),
|
|
16
16
|
unregisteredUserId: z.string().nullable(),
|
|
17
|
+
modelId: z.string(),
|
|
17
18
|
reaction: z.nativeEnum(USER_REACTION).nullable(),
|
|
18
19
|
pages: z.number(),
|
|
19
20
|
isDeleted: z.boolean(),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TOOL_MODEL_STATUS } from '../../common';
|
|
3
|
+
import { IconVariantsSchema } from '../../common';
|
|
4
|
+
import { WRITER_CONTENT_GENERATION_STRATEGY } from '../enums/writer-content-generation-strategy.enum';
|
|
5
|
+
|
|
6
|
+
export const WriterModelSchema = z.object({
|
|
7
|
+
uuid: z.string(),
|
|
8
|
+
title: z.string(),
|
|
9
|
+
description: z.string(),
|
|
10
|
+
aiModel: z.string(),
|
|
11
|
+
pricePerPage: z.number(),
|
|
12
|
+
order: z.number(),
|
|
13
|
+
status: z.nativeEnum(TOOL_MODEL_STATUS),
|
|
14
|
+
icons: IconVariantsSchema,
|
|
15
|
+
strategy: z.nativeEnum(WRITER_CONTENT_GENERATION_STRATEGY),
|
|
16
|
+
maxInputLength: z.number(),
|
|
17
|
+
createdAt: z.date(),
|
|
18
|
+
updatedAt: z.date(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type WriterModel = z.infer<typeof WriterModelSchema>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { WriterModel } from '../models';
|
|
2
|
+
|
|
3
|
+
export function calculateWriterContentGenerationPrice(pages: number, model: WriterModel): number {
|
|
4
|
+
return Math.max(1, pages * model.pricePerPage);
|
|
3
5
|
}
|