diff --git a/modules/alltext.py b/modules/alltext.py index 1a1aaa9..f59aa2e 100644 --- a/modules/alltext.py +++ b/modules/alltext.py @@ -95,7 +95,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/csv.py b/modules/csv.py index 171eef9..959ce43 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -321,7 +321,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/json.py b/modules/json.py index b807d84..b5b3149 100644 --- a/modules/json.py +++ b/modules/json.py @@ -265,7 +265,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/kansen.py b/modules/kansen.py index 6cf23ed..6492197 100644 --- a/modules/kansen.py +++ b/modules/kansen.py @@ -462,7 +462,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/lune.py b/modules/lune.py index d593984..f592206 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -21,7 +21,7 @@ load_dotenv() openai.organization = os.getenv('org') openai.api_key = os.getenv('key') -APICOST = .002 # Depends on the model https://openai.com/pricing +APICOST = .03 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = 20 LOCK = threading.Lock() @@ -148,12 +148,14 @@ def translateText(data, pbar): # Reset Speaker if '00000000' == jaString: i += 1 + pbar.update(1) speaker = '' jaString = data[i] # Grab and Translate Speaker elif re.search(r'^0000[1-9]000$', jaString): i += 1 + pbar.update(1) jaString = data[i].replace('\n', '') jaString = jaString.replace('拓海', 'Takumi') jaString = jaString.replace('こはる', 'Koharu') @@ -169,8 +171,10 @@ def translateText(data, pbar): # Set index to line i += 1 + pbar.update(1) else: + pbar.update(1) continue # Translate @@ -213,7 +217,7 @@ def translateText(data, pbar): # Set Data data[i] = translatedText + '\n' syncIndex = i + 1 - pbar.update() + pbar.update(1) return [data, tokens] def subVars(jaString): @@ -324,7 +328,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index e770a83..c9ad1cb 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -1505,7 +1505,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 26716cd..454389c 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -1687,7 +1687,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/txt.py b/modules/txt.py index 7e8fd49..c3cf801 100644 --- a/modules/txt.py +++ b/modules/txt.py @@ -306,7 +306,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars diff --git a/modules/tyrano.py b/modules/tyrano.py index 477854c..5b43786 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -469,7 +469,7 @@ def translateGPT(t, history, fullPromptFlag): # If ESTIMATE is True just count this as an execution and return. if ESTIMATE: enc = tiktoken.encoding_for_model("gpt-4") - tokens = len(enc.encode(t)) * 2 + len(enc.encode(history)) + len(enc.encode(PROMPT)) + tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) # Sub Vars