mirror of
https://github.com/artiemis/artemis.js.git
synced 2026-02-14 10:21:54 +00:00
log fallbacks
This commit is contained in:
parent
433df9364f
commit
3845df0ba3
@ -17,6 +17,7 @@ import { abort } from "../../utils/error";
|
|||||||
import type { OCRResult } from "../../types/ocr";
|
import type { OCRResult } from "../../types/ocr";
|
||||||
import { capitalize, languageCodeToName } from "../../utils/functions";
|
import { capitalize, languageCodeToName } from "../../utils/functions";
|
||||||
import { translate as translateGoogle } from "../../utils/gtrans";
|
import { translate as translateGoogle } from "../../utils/gtrans";
|
||||||
|
import { logger } from "../../utils/logger";
|
||||||
|
|
||||||
export async function translateAutocompleteImpl(
|
export async function translateAutocompleteImpl(
|
||||||
interaction: AutocompleteInteraction
|
interaction: AutocompleteInteraction
|
||||||
@ -49,7 +50,10 @@ export async function translateImpl(
|
|||||||
text,
|
text,
|
||||||
source,
|
source,
|
||||||
target
|
target
|
||||||
).catch(() => translateGoogle(text, "auto", "en"));
|
).catch(err => {
|
||||||
|
logger.error(err, "DeepL error, falling back to Google Translate");
|
||||||
|
return translateGoogle(text, "auto", "en");
|
||||||
|
});
|
||||||
|
|
||||||
if (translatedText.trim() === text.trim() && model === "deepl") {
|
if (translatedText.trim() === text.trim() && model === "deepl") {
|
||||||
const result = await translateGoogle(text, "auto", "en");
|
const result = await translateGoogle(text, "auto", "en");
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import {
|
|||||||
} from "../../utils/functions";
|
} from "../../utils/functions";
|
||||||
import { lensOcr } from "../../utils/lens";
|
import { lensOcr } from "../../utils/lens";
|
||||||
import type { OCRResult } from "../../types/ocr";
|
import type { OCRResult } from "../../types/ocr";
|
||||||
|
import { logger } from "../../utils/logger";
|
||||||
|
|
||||||
export function buildOcrPayload(
|
export function buildOcrPayload(
|
||||||
text: string,
|
text: string,
|
||||||
@ -85,7 +86,10 @@ export async function ocrImpl(url: string) {
|
|||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
const result = await lensOcr(compressed)
|
const result = await lensOcr(compressed)
|
||||||
.catch(() => yandexOcr(compressed, type.mime))
|
.catch(err => {
|
||||||
|
logger.error(err, "Google Lens error, falling back to Yandex");
|
||||||
|
return yandexOcr(compressed, type.mime);
|
||||||
|
})
|
||||||
.catch(() => abort("Failed to OCR the image"));
|
.catch(() => abort("Failed to OCR the image"));
|
||||||
|
|
||||||
if (!result.text) {
|
if (!result.text) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user