refactor: move prompt to env
This commit is contained in:
parent
b91ecea122
commit
c79ebef460
2 changed files with 8 additions and 14 deletions
|
|
@ -1,3 +1,7 @@
|
|||
key="<OPEN_AI_KEY>"
|
||||
openai.organization='<ORG_KEY>'
|
||||
organization='<ORG_KEY>'
|
||||
system="\n\n###\n\n You are a professional Japanese visual novel translator, editor, and localizer.\
|
||||
You always manages to carry all of the little nuances of the original Japanese text to your output,\
|
||||
while still making it a prose masterpiece, and localizing it in a way that an average American would\
|
||||
understand.\
|
||||
|
||||
|
|
|
|||
16
main.py
16
main.py
|
|
@ -16,6 +16,7 @@ import openai
|
|||
load_dotenv()
|
||||
openai.organization = os.getenv('org')
|
||||
openai.api_key = os.getenv('key')
|
||||
SYSTEM = os.getenv('system')
|
||||
THREADS = 20
|
||||
COST = .002 # Depends on the model https://openai.com/pricing
|
||||
|
||||
|
|
@ -82,13 +83,12 @@ def parseMap(data, filename):
|
|||
for page in event['pages']:
|
||||
totalLines += len(page['list'])
|
||||
|
||||
with tqdm(total = totalLines, leave=False, desc=filename, bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}', position=0, delay=10) as pbar:
|
||||
with tqdm(total = totalLines, leave=False, desc=filename, bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}', position=0) as pbar:
|
||||
for event in events:
|
||||
if event is not None:
|
||||
with ThreadPoolExecutor(max_workers=THREADS) as executor:
|
||||
for page in event['pages']:
|
||||
future = executor.submit(searchCodes, page, pbar)
|
||||
pbar.close()
|
||||
|
||||
# Verify if an exception was thrown
|
||||
try:
|
||||
|
|
@ -171,17 +171,7 @@ def translateGPT(t, history):
|
|||
|
||||
"""Translate text using GPT"""
|
||||
|
||||
system = "Context: " + history + "\n\n###\n\n You are a professional Japanese visual novel translator,\
|
||||
editor, and localizer. You always manages to carry all of the little nuances of the original Japanese text to your output,\
|
||||
while still making it a prose masterpiece, and localizing it in a way that an average American would understand.\
|
||||
The 'Context' at the top is previously translated text for the work.\
|
||||
You translate Onomatopoeia literally.\
|
||||
When I give you something to translate, answer with just the translation.\
|
||||
Translation Examples:\
|
||||
\\n<ルイ>そう、私はルイよ。= \\n<Rui> Yes, I'm Rui.\
|
||||
\\nそう、私はルイよ。= \\nYes, I'm Rui.\
|
||||
\\n<瑠唯>イヤァァァ\"ァ\"ァ\"ァ\"ァ\"っ!!? = \\n<Rui> Iyaaaaaaa\!!?\
|
||||
\\nイグぅぅぅぅぅぅぅゥゥゥゥゥゥっ!!!♡♡♡ = \\nIguuuuuuuuuuuuu!!!♡♡♡"
|
||||
system = "Context: " + history + system
|
||||
response = openai.ChatCompletion.create(
|
||||
temperature=0,
|
||||
model="gpt-3.5-turbo",
|
||||
|
|
|
|||
Loading…
Reference in a new issue