From c1f480e93bf879e886f55c22d25537319ab1f8af Mon Sep 17 00:00:00 2001 From: m5kro Date: Wed, 15 Nov 2023 21:21:25 -0800 Subject: [PATCH 1/6] Add More Variables and Start scripts --- .DS_Store | Bin 0 -> 6148 bytes .env.example | 9 +++++++-- modules/.DS_Store | Bin 0 -> 6148 bytes modules/alltext.py | 27 +++++++++++++++------------ modules/csv.py | 13 ++++++++----- modules/json.py | 13 ++++++++----- modules/kansen.py | 13 ++++++++----- modules/lune.py | 13 ++++++++----- modules/lune2.py | 13 ++++++++----- modules/main.py | 2 +- modules/rpgmakerace.py | 13 ++++++++----- modules/rpgmakermvmz.py | 13 ++++++++----- modules/txt.py | 13 ++++++++----- modules/tyrano.py | 13 ++++++++----- start.bat | 13 +++++++++++++ start.sh | 11 +++++++++++ 16 files changed, 119 insertions(+), 60 deletions(-) create mode 100644 .DS_Store create mode 100644 modules/.DS_Store create mode 100644 start.bat create mode 100755 start.sh diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b8ab2677ddfcde5782c5d2b3f4370dfdf998843b GIT binary patch literal 6148 zcmeHKO^ee&7=CBBYtybu4~lyc0$$77t-2syx@{L(P?3%3L8T@pt6|ejP13DW3O(z8 z@b1a0zr%z7#Z!IeVD_j#Y2UuJKbzI8t2b`mJ06@y!jW2j>0j@JrwygBJla^jzAt zav$b7XkzV6?^tVl?PqExXcRCC{H+4we6SG&b~Mfv%A*63d;$O~D3*q__z4gkTVqG# zTp?;;Oi_V~%JdV1DLTq+?bp#bSE%U3^y7o+o|%53FxflWx1~F=jzSX~1&jhk1vXW- zA@2Xf-@pHhB$G1=7zNf!0aocd{Vt}Y@7ATsiM!TDc!eNL_{|kc3L" -organization="" +key="" +organization="" +proxy="" +model="" +timeout="" +fileThreads="" +threads="" \ No newline at end of file diff --git a/modules/.DS_Store b/modules/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a6a92c67b0b816638ceb21c81769a6ad72f421e8 GIT binary patch literal 6148 zcmeHKOHRWu6dZ@DKO|tuG7H2K3B&=SQY2V&0cfcZ^oL4|C<~M`a0Cv)5jX^wfqBnX z)g)$%5PC1NC$VRemx*l009fW{ZcBCgqBUB(|Zi?ggFjyk7b2z z4d#G3@YfuWvD?NKMm*+N8^7nHX}>p`_Si3z!v}}>{#OWI*U`rV9{pG^a@}!>+rS;U zQ%s`lw-URBA@i9~F^DS?=2OU}!Q2<*4r2FDUP|odihUI0->JJ*|+#blGhTqMeb5_oAA5n zd|gy*P*89|t}XtT16;EunlcAim;>g3Ik4`4%nvDxU=}ddH-J&*_An94*V+zT&;W2?eLYt+FE%zS!+|4OBM;? 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, tokens] \ No newline at end of file + return [translatedText, tokens] diff --git a/modules/csv.py b/modules/csv.py index 7112ef2..6fd6bf5 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -18,12 +18,15 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 20 +THREADS = int(os.getenv('threads')) LOCK = threading.Lock() WIDTH = 60 MAXHISTORY = 10 @@ -320,7 +323,7 @@ def resubVars(translatedText, allList): 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") + enc = tiktoken.encoding_for_model(MODEL) tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) @@ -365,9 +368,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -395,4 +398,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, tokens] \ No newline at end of file + return [translatedText, tokens] diff --git a/modules/json.py b/modules/json.py index 402c8aa..b1a61dd 100644 --- a/modules/json.py +++ b/modules/json.py @@ -17,13 +17,16 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) INPUTAPICOST = .002 # Depends on the model https://openai.com/pricing OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 10 # Controls how many threads are working on a single file (May have to drop this) +THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() WIDTH = 50 LISTWIDTH = 90 @@ -293,7 +296,7 @@ def resubVars(translatedText, allList): 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-3.5-turbo") + enc = tiktoken.encoding_for_model(MODEL) historyRaw = '' if isinstance(history, list): for line in history: @@ -346,9 +349,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo-1106", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -376,4 +379,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, totalTokens] \ No newline at end of file + return [translatedText, totalTokens] diff --git a/modules/kansen.py b/modules/kansen.py index 464599e..ecb0b21 100644 --- a/modules/kansen.py +++ b/modules/kansen.py @@ -16,12 +16,15 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 10 # For GPT4 rate limit will be hit if you have more than 1 thread. +THREADS = int(os.getenv('threads')) # For GPT4 rate limit will be hit if you have more than 1 thread. LOCK = threading.Lock() WIDTH = 60 LISTWIDTH = 60 @@ -461,7 +464,7 @@ def resubVars(translatedText, allList): 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") + enc = tiktoken.encoding_for_model(MODEL) tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) @@ -506,9 +509,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -536,4 +539,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, tokens] \ No newline at end of file + return [translatedText, tokens] diff --git a/modules/lune.py b/modules/lune.py index f3548c2..3ea904a 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -17,13 +17,16 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) INPUTAPICOST = .002 # Depends on the model https://openai.com/pricing OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 10 # Controls how many threads are working on a single file (May have to drop this) +THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() WIDTH = 50 LISTWIDTH = 90 @@ -293,7 +296,7 @@ def resubVars(translatedText, allList): 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-3.5-turbo") + enc = tiktoken.encoding_for_model(MODEL) historyRaw = '' if isinstance(history, list): for line in history: @@ -346,9 +349,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo-1106", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -376,4 +379,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, totalTokens] \ No newline at end of file + return [translatedText, totalTokens] diff --git a/modules/lune2.py b/modules/lune2.py index 5ba9c9d..eb25f60 100644 --- a/modules/lune2.py +++ b/modules/lune2.py @@ -18,12 +18,15 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 20 +THREADS = int(os.getenv('threads')) LOCK = threading.Lock() WIDTH = 60 LISTWIDTH = 75 @@ -347,7 +350,7 @@ def resubVars(translatedText, allList): 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") + enc = tiktoken.encoding_for_model(MODEL) tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) @@ -392,9 +395,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -422,4 +425,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, tokens] \ No newline at end of file + return [translatedText, tokens] diff --git a/modules/main.py b/modules/main.py index f842d76..5bbc342 100644 --- a/modules/main.py +++ b/modules/main.py @@ -17,7 +17,7 @@ from modules.lune2 import handleLuneTxt # For GPT4 rate limit will be hit if you have more than 1 thread. # 1 Thread for each file. Controls how many files are worked on at once. -THREADS = 5 +THREADS = int(os.getenv('fileThreads')) # Info Message tqdm.write(Fore.LIGHTYELLOW_EX + "WARNING: Once a translation starts do not close it unless you want to lose your\ diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index 25674a6..43dfb27 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -19,13 +19,16 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) INPUTAPICOST = .002 # Depends on the model https://openai.com/pricing OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 10 # Controls how many threads are working on a single file (May have to drop this) +THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() WIDTH = 50 LISTWIDTH = 90 @@ -1757,7 +1760,7 @@ def resubVars(translatedText, allList): 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-3.5-turbo") + enc = tiktoken.encoding_for_model(MODEL) historyRaw = '' if isinstance(history, list): for line in history: @@ -1811,9 +1814,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -1841,4 +1844,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, totalTokens] \ No newline at end of file + return [translatedText, totalTokens] diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index b73c32d..204fe5b 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -18,13 +18,16 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) INPUTAPICOST = .002 # Depends on the model https://openai.com/pricing OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 10 # Controls how many threads are working on a single file (May have to drop this) +THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() WIDTH = 40 LISTWIDTH = 50 @@ -1758,7 +1761,7 @@ def resubVars(translatedText, allList): 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-3.5-turbo") + enc = tiktoken.encoding_for_model(MODEL) historyRaw = '' if isinstance(history, list): for line in history: @@ -1813,9 +1816,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo-1106", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -1843,4 +1846,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, totalTokens] \ No newline at end of file + return [translatedText, totalTokens] diff --git a/modules/txt.py b/modules/txt.py index 05f58de..59917f3 100644 --- a/modules/txt.py +++ b/modules/txt.py @@ -18,12 +18,15 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 20 +THREADS = int(os.getenv('threads')) LOCK = threading.Lock() WIDTH = 75 LISTWIDTH = 75 @@ -305,7 +308,7 @@ def resubVars(translatedText, allList): 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") + enc = tiktoken.encoding_for_model(MODEL) tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) @@ -350,9 +353,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -380,4 +383,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, tokens] \ No newline at end of file + return [translatedText, tokens] diff --git a/modules/tyrano.py b/modules/tyrano.py index 97b0b41..3018b03 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -16,12 +16,15 @@ from tqdm import tqdm #Globals load_dotenv() +openai.api_base = os.getenv('proxy') openai.organization = os.getenv('org') openai.api_key = os.getenv('key') +MODEL = os.getenv('model') +TIMEOUT = int(os.getenv('timeout')) APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') -THREADS = 10 # For GPT4 rate limit will be hit if you have more than 1 thread. +THREADS = int(os.getenv('threads')) # For GPT4 rate limit will be hit if you have more than 1 thread. LOCK = threading.Lock() WIDTH = 80 LISTWIDTH = 60 @@ -475,7 +478,7 @@ def resubVars(translatedText, allList): 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-3.5-turbo") + enc = tiktoken.encoding_for_model(MODEL) tokens = len(enc.encode(t)) * 2 + len(enc.encode(str(history))) + len(enc.encode(PROMPT)) return (t, tokens) @@ -517,9 +520,9 @@ def translateGPT(t, history, fullPromptFlag): temperature=0.1, frequency_penalty=0.2, presence_penalty=0.2, - model="gpt-3.5-turbo", + model=MODEL, messages=msg, - request_timeout=30, + request_timeout=TIMEOUT, ) # Save Translated Text @@ -547,4 +550,4 @@ def translateGPT(t, history, fullPromptFlag): if len(translatedText) > 15 * len(t) or "I'm sorry, but I'm unable to assist with that translation" in translatedText: raise Exception else: - return [translatedText, tokens] \ No newline at end of file + return [translatedText, tokens] diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..8c5e876 --- /dev/null +++ b/start.bat @@ -0,0 +1,13 @@ +@echo off +set /p choice=Do you want to edit the .env file? (y/n): +if /i "%choice%"=="y" ( + notepad .env + echo Press enter when you are done + pause + echo Continuing... +) else ( + echo Continuing without editing .env file... +) +python3 -m pip install -r requirements.txt +python3 start.py +pause \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..2fd110a --- /dev/null +++ b/start.sh @@ -0,0 +1,11 @@ +#!/bin/bash +read -p "Do you want to edit the .env file? (y/n): " choice + +if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then + nano .env + echo "Continuing..." +else + echo "Continuing without editing .env file..." +fi +python3 -m pip install -r requirements.txt +python3 start.py \ No newline at end of file From 797a4c2d98aaaa4218be9c7206bca47a227f9911 Mon Sep 17 00:00:00 2001 From: m5kro Date: Wed, 15 Nov 2023 21:24:11 -0800 Subject: [PATCH 2/6] remove DS Store files --- .DS_Store | Bin 6148 -> 0 bytes modules/.DS_Store | Bin 6148 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 modules/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index b8ab2677ddfcde5782c5d2b3f4370dfdf998843b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO^ee&7=CBBYtybu4~lyc0$$77t-2syx@{L(P?3%3L8T@pt6|ejP13DW3O(z8 z@b1a0zr%z7#Z!IeVD_j#Y2UuJKbzI8t2b`mJ06@y!jW2j>0j@JrwygBJla^jzAt zav$b7XkzV6?^tVl?PqExXcRCC{H+4we6SG&b~Mfv%A*63d;$O~D3*q__z4gkTVqG# zTp?;;Oi_V~%JdV1DLTq+?bp#bSE%U3^y7o+o|%53FxflWx1~F=jzSX~1&jhk1vXW- zA@2Xf-@pHhB$G1=7zNf!0aocd{Vt}Y@7ATsiM!TDc!eNL_{|kc3LfW{ZcBCgqBUB(|Zi?ggFjyk7b2z z4d#G3@YfuWvD?NKMm*+N8^7nHX}>p`_Si3z!v}}>{#OWI*U`rV9{pG^a@}!>+rS;U zQ%s`lw-URBA@i9~F^DS?=2OU}!Q2<*4r2FDUP|odihUI0->JJ*|+#blGhTqMeb5_oAA5n zd|gy*P*89|t}XtT16;EunlcAim;>g3Ik4`4%nvDxU=}ddH-J&*_An94*V+zT&;W2?eLYt+FE%zS!+|4OBM;? Date: Wed, 15 Nov 2023 21:50:08 -0800 Subject: [PATCH 3/6] Add Width Variables --- .env.example | 4 +++- modules/alltext.py | 4 ++-- modules/csv.py | 2 +- modules/json.py | 4 ++-- modules/kansen.py | 4 ++-- modules/lune.py | 4 ++-- modules/lune2.py | 4 ++-- modules/rpgmakerace.py | 4 ++-- modules/rpgmakermvmz.py | 4 ++-- modules/txt.py | 4 ++-- modules/tyrano.py | 4 ++-- 11 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index 657b683..a59c906 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,6 @@ proxy="" model="" timeout="" fileThreads="" -threads="" \ No newline at end of file +threads="" +width="" +listWidth="" \ No newline at end of file diff --git a/modules/alltext.py b/modules/alltext.py index 9f7c541..defd384 100644 --- a/modules/alltext.py +++ b/modules/alltext.py @@ -28,8 +28,8 @@ APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # For GPT4 rate limit will be hit if you have more than 1 thread. LOCK = threading.Lock() -WIDTH = 60 -LISTWIDTH = 60 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) MAXHISTORY = 10 ESTIMATE = '' TOTALCOST = 0 diff --git a/modules/csv.py b/modules/csv.py index 6fd6bf5..1a662e4 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -28,7 +28,7 @@ APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) LOCK = threading.Lock() -WIDTH = 60 +WIDTH = int(os.getenv('width')) MAXHISTORY = 10 ESTIMATE = '' TOTALCOST = 0 diff --git a/modules/json.py b/modules/json.py index b1a61dd..def8baa 100644 --- a/modules/json.py +++ b/modules/json.py @@ -28,8 +28,8 @@ OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() -WIDTH = 50 -LISTWIDTH = 90 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) NOTEWIDTH = 50 MAXHISTORY = 10 ESTIMATE = '' diff --git a/modules/kansen.py b/modules/kansen.py index ecb0b21..a48bbe3 100644 --- a/modules/kansen.py +++ b/modules/kansen.py @@ -26,8 +26,8 @@ APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # For GPT4 rate limit will be hit if you have more than 1 thread. LOCK = threading.Lock() -WIDTH = 60 -LISTWIDTH = 60 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) MAXHISTORY = 10 ESTIMATE = '' TOTALCOST = 0 diff --git a/modules/lune.py b/modules/lune.py index 3ea904a..77c322a 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -28,8 +28,8 @@ OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() -WIDTH = 50 -LISTWIDTH = 90 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) NOTEWIDTH = 50 MAXHISTORY = 10 ESTIMATE = '' diff --git a/modules/lune2.py b/modules/lune2.py index eb25f60..fb284b3 100644 --- a/modules/lune2.py +++ b/modules/lune2.py @@ -28,8 +28,8 @@ APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) LOCK = threading.Lock() -WIDTH = 60 -LISTWIDTH = 75 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) MAXHISTORY = 10 ESTIMATE = '' TOTALCOST = 0 diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index 43dfb27..8233a1f 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -30,8 +30,8 @@ OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() -WIDTH = 50 -LISTWIDTH = 90 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) NOTEWIDTH = 50 MAXHISTORY = 10 ESTIMATE = '' diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index 204fe5b..deac15e 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -29,8 +29,8 @@ OUTPUTAPICOST = .002 PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # Controls how many threads are working on a single file (May have to drop this) LOCK = threading.Lock() -WIDTH = 40 -LISTWIDTH = 50 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) NOTEWIDTH = 40 MAXHISTORY = 10 ESTIMATE = '' diff --git a/modules/txt.py b/modules/txt.py index 59917f3..d42280d 100644 --- a/modules/txt.py +++ b/modules/txt.py @@ -28,8 +28,8 @@ APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) LOCK = threading.Lock() -WIDTH = 75 -LISTWIDTH = 75 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) MAXHISTORY = 10 ESTIMATE = '' TOTALCOST = 0 diff --git a/modules/tyrano.py b/modules/tyrano.py index 3018b03..954451f 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -26,8 +26,8 @@ APICOST = .002 # Depends on the model https://openai.com/pricing PROMPT = Path('prompt.txt').read_text(encoding='utf-8') THREADS = int(os.getenv('threads')) # For GPT4 rate limit will be hit if you have more than 1 thread. LOCK = threading.Lock() -WIDTH = 80 -LISTWIDTH = 60 +WIDTH = int(os.getenv('width')) +LISTWIDTH = int(os.getenv('listWidth')) MAXHISTORY = 10 ESTIMATE = '' TOTALCOST = 0 From c98bddf08a6917cd4451b58a6e4b0c55d43e3c3e Mon Sep 17 00:00:00 2001 From: m5kro <44246711+m5kro@users.noreply.github.com> Date: Wed, 15 Nov 2023 21:54:37 -0800 Subject: [PATCH 4/6] Update README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 5a17513..f9b25c1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ +This is a modified version of dazedanon's DazedMTLTool indended for use with proxies and self hosted LLM APIs. There are also some "quality of life" changes. + +In the .env file there are a few new variables to play with: +

proxy - The link to the API you want to use

+

model - The model name of the LLM

+

timeout - The timeout before disconnect error (30 to 120 recommended)

+

fileThreads - The number of files to translate at the same time (1 recommended for free or self hosted API)

+

threads - The number of threads per file (1 recommended for free or self hosted API)

+

width - The wordwrap of dialogue text

+

listWidth - The wordwap of items and help text

+
+

Depending on the API a key or organization won't be needed. You can just set those to something random.

+

Start scripts have been added to streamline the process.

+ +All credit goes to dazedanon for creating this marvelous tool. # DazedMTLTool - A script that translates RPGMaker JSON files using ChatGPT API ![image](https://user-images.githubusercontent.com/96628874/230908699-adacb5e1-1548-4116-a0ea-a33297cdafa4.png) From 15cf68cac0fbb92f7c9707c42d0aa7f102523ecb Mon Sep 17 00:00:00 2001 From: m5kro Date: Fri, 17 Nov 2023 18:58:37 -0800 Subject: [PATCH 5/6] Undo Accidental Change --- modules/alltext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/alltext.py b/modules/alltext.py index b33a3ed..62a1d97 100644 --- a/modules/alltext.py +++ b/modules/alltext.py @@ -104,7 +104,7 @@ def translateGPT(t, history, fullPromptFlag): subbedT = varResponse[0] # If there isn't any Japanese in the text just skip - if not re.search(r'[��-�]+|[��-?]+|[�@-��]+|[\uFF00-\uFFEF]', subbedT): + if not re.search(r'[一-龠]+|[ぁ-ゔ]+|[ァ-ヴ]+|[\uFF00-\uFFEF]', subbedT): return (t, 0) # Characters From ae9f9142c1640634abc3c3058a6372f24e35ee4e Mon Sep 17 00:00:00 2001 From: m5kro Date: Sat, 18 Nov 2023 11:28:48 -0800 Subject: [PATCH 6/6] Default to OpenAI API if no API given --- .env.example | 31 +++++++++++++++++++++++++------ README.md | 15 --------------- modules/alltext.py | 7 ++++++- modules/csv.py | 7 ++++++- modules/json.py | 7 ++++++- modules/kansen.py | 7 ++++++- modules/lune.py | 7 ++++++- modules/lune2.py | 7 ++++++- modules/rpgmakerace.py | 7 ++++++- modules/rpgmakermvmz.py | 7 ++++++- modules/txt.py | 7 ++++++- modules/tyrano.py | 7 ++++++- 12 files changed, 85 insertions(+), 31 deletions(-) diff --git a/.env.example b/.env.example index 82972d3..6429ce5 100644 --- a/.env.example +++ b/.env.example @@ -1,11 +1,30 @@ +#API link, leave blank to use OpenAI API +api="" + +#API key key="" + +#Oranization key, make something up for self hosted or other API organization="" -proxy="" + +#LLM model name, use gpt-3.5-turbo-1106 or gpt-3.5-turbo or gpt-4 for OpenAI API +#For text generation webui use gpt-3.5-turbo, for other API's consult their documentation model="" -timeout="" -fileThreads="" -threads="" -width="" -listWidth="" + #The language to translate TO, Don't forget to change the prompt language="" + +#The timeout before disconnect error, 30 to 120 recommended +timeout="" + +#The number of files to translate at the same time, 1 recommended for free or self hosted API or gpt-4 +fileThreads="" + +#The number of threads per file, 1 recommended for free or self hosted API or gpt-4 +threads="" + +#The wordwrap of dialogue text +width="" + +#The wordwap of items and help text +listWidth="" \ No newline at end of file diff --git a/README.md b/README.md index f9b25c1..5a17513 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,3 @@ -This is a modified version of dazedanon's DazedMTLTool indended for use with proxies and self hosted LLM APIs. There are also some "quality of life" changes. - -In the .env file there are a few new variables to play with: -

proxy - The link to the API you want to use

-

model - The model name of the LLM

-

timeout - The timeout before disconnect error (30 to 120 recommended)

-

fileThreads - The number of files to translate at the same time (1 recommended for free or self hosted API)

-

threads - The number of threads per file (1 recommended for free or self hosted API)

-

width - The wordwrap of dialogue text

-

listWidth - The wordwap of items and help text

-
-

Depending on the API a key or organization won't be needed. You can just set those to something random.

-

Start scripts have been added to streamline the process.

- -All credit goes to dazedanon for creating this marvelous tool. # DazedMTLTool - A script that translates RPGMaker JSON files using ChatGPT API ![image](https://user-images.githubusercontent.com/96628874/230908699-adacb5e1-1548-4116-a0ea-a33297cdafa4.png) diff --git a/modules/alltext.py b/modules/alltext.py index 4e36dc0..bb595c3 100644 --- a/modules/alltext.py +++ b/modules/alltext.py @@ -18,7 +18,12 @@ from tqdm import tqdm # Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/csv.py b/modules/csv.py index 96f8c21..94cfa57 100644 --- a/modules/csv.py +++ b/modules/csv.py @@ -18,7 +18,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/json.py b/modules/json.py index fddf2d1..f3360c8 100644 --- a/modules/json.py +++ b/modules/json.py @@ -17,7 +17,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/kansen.py b/modules/kansen.py index ae82e0d..f0af984 100644 --- a/modules/kansen.py +++ b/modules/kansen.py @@ -16,7 +16,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/lune.py b/modules/lune.py index 952ca4b..bae87f9 100644 --- a/modules/lune.py +++ b/modules/lune.py @@ -17,7 +17,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/lune2.py b/modules/lune2.py index a0ffe75..46a4a4c 100644 --- a/modules/lune2.py +++ b/modules/lune2.py @@ -18,7 +18,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/rpgmakerace.py b/modules/rpgmakerace.py index 5fd7744..2175d36 100644 --- a/modules/rpgmakerace.py +++ b/modules/rpgmakerace.py @@ -19,7 +19,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index ac324a0..9364d93 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -18,7 +18,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/txt.py b/modules/txt.py index 585391a..3d2b394 100644 --- a/modules/txt.py +++ b/modules/txt.py @@ -18,7 +18,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model') diff --git a/modules/tyrano.py b/modules/tyrano.py index 12dc59e..8b31163 100644 --- a/modules/tyrano.py +++ b/modules/tyrano.py @@ -16,7 +16,12 @@ from tqdm import tqdm #Globals load_dotenv() -openai.api_base = os.getenv('proxy') +if not os.getenv('api').replace(" ", ""): + print('No API given, defaulting to OpenAI API') +else: + openai.api_base = os.getenv('api') + print('Using ' + os.getenv('api') + ' as API') + openai.organization = os.getenv('org') openai.api_key = os.getenv('key') MODEL = os.getenv('model')