Remove combineList
This commit is contained in:
parent
61fbe8b2f0
commit
429f2e5c97
22 changed files with 132 additions and 176 deletions
|
|
@ -558,12 +558,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
totalTokens = [0, 0]
|
||||
|
|
@ -616,8 +610,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation("\n".join(translatedTextList), False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -499,12 +499,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
mismatch = False
|
||||
|
|
@ -575,8 +569,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -529,12 +529,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -625,8 +619,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -660,12 +660,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR
|
||||
|
|
@ -743,8 +737,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -539,12 +539,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR
|
||||
|
|
@ -625,8 +619,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -682,12 +682,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag, pbar, filename):
|
||||
mismatch = False
|
||||
|
|
@ -759,8 +753,12 @@ def translateGPT(text, history, fullPromptFlag, pbar, filename):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -457,12 +457,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag, pbar):
|
||||
mismatch = False
|
||||
|
|
@ -533,8 +527,12 @@ def translateGPT(text, history, fullPromptFlag, pbar):
|
|||
extractedTranslations = extractTranslation(translatedText, False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -470,12 +470,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -566,8 +560,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -655,12 +655,6 @@ def countTokens(characters, system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
totalTokens = [0, 0]
|
||||
|
|
@ -713,8 +707,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
extractedTranslations = extractTranslation("\n".join(translatedTextList), False)
|
||||
tList[index] = extractedTranslations
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -513,12 +513,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -609,8 +603,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -505,12 +505,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -593,8 +587,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -529,12 +529,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -625,8 +619,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -529,12 +529,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -627,8 +621,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -453,12 +453,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -549,8 +543,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -2585,12 +2585,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -2681,8 +2675,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -2574,12 +2574,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -2670,8 +2664,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -444,12 +444,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -540,8 +534,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -444,12 +444,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -540,8 +534,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -520,12 +520,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -616,8 +610,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -466,12 +466,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -554,8 +548,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -2382,12 +2382,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -2478,8 +2472,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
|
|
@ -487,12 +487,6 @@ def countTokens(system, user, history):
|
|||
return [inputTotalTokens, outputTotalTokens]
|
||||
|
||||
|
||||
def combineList(tlist, text):
|
||||
if isinstance(text, list):
|
||||
return [t for sublist in tlist for t in sublist]
|
||||
return tlist[0]
|
||||
|
||||
|
||||
@retry(exceptions=Exception, tries=5, delay=5)
|
||||
def translateGPT(text, history, fullPromptFlag):
|
||||
global PBAR, MISMATCH, FILENAME
|
||||
|
|
@ -583,8 +577,12 @@ def translateGPT(text, history, fullPromptFlag):
|
|||
# Ensure we're passing a single string to extractTranslation
|
||||
tList[index] = translatedText.replace("Placeholder Text", "")
|
||||
|
||||
# Combine if multilist
|
||||
if isinstance(tList[0], list):
|
||||
tList = [t for sublist in tList for t in sublist]
|
||||
|
||||
# Return
|
||||
if format == "json":
|
||||
finalList = combineList(tList, text)
|
||||
return [finalList, totalTokens]
|
||||
return [tList, totalTokens]
|
||||
else:
|
||||
return [tList[0], totalTokens]
|
||||
|
|
|
|||
Loading…
Reference in a new issue