mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-22 07:04:59 +01:00
drop deepl api
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
import deepl
|
import requests
|
||||||
|
|
||||||
from .plugin import Plugin
|
from .plugin import Plugin
|
||||||
|
|
||||||
@@ -35,6 +35,13 @@ class DeeplTranslatePlugin(Plugin):
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
async def execute(self, function_name, **kwargs) -> Dict:
|
async def execute(self, function_name, **kwargs) -> Dict:
|
||||||
translator = deepl.Translator(self.api_key)
|
translator = requests.get(
|
||||||
answer = translator.translate_text(kwargs['text'], target_lang=kwargs['to_language'])
|
"https://api.deepl.com/v2/translate",
|
||||||
return answer.text
|
params={
|
||||||
|
"auth_key": self.api_key,
|
||||||
|
"target_lang": kwargs['to_language'],
|
||||||
|
"text": kwargs['text'],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
translated_text = translator.json()["translations"][0]["text"]
|
||||||
|
return translated_text
|
||||||
|
|||||||
@@ -8,4 +8,3 @@ tenacity==8.2.2
|
|||||||
wolframalpha==5.0.0
|
wolframalpha==5.0.0
|
||||||
duckduckgo_search==3.8.3
|
duckduckgo_search==3.8.3
|
||||||
spotipy==2.23.0
|
spotipy==2.23.0
|
||||||
deepl>=1.15.0
|
|
||||||
Reference in New Issue
Block a user