Skip to content

Commit

Permalink
fix: use self-deployed deeplx
Browse files Browse the repository at this point in the history
  • Loading branch information
7086cmd committed Jan 20, 2025
1 parent c758a1e commit 0aa7fdf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 124 deletions.
16 changes: 9 additions & 7 deletions routers/plugins_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from database import db
from pydantic import BaseModel
from PyDeepLX import PyDeepLX
from util.deepl import translate
import json
import requests

from util.object_id import compulsory_temporary_token, get_current_user, validate_object_id
Expand All @@ -22,11 +22,13 @@ def get_word_oxford(word: str):
}


class TranslateRequest(BaseModel):
text: str
target_lang: str


@router.get('/translate/deepl')
def translate_deepl(text: str, lang: str):
return translate(text, lang, 3)
data = {'text': text, 'target_lang': lang}
data = json.dumps(data)
result = requests.post(f'http://127.0.0.1:1188/translate', data=data).json()
return {
'status': 'ok',
'code': 200,
'data': result
}
117 changes: 0 additions & 117 deletions util/deepl.py

This file was deleted.

0 comments on commit 0aa7fdf

Please sign in to comment.