mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add default URL for Lingva translator
This commit is contained in:
@ -11,6 +11,7 @@ import { jsonParser } from '../express-common.js';
|
||||
|
||||
const DEEPLX_URL_DEFAULT = 'http://127.0.0.1:1188/translate';
|
||||
const ONERING_URL_DEFAULT = 'http://127.0.0.1:4990/translate';
|
||||
const LINGVA_DEFAULT = 'https://lingva.ml/api/v1';
|
||||
|
||||
export const router = express.Router();
|
||||
|
||||
@ -189,7 +190,12 @@ router.post('/yandex', jsonParser, async (request, response) => {
|
||||
|
||||
router.post('/lingva', jsonParser, async (request, response) => {
|
||||
try {
|
||||
const baseUrl = readSecret(request.user.directories, SECRET_KEYS.LINGVA_URL);
|
||||
const secretUrl = readSecret(request.user.directories, SECRET_KEYS.LINGVA_URL);
|
||||
const baseUrl = secretUrl || LINGVA_DEFAULT;
|
||||
|
||||
if (!secretUrl && baseUrl === ONERING_URL_DEFAULT) {
|
||||
console.log('Lingva URL is using default value.', LINGVA_DEFAULT);
|
||||
}
|
||||
|
||||
if (!baseUrl) {
|
||||
console.log('Lingva URL is not configured.');
|
||||
@ -307,6 +313,10 @@ router.post('/onering', jsonParser, async (request, response) => {
|
||||
console.log('OneRing URL is using default value.', ONERING_URL_DEFAULT);
|
||||
}
|
||||
|
||||
if (request.body.lang === 'pt-BR' || request.body.lang === 'pt-PT') {
|
||||
request.body.lang = 'pt';
|
||||
}
|
||||
|
||||
const text = request.body.text;
|
||||
const from_lang = request.body.from_lang;
|
||||
const to_lang = request.body.to_lang;
|
||||
|
Reference in New Issue
Block a user