From ad148571f4983c6817e0c188da5c41a8fb5b8aeb Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 29 Jan 2023 14:55:24 -0300 Subject: [PATCH] Add fixed Google Translation extension --- extensions/google_translate/requirements.txt | 1 + extensions/google_translate/script.py | 29 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 extensions/google_translate/requirements.txt create mode 100644 extensions/google_translate/script.py diff --git a/extensions/google_translate/requirements.txt b/extensions/google_translate/requirements.txt new file mode 100644 index 00000000..554a00df --- /dev/null +++ b/extensions/google_translate/requirements.txt @@ -0,0 +1 @@ +deep-translator==1.9.2 diff --git a/extensions/google_translate/script.py b/extensions/google_translate/script.py new file mode 100644 index 00000000..064a7ec7 --- /dev/null +++ b/extensions/google_translate/script.py @@ -0,0 +1,29 @@ +from deep_translator import GoogleTranslator + +params = { + "language string": "ja", +} + +def input_modifier(string): + """ + This function is applied to your text inputs before + they are fed into the model. + """ + + return GoogleTranslator(source=params['language string'], target='en').translate(string) + +def output_modifier(string): + """ + This function is applied to the model outputs. + """ + + return GoogleTranslator(source='en', target=params['language string']).translate(string) + +def bot_prefix_modifier(string): + """ + This function is only applied in chat mode. It modifies + the prefix text for the Bot and can be used to bias its + behavior. + """ + + return string