@purpleschool/gptbot 0.7.34 → 0.7.35-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.
- package/api/controllers/http/index.ts +1 -0
- package/api/controllers/http/writer.ts +20 -0
- package/build/api/controllers/http/index.js +1 -0
- package/build/api/controllers/http/writer.js +22 -0
- package/build/commands/tools/index.js +1 -0
- package/build/commands/tools/writer/create-writer-document.command.js +16 -0
- package/build/commands/tools/writer/delete-all-writer-documents.command.js +8 -0
- package/build/commands/tools/writer/delete-writer-document-by-uuid.command.js +11 -0
- package/build/commands/tools/writer/export-writer-document-as-docx.command.js +15 -0
- package/build/commands/tools/writer/find-writer-document-by-uuid.command.js +14 -0
- package/build/commands/tools/writer/find-writer-documents.command.js +18 -0
- package/build/commands/tools/writer/generate-writer-document-contents.command.js +14 -0
- package/build/commands/tools/writer/get-writer-tool-config.command.js +11 -0
- package/build/commands/tools/writer/index.js +31 -0
- package/build/commands/tools/writer/update-writer-document-contents.command.js +18 -0
- package/build/commands/tools/writer/update-writer-document-outline.command.js +17 -0
- package/build/commands/tools/writer/writer-extend-text.command.js +18 -0
- package/build/commands/tools/writer/writer-fix-errors.command.js +18 -0
- package/build/commands/tools/writer/writer-generate-text.command.js +21 -0
- package/build/commands/tools/writer/writer-paraphrase.command.js +18 -0
- package/build/commands/tools/writer/writer-shorten-text.command.js +18 -0
- package/build/constants/errors/errors.js +89 -14
- package/build/constants/index.js +1 -0
- package/build/constants/writer/enums/index.js +20 -0
- package/build/constants/writer/enums/writer-ai-action-pricing-type.enum.js +8 -0
- package/build/constants/writer/enums/writer-ai-action-type.enum.js +11 -0
- package/build/constants/writer/enums/writer-document-section-type.enum.js +9 -0
- package/build/constants/writer/enums/writer-document-stage.enum.js +14 -0
- package/build/constants/writer/index.js +17 -0
- package/build/helpers/index.js +1 -0
- package/build/helpers/writer/calculate-writer-ai-action-price.util.js +16 -0
- package/build/helpers/writer/calculate-writer-content-generation-price.util.js +6 -0
- package/build/helpers/writer/index.js +18 -0
- package/build/models/tools/image-editor/image-editor-config.schema.js +2 -10
- package/build/models/tools/image-editor/image-editor-job.schema.js +1 -2
- package/build/models/tools/index.js +1 -0
- package/build/models/tools/writer/index.js +21 -0
- package/build/models/tools/writer/writer-ai-action.schema.js +26 -0
- package/build/models/tools/writer/writer-config.schema.js +13 -0
- package/build/models/tools/writer/writer-document-outline.schema.js +21 -0
- package/build/models/tools/writer/writer-document-type.schema.js +13 -0
- package/build/models/tools/writer/writer-document.schema.js +22 -0
- package/commands/tools/index.ts +1 -0
- package/commands/tools/writer/create-writer-document.command.ts +16 -0
- package/commands/tools/writer/delete-all-writer-documents.command.ts +6 -0
- package/commands/tools/writer/delete-writer-document-by-uuid.command.ts +11 -0
- package/commands/tools/writer/export-writer-document-as-docx.command.ts +15 -0
- package/commands/tools/writer/find-writer-document-by-uuid.command.ts +14 -0
- package/commands/tools/writer/find-writer-documents.command.ts +18 -0
- package/commands/tools/writer/generate-writer-document-contents.command.ts +14 -0
- package/commands/tools/writer/get-writer-tool-config.command.ts +10 -0
- package/commands/tools/writer/index.ts +15 -0
- package/commands/tools/writer/update-writer-document-contents.command.ts +20 -0
- package/commands/tools/writer/update-writer-document-outline.command.ts +19 -0
- package/commands/tools/writer/writer-extend-text.command.ts +20 -0
- package/commands/tools/writer/writer-fix-errors.command.ts +20 -0
- package/commands/tools/writer/writer-generate-text.command.ts +23 -0
- package/commands/tools/writer/writer-paraphrase.command.ts +20 -0
- package/commands/tools/writer/writer-shorten-text.command.ts +20 -0
- package/constants/errors/errors.ts +89 -14
- package/constants/index.ts +1 -0
- package/constants/writer/enums/index.ts +4 -0
- package/constants/writer/enums/writer-ai-action-pricing-type.enum.ts +4 -0
- package/constants/writer/enums/writer-ai-action-type.enum.ts +7 -0
- package/constants/writer/enums/writer-document-section-type.enum.ts +5 -0
- package/constants/writer/enums/writer-document-stage.enum.ts +13 -0
- package/constants/writer/index.ts +1 -0
- package/helpers/index.ts +1 -0
- package/helpers/writer/calculate-writer-ai-action-price.util.ts +20 -0
- package/helpers/writer/calculate-writer-content-generation-price.util.ts +3 -0
- package/helpers/writer/index.ts +2 -0
- package/models/tools/image-editor/image-editor-config.schema.ts +1 -12
- package/models/tools/image-editor/image-editor-job.schema.ts +1 -2
- package/models/tools/index.ts +1 -0
- package/models/tools/writer/index.ts +5 -0
- package/models/tools/writer/writer-ai-action.schema.ts +27 -0
- package/models/tools/writer/writer-config.schema.ts +12 -0
- package/models/tools/writer/writer-document-outline.schema.ts +28 -0
- package/models/tools/writer/writer-document-type.schema.ts +12 -0
- package/models/tools/writer/writer-document.schema.ts +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export enum WRITER_DOCUMENT_STAGE {
|
|
2
|
+
CREATED = 'CREATED',
|
|
3
|
+
|
|
4
|
+
GENERATING_OUTLINE = 'GENERATING_OUTLINE',
|
|
5
|
+
OUTLINE_GENERATED = 'OUTLINE_GENERATED',
|
|
6
|
+
OUTLINE_GENERATION_FAILED = 'OUTLINE_GENERATION_FAILED',
|
|
7
|
+
|
|
8
|
+
GENERATING_CONTENT = 'GENERATING_CONTENT',
|
|
9
|
+
CONTENT_GENERATED = 'CONTENT_GENERATED',
|
|
10
|
+
CONTENT_GENERATION_FAILED = 'CONTENT_GENERATION_FAILED',
|
|
11
|
+
|
|
12
|
+
DELETED = 'DELETED',
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './enums';
|
package/helpers/index.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -2,15 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ImageEditorModelSchema } from './image-editor-model.schema';
|
|
3
3
|
import { IconVariantsSchema } from '../../icon-variants.schema';
|
|
4
4
|
|
|
5
|
-
export const SystemPromptParamsSchema = z.object({
|
|
6
|
-
imageSettings: z.object({
|
|
7
|
-
minImages: z.number(),
|
|
8
|
-
maxImages: z.number(),
|
|
9
|
-
}),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export type SystemPromptParams = z.infer<typeof SystemPromptParamsSchema>;
|
|
13
|
-
|
|
14
5
|
export const SystemPromptSchema = z.object({
|
|
15
6
|
uuid: z.string(),
|
|
16
7
|
title: z.string(),
|
|
@@ -18,7 +9,6 @@ export const SystemPromptSchema = z.object({
|
|
|
18
9
|
prompt: z.string(),
|
|
19
10
|
allowUserPrompt: z.boolean(),
|
|
20
11
|
groupId: z.string().uuid(),
|
|
21
|
-
params: SystemPromptParamsSchema,
|
|
22
12
|
preview: z
|
|
23
13
|
.object({
|
|
24
14
|
before: z.string(),
|
|
@@ -26,7 +16,6 @@ export const SystemPromptSchema = z.object({
|
|
|
26
16
|
})
|
|
27
17
|
.optional()
|
|
28
18
|
.nullable(),
|
|
29
|
-
order: z.number(),
|
|
30
19
|
});
|
|
31
20
|
|
|
32
21
|
export const PromptGroupSchema = z.object({
|
|
@@ -39,5 +28,5 @@ export const PromptGroupSchema = z.object({
|
|
|
39
28
|
|
|
40
29
|
export const ImageEditorConfigSchema = z.object({
|
|
41
30
|
models: z.array(ImageEditorModelSchema),
|
|
42
|
-
promptGroups: z.array(
|
|
31
|
+
promptGroups: z.array(SystemPromptSchema),
|
|
43
32
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { USER_REACTION } from '../../../constants';
|
|
3
|
-
import { ToolJobSchema } from '../../tool-job.schema';
|
|
4
3
|
|
|
5
4
|
export const ImageEditorJobParamsSchema = z.object({
|
|
6
5
|
imageUrls: z.array(z.string()).optional(),
|
|
@@ -9,7 +8,7 @@ export const ImageEditorJobParamsSchema = z.object({
|
|
|
9
8
|
|
|
10
9
|
export type ImageEditorJobParams = z.infer<typeof ImageEditorJobParamsSchema>;
|
|
11
10
|
|
|
12
|
-
export const ImageEditorJobSchema =
|
|
11
|
+
export const ImageEditorJobSchema = z.object({
|
|
13
12
|
title: z.string(),
|
|
14
13
|
prompt: z.string(),
|
|
15
14
|
reaction: z.nativeEnum(USER_REACTION).nullable(),
|
package/models/tools/index.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WRITER_AI_ACTION_PRICING_TYPE, WRITER_AI_ACTION_TYPE } from '../../../constants';
|
|
3
|
+
|
|
4
|
+
export const WriterAiActionPricingRulesSchema = z.discriminatedUnion('type', [
|
|
5
|
+
z.object({
|
|
6
|
+
type: z.literal(WRITER_AI_ACTION_PRICING_TYPE.PER_CHARACTER),
|
|
7
|
+
price: z.number(),
|
|
8
|
+
}),
|
|
9
|
+
z.object({
|
|
10
|
+
type: z.literal(WRITER_AI_ACTION_PRICING_TYPE.FLAT),
|
|
11
|
+
price: z.number(),
|
|
12
|
+
}),
|
|
13
|
+
]);
|
|
14
|
+
export type WriterAiActionPricingRules = z.infer<typeof WriterAiActionPricingRulesSchema>;
|
|
15
|
+
|
|
16
|
+
export const WriterAiActionSchema = z.object({
|
|
17
|
+
uuid: z.string(),
|
|
18
|
+
type: z.nativeEnum(WRITER_AI_ACTION_TYPE),
|
|
19
|
+
pricingRules: WriterAiActionPricingRulesSchema,
|
|
20
|
+
maxPromptLength: z.number(),
|
|
21
|
+
title: z.string(),
|
|
22
|
+
icon: z.string(),
|
|
23
|
+
order: z.number(),
|
|
24
|
+
createdAt: z.date(),
|
|
25
|
+
updatedAt: z.date(),
|
|
26
|
+
});
|
|
27
|
+
export type WriterAiAction = z.infer<typeof WriterAiActionSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WriterDocumentTypeSchema } from './writer-document-type.schema';
|
|
3
|
+
import { WriterAiActionSchema } from './writer-ai-action.schema';
|
|
4
|
+
|
|
5
|
+
export const WriterConfigSchema = z.object({
|
|
6
|
+
minPages: z.number(),
|
|
7
|
+
maxPages: z.number(),
|
|
8
|
+
maxPromptLength: z.number(),
|
|
9
|
+
documentTypes: z.array(WriterDocumentTypeSchema),
|
|
10
|
+
aiActions: z.array(WriterAiActionSchema),
|
|
11
|
+
});
|
|
12
|
+
export type WriterConfig = z.infer<typeof WriterConfigSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WRITER_DOCUMENT_SECTION_TYPE } from '../../../constants';
|
|
3
|
+
|
|
4
|
+
export const WriterDocumentOutlineSubsectionSchema = z.object({
|
|
5
|
+
title: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(3)
|
|
8
|
+
.max(120)
|
|
9
|
+
.describe(
|
|
10
|
+
`Concise title of the subsection. Meant to elaborate on its parent section's title.`,
|
|
11
|
+
),
|
|
12
|
+
});
|
|
13
|
+
export type WriterDocumentOutlineSubsection = z.infer<typeof WriterDocumentOutlineSubsectionSchema>;
|
|
14
|
+
|
|
15
|
+
export const WriterDocumentOutlineSectionSchema = z.object({
|
|
16
|
+
title: z.string().min(3).max(120).describe(`Concise title of the paper section.`),
|
|
17
|
+
type: z.nativeEnum(WRITER_DOCUMENT_SECTION_TYPE),
|
|
18
|
+
subsections: z
|
|
19
|
+
.array(WriterDocumentOutlineSubsectionSchema)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe(
|
|
22
|
+
`Subsections of the paper section. Each subsection is a single idea that is a part of the parent section.`,
|
|
23
|
+
),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const WriterDocumentOutlineSchema = z.array(WriterDocumentOutlineSectionSchema);
|
|
27
|
+
|
|
28
|
+
export type WriterDocumentOutline = z.infer<typeof WriterDocumentOutlineSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const WriterDocumentTypeSchema = z.object({
|
|
4
|
+
uuid: z.string().uuid(),
|
|
5
|
+
title: z.string(),
|
|
6
|
+
icon: z.string(),
|
|
7
|
+
order: z.number(),
|
|
8
|
+
promptInstructions: z.string().nullable(),
|
|
9
|
+
createdAt: z.date(),
|
|
10
|
+
updatedAt: z.date(),
|
|
11
|
+
});
|
|
12
|
+
export type WriterDocumentType = z.infer<typeof WriterDocumentTypeSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WriterDocumentOutlineSchema } from './writer-document-outline.schema';
|
|
3
|
+
import { WRITER_DOCUMENT_STAGE } from '../../../constants';
|
|
4
|
+
|
|
5
|
+
export const WriterDocumentSchema = z.object({
|
|
6
|
+
uuid: z.string().uuid(),
|
|
7
|
+
prompt: z.string(),
|
|
8
|
+
topic: z.string(),
|
|
9
|
+
typeId: z.string(),
|
|
10
|
+
stage: z.nativeEnum(WRITER_DOCUMENT_STAGE),
|
|
11
|
+
outline: WriterDocumentOutlineSchema,
|
|
12
|
+
sourceMd: z.string().nullable(),
|
|
13
|
+
finalMd: z.string().nullable(),
|
|
14
|
+
userId: z.string().nullable(),
|
|
15
|
+
unregisteredUserId: z.string().nullable(),
|
|
16
|
+
pages: z.number(),
|
|
17
|
+
createdAt: z.date(),
|
|
18
|
+
updatedAt: z.date(),
|
|
19
|
+
completedAt: z.date().nullable(),
|
|
20
|
+
});
|
|
21
|
+
export type WriterDocument = z.infer<typeof WriterDocumentSchema>;
|