CLI estimation mismatch fix
This commit is contained in:
parent
76dba4e618
commit
e37852c8b3
2 changed files with 19 additions and 8 deletions
|
|
@ -235,9 +235,10 @@ def _pat355655_captured_text(match):
|
|||
|
||||
|
||||
def handleMVMZ(filename, estimate):
|
||||
global ESTIMATE, TOKENS, FILENAME
|
||||
global ESTIMATE, TOKENS, FILENAME, MISMATCH
|
||||
ESTIMATE = estimate
|
||||
FILENAME = filename
|
||||
MISMATCH = [] # Reset per-file; prevents cross-file contamination in CLI mode
|
||||
# Also record per-thread filename to avoid cross-thread interference
|
||||
try:
|
||||
THREAD_CTX.filename = filename
|
||||
|
|
|
|||
|
|
@ -1831,17 +1831,27 @@ def translateAI(text, history, config, filename=None, pbar=None, lock=None, mism
|
|||
# Check cache for this exact payload
|
||||
cached_result = get_cached_translation(subbedT, config.language)
|
||||
if cached_result is not None:
|
||||
if isinstance(tItem, list):
|
||||
tList[index] = cached_result
|
||||
history = cached_result[-config.maxHistory:]
|
||||
# In estimate mode, never replace tList[index] from cache — the cached value
|
||||
# may have been stored for a batch with a different number of skip_indices,
|
||||
# so its length can differ from the current tItem. Keeping tList[index] as
|
||||
# the original tItem ensures the returned list always has the correct length.
|
||||
if not config.estimateMode:
|
||||
if isinstance(tItem, list):
|
||||
tList[index] = cached_result
|
||||
history = cached_result[-config.maxHistory:]
|
||||
else:
|
||||
tList[index] = cached_result
|
||||
history = cached_result
|
||||
else:
|
||||
tList[index] = cached_result
|
||||
history = cached_result
|
||||
|
||||
if isinstance(cached_result, list) and cached_result:
|
||||
history = cached_result[-config.maxHistory:]
|
||||
elif cached_result:
|
||||
history = cached_result
|
||||
|
||||
if lock and pbar is not None:
|
||||
with lock:
|
||||
pbar.update(len(tItem) if isinstance(tItem, list) else 1)
|
||||
|
||||
|
||||
continue
|
||||
|
||||
# Create context — static_system is the stable prompt.txt content;
|
||||
|
|
|
|||
Loading…
Reference in a new issue