@purpleschool/gptbot 0.7.33 → 0.7.34-texteditor

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.
@@ -15,4 +15,5 @@ export const WRITER_ROUTES = {
15
15
  EXTEND_TEXT: (uuid: string) => `documents/${uuid}/actions/extend-text`,
16
16
  SHORTEN_TEXT: (uuid: string) => `documents/${uuid}/actions/shorten-text`,
17
17
  FIX_ERRORS: (uuid: string) => `documents/${uuid}/actions/fix-errors`,
18
+ GENERATE_TEXT: (uuid: string) => `documents/${uuid}/actions/generate-text`,
18
19
  } as const;
@@ -17,4 +17,5 @@ exports.WRITER_ROUTES = {
17
17
  EXTEND_TEXT: (uuid) => `documents/${uuid}/actions/extend-text`,
18
18
  SHORTEN_TEXT: (uuid) => `documents/${uuid}/actions/shorten-text`,
19
19
  FIX_ERRORS: (uuid) => `documents/${uuid}/actions/fix-errors`,
20
+ GENERATE_TEXT: (uuid) => `documents/${uuid}/actions/generate-text`,
20
21
  };
@@ -6,7 +6,7 @@ const models_1 = require("../../../models");
6
6
  var CreateWriterDocumentCommand;
7
7
  (function (CreateWriterDocumentCommand) {
8
8
  CreateWriterDocumentCommand.RequestSchema = zod_1.z.object({
9
- topic: zod_1.z.string(),
9
+ prompt: zod_1.z.string(),
10
10
  numPages: zod_1.z.number(),
11
11
  documentTypeId: zod_1.z.string(),
12
12
  });
@@ -27,3 +27,4 @@ __exportStar(require("./writer-paraphrase.command"), exports);
27
27
  __exportStar(require("./writer-extend-text.command"), exports);
28
28
  __exportStar(require("./writer-shorten-text.command"), exports);
29
29
  __exportStar(require("./writer-fix-errors.command"), exports);
30
+ __exportStar(require("./writer-generate-text.command"), exports);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WriterGenerateTextCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var WriterGenerateTextCommand;
6
+ (function (WriterGenerateTextCommand) {
7
+ WriterGenerateTextCommand.RequestParamsSchema = zod_1.z.object({
8
+ uuid: zod_1.z.string().uuid(),
9
+ });
10
+ WriterGenerateTextCommand.RequestBodySchema = zod_1.z.object({
11
+ prompt: zod_1.z.string(),
12
+ selectionText: zod_1.z.string(),
13
+ contextBefore: zod_1.z.string().max(2000).optional(),
14
+ contextAfter: zod_1.z.string().max(2000).optional(),
15
+ });
16
+ WriterGenerateTextCommand.ResponseSchema = zod_1.z.object({
17
+ data: zod_1.z.object({
18
+ output: zod_1.z.string(),
19
+ }),
20
+ });
21
+ })(WriterGenerateTextCommand || (exports.WriterGenerateTextCommand = WriterGenerateTextCommand = {}));
@@ -1826,4 +1826,9 @@ exports.ERRORS = {
1826
1826
  message: 'Произошла ошибка при обновлении содержимого документа',
1827
1827
  httpCode: 500,
1828
1828
  },
1829
+ WRITER_GENERATE_TEXT_ERROR: {
1830
+ code: 'A386',
1831
+ message: 'Произошла ошибка при генерации текста',
1832
+ httpCode: 500,
1833
+ },
1829
1834
  };
@@ -19,3 +19,4 @@ __exportStar(require("./stt"), exports);
19
19
  __exportStar(require("./subscription"), exports);
20
20
  __exportStar(require("./tts"), exports);
21
21
  __exportStar(require("./video"), exports);
22
+ __exportStar(require("./writer"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateWriterAiActionPrice = calculateWriterAiActionPrice;
4
+ const constants_1 = require("../../constants");
5
+ function calculateWriterAiActionPrice(pricingRules, selectionText) {
6
+ switch (pricingRules.type) {
7
+ case constants_1.WRITER_AI_ACTION_PRICING_TYPE.PER_CHARACTER:
8
+ const characterCount = selectionText.length;
9
+ const price = characterCount * pricingRules.price;
10
+ return Math.max(1, Math.ceil(price));
11
+ case constants_1.WRITER_AI_ACTION_PRICING_TYPE.FLAT:
12
+ return Math.max(1, Math.ceil(pricingRules.price));
13
+ default:
14
+ throw new Error(`Unknown pricing type`);
15
+ }
16
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateWriterContentGenerationPrice = calculateWriterContentGenerationPrice;
4
+ function calculateWriterContentGenerationPrice(pages) {
5
+ return Math.max(1, pages);
6
+ }
@@ -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("./calculate-writer-ai-action-price.util"), exports);
18
+ __exportStar(require("./calculate-writer-content-generation-price.util"), exports);
@@ -7,7 +7,7 @@ const writer_ai_action_schema_1 = require("./writer-ai-action.schema");
7
7
  exports.WriterConfigSchema = zod_1.z.object({
8
8
  minPages: zod_1.z.number(),
9
9
  maxPages: zod_1.z.number(),
10
- maxTopicLength: zod_1.z.number(),
10
+ maxPromptLength: zod_1.z.number(),
11
11
  documentTypes: zod_1.z.array(writer_document_type_schema_1.WriterDocumentTypeSchema),
12
12
  aiActions: zod_1.z.array(writer_ai_action_schema_1.WriterAiActionSchema),
13
13
  });
@@ -3,7 +3,7 @@ import { WriterDocumentSchema } from '../../../models';
3
3
 
4
4
  export namespace CreateWriterDocumentCommand {
5
5
  export const RequestSchema = z.object({
6
- topic: z.string(),
6
+ prompt: z.string(),
7
7
  numPages: z.number(),
8
8
  documentTypeId: z.string(),
9
9
  });
@@ -11,3 +11,4 @@ export * from './writer-paraphrase.command';
11
11
  export * from './writer-extend-text.command';
12
12
  export * from './writer-shorten-text.command';
13
13
  export * from './writer-fix-errors.command';
14
+ export * from './writer-generate-text.command';
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace WriterGenerateTextCommand {
4
+ export const RequestParamsSchema = z.object({
5
+ uuid: z.string().uuid(),
6
+ });
7
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
8
+
9
+ export const RequestBodySchema = z.object({
10
+ prompt: z.string(),
11
+ selectionText: z.string(),
12
+ contextBefore: z.string().max(2000).optional(),
13
+ contextAfter: z.string().max(2000).optional(),
14
+ });
15
+ export type RequestBody = z.infer<typeof RequestBodySchema>;
16
+
17
+ export const ResponseSchema = z.object({
18
+ data: z.object({
19
+ output: z.string(),
20
+ }),
21
+ });
22
+ export type Response = z.infer<typeof ResponseSchema>;
23
+ }
@@ -1834,4 +1834,9 @@ export const ERRORS = {
1834
1834
  message: 'Произошла ошибка при обновлении содержимого документа',
1835
1835
  httpCode: 500,
1836
1836
  },
1837
+ WRITER_GENERATE_TEXT_ERROR: {
1838
+ code: 'A386',
1839
+ message: 'Произошла ошибка при генерации текста',
1840
+ httpCode: 500,
1841
+ },
1837
1842
  };
package/helpers/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from './stt';
3
3
  export * from './subscription';
4
4
  export * from './tts';
5
5
  export * from './video';
6
+ export * from './writer';
@@ -0,0 +1,20 @@
1
+ import { WRITER_AI_ACTION_PRICING_TYPE } from '../../constants';
2
+ import { WriterAiActionPricingRules } from '../../models';
3
+
4
+ export function calculateWriterAiActionPrice(
5
+ pricingRules: WriterAiActionPricingRules,
6
+ selectionText: string,
7
+ ): number {
8
+ switch (pricingRules.type) {
9
+ case WRITER_AI_ACTION_PRICING_TYPE.PER_CHARACTER:
10
+ const characterCount = selectionText.length;
11
+ const price = characterCount * pricingRules.price;
12
+ return Math.max(1, Math.ceil(price));
13
+
14
+ case WRITER_AI_ACTION_PRICING_TYPE.FLAT:
15
+ return Math.max(1, Math.ceil(pricingRules.price));
16
+
17
+ default:
18
+ throw new Error(`Unknown pricing type`);
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ export function calculateWriterContentGenerationPrice(pages: number): number {
2
+ return Math.max(1, pages);
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './calculate-writer-ai-action-price.util';
2
+ export * from './calculate-writer-content-generation-price.util';
@@ -5,9 +5,8 @@ import { WriterAiActionSchema } from './writer-ai-action.schema';
5
5
  export const WriterConfigSchema = z.object({
6
6
  minPages: z.number(),
7
7
  maxPages: z.number(),
8
- maxTopicLength: z.number(),
8
+ maxPromptLength: z.number(),
9
9
  documentTypes: z.array(WriterDocumentTypeSchema),
10
10
  aiActions: z.array(WriterAiActionSchema),
11
11
  });
12
-
13
12
  export type WriterConfig = z.infer<typeof WriterConfigSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.7.33",
3
+ "version": "0.7.34-texteditor+01",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",