Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions make_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def __init__(self, key, language, api_base=None):
def translate(self, text):
print(text)
self.headers["Authorization"] = f"Bearer {self.get_key(self.api_key)}"
self.data["prompt"] = f"Please help me to translate,`{text}` to {self.language}"
self.data[
"prompt"
] = f"I want you to act as an {self.language} translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in {self.language}. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level {self.language} words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations, the text is: \n\n{text}"
r = self.session.post(self.api_url, headers=self.headers, json=self.data)
if not r.ok:
return text
Expand Down Expand Up @@ -98,7 +100,7 @@ def translate(self, text):
{
"role": "user",
# english prompt here to save tokens
"content": f"Please help me to translate,`{text}` to {self.language}, please return only translated content not include the origin text",
"content": f"I want you to act as an {self.language} translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in {self.language}. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level {self.language} words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations, the text is: \n\n{text}",
}
],
)
Expand All @@ -124,7 +126,7 @@ def translate(self, text):
messages=[
{
"role": "user",
"content": f"Please help me to translate,`{text}` to {self.language}, please return only translated content not include the origin text",
"content": f"I want you to act as an {self.language} translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in {self.language}. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level {self.language} words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations, the text is: \n\n{text}",
}
],
)
Expand Down