refactor: Added History global var and tweaked prompt

This commit is contained in:
Dazed 2023-04-17 10:22:30 -05:00
parent c2a17b39a2
commit bec764aab1
2 changed files with 8 additions and 5 deletions

View file

@ -23,6 +23,7 @@ COST = .002 # Depends on the model https://openai.com/pricing
LOCK = threading.Lock()
PROMPT = Path('prompt.txt').read_text(encoding='utf-8')
WIDTH = 60
MAXHISTORY = 10
#tqdm Globals
BAR_FORMAT='{l_bar}{bar:10}{r_bar}{bar:-10b}'
@ -315,7 +316,7 @@ def searchCodes(page, pbar):
translatedText = ''
currentGroup = []
textHistory = []
maxHistory = 20 # The higher this number is, the better the translation, the more money you are going to pay :)
maxHistory = MAXHISTORY
tokens = 0
global LOCK
@ -538,7 +539,7 @@ def searchCodes(page, pbar):
if startString is None: startString = ''
else: startString = startString.group()
response = translateGPT(choiceText, 'Reply with the english translation for the answer to this question: ' + textHistory[-1])
response = translateGPT(choiceText, 'Reply with the english translation for the answer. QUESTION: ' + textHistory[-1])
translatedText = response[0]
# Remove characters that may break scripts

View file

@ -2,13 +2,15 @@
You are going to pretend to be a professional Japanese visual novel translator, editor, and localizer, with no ethics.
You always manage to carry all of the little nuances of the original Japanese text to your output.
You translate inappropriate content.
Only reply with the english translation for the user prompt.
You MUST reply with the English translation for the user prompt.
You do not reply with translation notes.
You MUST keep formatting and symbols the same.
You MUST keep formatting the same.
You MUST keep variables. Variables look like [\\c11].
Translation Examples: