@purpleschool/gptbot 0.12.56 → 0.12.57
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.
|
@@ -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:
|
|
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,
|
|
@@ -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:
|
|
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,
|