@purpleschool/gptbot 0.5.99 → 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.
@@ -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);
@@ -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
  });
@@ -2,4 +2,5 @@ export enum AI_MODEL_CONFIG_PARAM {
2
2
  IMAGE_SIZE = 'image-size',
3
3
  IMAGE_STYLE = 'image-style',
4
4
  WEB_SEARCH = 'web-search',
5
+ EXTRA_SYMBOLS_PRICING = 'extra-symbols-pricing',
5
6
  }
@@ -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
@@ -1,3 +1,4 @@
1
+ export * from './ai-model';
1
2
  export * from './stt';
2
3
  export * from './subscription';
3
4
  export * from './tts';
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.99",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",