From a2a4c15e3b2692c6e25edd0355c5dcf1b5f781d2 Mon Sep 17 00:00:00 2001 From: DazedAnon Date: Wed, 22 Jan 2025 13:05:03 -0600 Subject: [PATCH] Check for AI Refusal --- modules/csv.py | 14 ++++++++--- modules/json.py | 8 ++++++ modules/kirikiri.py | 8 ++++++ modules/nscript.py | 8 ++++++ modules/renpy.py | 8 ++++++ modules/rpgmakerace.py | 8 ++++++ modules/rpgmakermvmz.py | 14 ++++++++--- modules/rpgmakerplugin.py | 8 ++++++ modules/text.py | 8 ++++++ modules/tyrano.py | 8 ++++++ modules/wolf.py | 8 ++++++ modules/wolf2.py | 8 ++++++ vocab.txt | 51 ++++++++++++++++++++++++++++++++++++--- 13 files changed, 149 insertions(+), 10 deletions(-) diff --git a/modules/csv.py b/modules/csv.py index 1006f90..da94d04 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -79,7 +79,7 @@ def handleCSV(filename, estimate): ESTIMATE = estimate if not ESTIMATE: - with open("translated/" + filename, "w+t", newline="", encoding=ENCODING) as writeFile: + with open("translated/" + filename, "w+t", newline="", encoding=ENCODING, errors="xmlcharrefreplace") as writeFile: # Translate start = time.time() translatedData = openFiles(filename, writeFile) @@ -113,7 +113,7 @@ def handleCSV(filename, estimate): def openFiles(filename, writeFile): - with open("files/" + filename, "r", encoding="cp932", errors="ignore") as readFile, writeFile: + with open("files/" + filename, "r", encoding=ENCODING) as readFile, writeFile: translatedData = parseCSV(readFile, writeFile, filename) return translatedData @@ -185,7 +185,7 @@ def parseCSV(readFile, writeFile, filename): reader = csv.reader(readFile, delimiter=",") if not ESTIMATE: - writer = csv.writer(writeFile, delimiter=",") + writer = csv.writer(writeFile, delimiter=",", ) else: writer = "" @@ -660,6 +660,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/json.py b/modules/json.py index 48d003f..108d87f 100644 --- a/modules/json.py +++ b/modules/json.py @@ -525,6 +525,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/kirikiri.py b/modules/kirikiri.py index 248dbf4..f77037b 100644 --- a/modules/kirikiri.py +++ b/modules/kirikiri.py @@ -569,6 +569,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/nscript.py b/modules/nscript.py index 77658c4..94cda4f 100644 --- a/modules/nscript.py +++ b/modules/nscript.py @@ -584,6 +584,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/renpy.py b/modules/renpy.py index 70519c6..8fbc29e 100644 --- a/modules/renpy.py +++ b/modules/renpy.py @@ -508,6 +508,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index b9e3911..bedd2e5 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -2591,6 +2591,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 9a9f9fc..f3aff6e 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -61,7 +61,7 @@ if "gpt-3.5" in MODEL: elif "gpt-4" in MODEL: INPUTAPICOST = 0.0025 OUTPUTAPICOST = 0.01 - BATCHSIZE = 60 + BATCHSIZE = 30 FREQUENCY_PENALTY = 0.05 else: INPUTAPICOST = float(os.getenv("input_cost")) @@ -77,10 +77,10 @@ LEAVE = False # Dialogue / Scroll / Choices (Main Codes) CODE401 = True CODE405 = True -CODE102 = False +CODE102 = True # Optional -CODE101 = True # Turn this one when names exist in 101 +CODE101 = False # Turn this one when names exist in 101 CODE408 = False # Warning, translates comments and can inflate costs. # Variables @@ -2702,6 +2702,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/rpgmakerplugin.py b/modules/rpgmakerplugin.py index b950a5c..ef02d85 100644 --- a/modules/rpgmakerplugin.py +++ b/modules/rpgmakerplugin.py @@ -784,6 +784,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/text.py b/modules/text.py index 87d474b..4cd7f62 100644 --- a/modules/text.py +++ b/modules/text.py @@ -497,6 +497,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/tyrano.py b/modules/tyrano.py index 6a2c5c8..3e64cbf 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -571,6 +571,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/wolf.py b/modules/wolf.py index a23d425..d67cee8 100644 --- a/modules/wolf.py +++ b/modules/wolf.py @@ -2373,6 +2373,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/modules/wolf2.py b/modules/wolf2.py index fbb9f20..44293bf 100644 --- a/modules/wolf2.py +++ b/modules/wolf2.py @@ -536,6 +536,14 @@ def translateGPT(text, history, fullPromptFlag): # Translating response = translateText(system, user, history, 0.05, format) + + # AI Refused. Try Again + if not response: + response = translateText(system, user, history, 0.05, format, MODEL) + if not response: + continue + + # Set Tokens translatedText = response.choices[0].message.content totalTokens[0] += response.usage.prompt_tokens totalTokens[1] += response.usage.completion_tokens diff --git a/vocab.txt b/vocab.txt index e540223..26af8a0 100644 --- a/vocab.txt +++ b/vocab.txt @@ -1,10 +1,10 @@ Here are some vocabulary and terms so that you know the proper spelling and translation. ``` # Game Characters -ジョフ (Joff) - Male -ミラ (Mira) - Female -ルマ (Ruma) - Female -チェーカ (Cheka) - Female +イルミナ (Lumina) - Female +セラ (Sera) - Female +リアン (Lian) - Female +イニス (Inis) - Female # Lewd Terms マンコ (pussy) @@ -99,4 +99,47 @@ w ((lol)) # Locations サイノ河 (Saino River) オソレ峠 一幕 (Osore Pass Act One) + +#Skills +ヒール (Heal) +ファイア (Fire) +スパーク (Spark) +アーマーブレイク (Armor Break) +チートアタック (Cheat Attack) +ゴブリン拘束攻撃 (Goblin Restraint Attack) +ゴブリン拘束攻撃バックアップ (Goblin Restraint Attack Backup) +■↓イルミナの技↓■ (■↓Lumina's Skills↓■) +ホーリーインパクト (Holy Impact) +セイントアロー (Saint Arrow) +ホーリーインパクトII (Holy Impact II) +セイントアローII (Saint Arrow II) +ヒール (Heal) +クリアウィンド (Clear Wind) +エクスプロージョン (Explosion) +アンチマジック (Anti-Magic) +リザレクション (Resurrection) +リジェネ (Regen) +ルミナス・ゲイル (Luminous Gale) +プロメテウスバースト (Prometheus Burst) +コキュートス (Cocytus) +ディエス・イラ (Dies Irae) +■インフェリアード行動■ (■ Inferiard Actions ■) +ブロッサムスラッシュ (Blossom Slash) +ラッシュオブアイビー (Rush of Ivy) +デバウアーブロッサム (Devour Blossom) +■マクスウェル行動■ (■ Maxwell Actions ■) +チャージ (Charge) +サンダーフォース (Thunder Force) +オーバードライブ・キャノン (Overdrive Cannon) +マシンガン (Machine Gun) +■ナイトメア (■ Nightmare) +イントロイトゥス (Introitus) +タルタロス・ハウル (Tartarus Howl) +ユーディキウム (Eudicium) +ソムニウム・シネフィーネ (Somnium Cinefine) +ラクリモーサ (Lacrimosa) +モルス・ウルティマ (Mors Ultima) +リベラ・メ (Libera Me) +ディエス・イレ (Dies Irae) +乱舞 (Wild Dance) ``` \ No newline at end of file