Fix estimates
This commit is contained in:
parent
1421cc431b
commit
19825a1206
2 changed files with 16 additions and 3 deletions
|
|
@ -49,7 +49,7 @@ _ACTOR_MAP_CACHE_LOCK = threading.Lock()
|
|||
_VAR_ACTOR_RE = re.compile(r"\\n\[(\d+)\]", re.IGNORECASE)
|
||||
|
||||
# Regex - Need to change this if you want to translate from/to other languages. Default is Japanese Regex
|
||||
LANGREGEX = r"[\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF61-\uFF9F]+"
|
||||
LANGREGEX = r"[\u3000\u3002-\u3009\u300C-\u303F\u3040-\u309A\u309C-\u30FF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF61-\uFF9F]+"
|
||||
|
||||
# Get pricing configuration based on the model
|
||||
PRICING_CONFIG = getPricingConfig(MODEL)
|
||||
|
|
@ -2098,6 +2098,15 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
if match:
|
||||
translatedText = translatedText.replace(match.group(1), "")
|
||||
|
||||
# Ensure a space follows sentence-ending punctuation before a capital letter.
|
||||
# Japanese doesn't use spaces after !/?, so the AI omits them too.
|
||||
translatedText = re.sub(r'([!?])([A-Z])', r'\1 \2', translatedText)
|
||||
|
||||
# Ensure a single space before a run of RPGMaker pause/wait codes
|
||||
# (\. \! \| \^) when immediately preceded by a word/punctuation char.
|
||||
# Matches the whole code run at once so no intra-run spaces are added.
|
||||
translatedText = re.sub(r'([^\s\\])((?:\\[.!|^])+)', r'\1 \2', translatedText)
|
||||
|
||||
# Fix '- '
|
||||
translatedText = translatedText.replace("- ", "-")
|
||||
|
||||
|
|
|
|||
|
|
@ -1215,10 +1215,14 @@ def calculateCost(inputTokens, outputTokens, model):
|
|||
_thread_local.file_cost_ready = False
|
||||
return cost
|
||||
# TOTAL call (flag already cleared): return the cross-thread running total.
|
||||
# If _global_accurate_cost is 0 it means no real API calls were made
|
||||
# (e.g. estimate mode), so fall through to the naive calculation below.
|
||||
with _global_accurate_cost_lock:
|
||||
return _global_accurate_cost
|
||||
accurate = _global_accurate_cost
|
||||
if accurate > 0:
|
||||
return accurate
|
||||
|
||||
# Non-Claude (or no accurate data available): naive calculation.
|
||||
# Non-Claude, estimate mode, or no accurate data: naive calculation.
|
||||
pricing = getPricingConfig(model)
|
||||
inputCost = (inputTokens / 1_000_000) * pricing["inputAPICost"]
|
||||
outputCost = (outputTokens / 1_000_000) * pricing["outputAPICost"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue