@purpleschool/gptbot 0.12.56 → 0.12.58

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,12 +6,14 @@ var GetHtmlPageBuilderPriceCommand;
6
6
  (function (GetHtmlPageBuilderPriceCommand) {
7
7
  GetHtmlPageBuilderPriceCommand.RequestSchema = zod_1.z.object({
8
8
  modelId: zod_1.z.string().uuid(),
9
- userPrompt: zod_1.z.string(),
9
+ inputLength: zod_1.z.number().int().nonnegative(),
10
10
  sessionId: zod_1.z.string().uuid().nullable().optional(),
11
11
  });
12
12
  GetHtmlPageBuilderPriceCommand.ResponseSchema = zod_1.z.object({
13
13
  data: zod_1.z.object({
14
14
  price: zod_1.z.number(),
15
+ charsUntilNextPriceIncrease: zod_1.z.number().int().nonnegative().nullable(),
16
+ charsUntilNextPriceDecrease: zod_1.z.number().int().nonnegative().nullable(),
15
17
  }),
16
18
  });
17
19
  })(GetHtmlPageBuilderPriceCommand || (exports.GetHtmlPageBuilderPriceCommand = GetHtmlPageBuilderPriceCommand = {}));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_TARGET_MARGIN = exports.DEFAULT_STAR_PRICE_USD = exports.GPT_IMAGE_2_DEFAULT_OUTPUT_PRICE_PER_1M_USD = void 0;
3
+ exports.GPT_IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS = exports.DEFAULT_TARGET_MARGIN = exports.DEFAULT_STAR_PRICE_USD = exports.GPT_IMAGE_2_DEFAULT_OUTPUT_PRICE_PER_1M_USD = void 0;
4
4
  exports.getGptImage2OutputTokensByTier = getGptImage2OutputTokensByTier;
5
5
  exports.estimateGptImage2OutputCostUsdFromTokens = estimateGptImage2OutputCostUsdFromTokens;
6
6
  exports.applyTargetMargin = applyTargetMargin;
@@ -10,6 +10,7 @@ exports.calculateGptImage2PriceInStarsByTier = calculateGptImage2PriceInStarsByT
10
10
  exports.GPT_IMAGE_2_DEFAULT_OUTPUT_PRICE_PER_1M_USD = 30;
11
11
  exports.DEFAULT_STAR_PRICE_USD = 0.018;
12
12
  exports.DEFAULT_TARGET_MARGIN = 0.6;
13
+ exports.GPT_IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS = 2;
13
14
  const GPT_IMAGE_2_OUTPUT_TOKENS_BY_QUALITY_RATIO_AND_TIER = {
14
15
  low: {
15
16
  '1:1': { '1K': 196, '2K': 397, '4K': 659 },
@@ -61,11 +62,13 @@ function calculateGptImage2PriceInStarsFromTokens(params) {
61
62
  cost: costUsd,
62
63
  targetMargin: params.targetMargin,
63
64
  });
65
+ const sellStars = convertUsdToStarsCeil({ usd: sellUsd, starPriceUsd: params.starPriceUsd });
66
+ const finalSellStars = sellStars + (params.hasAttachedImage ? exports.GPT_IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS : 0);
64
67
  return {
65
68
  costUsd,
66
69
  sellUsd,
67
70
  costStars: convertUsdToStarsCeil({ usd: costUsd, starPriceUsd: params.starPriceUsd }),
68
- sellStars: convertUsdToStarsCeil({ usd: sellUsd, starPriceUsd: params.starPriceUsd }),
71
+ sellStars: finalSellStars,
69
72
  };
70
73
  }
71
74
  function calculateGptImage2PriceInStarsByTier(params) {
@@ -76,6 +79,7 @@ function calculateGptImage2PriceInStarsByTier(params) {
76
79
  });
