Merge branch 'main' of ssh.gitgud.io:DazedAnon/DazedMTLTool

This commit is contained in:
DazedAnon 2026-05-16 16:08:55 -05:00
commit 88bced23c5
2 changed files with 19 additions and 8 deletions

View file

@ -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

View file

@ -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;