drop deepl api

This commit is contained in:
Bacer
2023-07-03 00:05:34 +03:00
parent 6d32ae916c
commit 694d81563d
2 changed files with 12 additions and 6 deletions

View File

@@ -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

View File

@@ -7,5 +7,4 @@ requests~=2.31.0
tenacity==8.2.2 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