77
80
  const priced = calculateGptImage2PriceInStarsFromTokens({
78
81
  outputTokens,
82
+ hasAttachedImage: params.hasAttachedImage,
79
83
  outputPricePer1MUsd: params.outputPricePer1MUsd,
80
84
  targetMargin: params.targetMargin,
81
85
  starPriceUsd: params.starPriceUsd,
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  export namespace GetHtmlPageBuilderPriceCommand {
4
4
  export const RequestSchema = z.object({
5
5
  modelId: z.string().uuid(),
6
- userPrompt: z.string(),
6
+ inputLength: z.number().int().nonnegative(),
7
7
  sessionId: z.string().uuid().nullable().optional(),
8
8
  });
9
9
  export type Request = z.infer<typeof RequestSchema>;
@@ -11,6 +11,8 @@ export namespace GetHtmlPageBuilderPriceCommand {
11
11
  export const ResponseSchema = z.object({
12
12
  data: z.object({
13
13
  price: z.number(),
14
+ charsUntilNextPriceIncrease: z.number().int().nonnegative().nullable(),
15
+ charsUntilNextPriceDecrease: z.number().int().nonnegative().nullable(),
14
16
  }),
15
17
  });
16
18
  export type Response = z.infer<typeof ResponseSchema>;
@@ -5,6 +5,7 @@ export type GptImage2ResolutionTier = '1K' | '2K' | '4K';
5
5
  export const GPT_IMAGE_2_DEFAULT_OUTPUT_PRICE_PER_1M_USD = 30;
6
6
  export const DEFAULT_STAR_PRICE_USD = 0.018;
7
7
  export const DEFAULT_TARGET_MARGIN = 0.6;
8
+ export const GPT_IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS = 2;
8
9
 
9
10
  const GPT_IMAGE_2_OUTPUT_TOKENS_BY_QUALITY_RATIO_AND_TIER: Record<
10
11
  GptImage2Quality,
@@ -77,6 +78,7 @@ export function convertUsdToStarsCeil(params: {
77
78
 
78
79
  export function calculateGptImage2PriceInStarsFromTokens(params: {
79
80
  outputTokens: number;
81
+ hasAttachedImage?: boolean;
80
82
  outputPricePer1MUsd?: number;
81
83
  targetMargin?: number;
82
84
  starPriceUsd?: number;
@@ -95,11 +97,15 @@ export function calculateGptImage2PriceInStarsFromTokens(params: {
95
97
  targetMargin: params.targetMargin,
96
98
  });
97
99
 
100
+ const sellStars = convertUsdToStarsCeil({ usd: sellUsd, starPriceUsd: params.starPriceUsd });
101
+ const finalSellStars =
102
+ sellStars + (params.hasAttachedImage ? GPT_IMAGE_2_INPUT_IMAGE_SURCHARGE_STARS : 0);
103
+
98
104
  return {
99
105
  costUsd,
100
106
  sellUsd,
101
107
  costStars: convertUsdToStarsCeil({ usd: costUsd, starPriceUsd: params.starPriceUsd }),
102
- sellStars: convertUsdToStarsCeil({ usd: sellUsd, starPriceUsd: params.starPriceUsd }),
108
+ sellStars: finalSellStars,
103
109
  };
104
110
  }
105
111
 
@@ -107,6 +113,7 @@ export function calculateGptImage2PriceInStarsByTier(params: {
107
113
  quality: GptImage2Quality;
108
114
  aspectRatio: GptImage2AspectRatio;
109
115
  resolutionTier: GptImage2ResolutionTier;
116
+ hasAttachedImage?: boolean;
110
117
  outputPricePer1MUsd?: number;
111
118
  targetMargin?: number;
112
119
  starPriceUsd?: number;
@@ -124,6 +131,7 @@ export function calculateGptImage2PriceInStarsByTier(params: {
124
131
  });
125
132
  const priced = calculateGptImage2PriceInStarsFromTokens({
126
133
  outputTokens,
134
+ hasAttachedImage: params.hasAttachedImage,
127
135
  outputPricePer1MUsd: params.outputPricePer1MUsd,
128
136
  targetMargin: params.targetMargin,
129
137
  starPriceUsd: params.starPriceUsd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.12.56",
3
+ "version": "0.12.58",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",