diff --git a/docutranslate/agents/agent.py b/docutranslate/agents/agent.py index 9d36f2a..9bc0ffd 100644 --- a/docutranslate/agents/agent.py +++ b/docutranslate/agents/agent.py @@ -107,12 +107,11 @@ class Agent: result = response.json()["choices"][0]["message"]["content"] return result except httpx.HTTPStatusError as e: - translater_logger.error(f"AI请求错误 (async): {e.response.status_code} - {e.response.text}") + raise Exception(f"AI请求错误 (async): {e.response.status_code} - {e.response.text}") except httpx.RequestError as e: - translater_logger.warning(Exception(f"AI请求连接错误 (async): {repr(e)}")) + translater_logger.warning(f"AI请求连接错误 (async): {repr(e)}") except (KeyError, IndexError) as e: - translater_logger.error(f"AI响应格式错误 (async): {repr(e)}") - return "" + raise Exception(f"AI响应格式错误 (async): {repr(e)}") # 如果没有正常获取结果则重试 if retry and retry_count < MAX_RETRY_COUNT: if total_retry_counter.add(): @@ -173,12 +172,11 @@ class Agent: result = response.json()["choices"][0]["message"]["content"] return result except httpx.HTTPStatusError as e: - translater_logger.error(f"AI请求错误 (sync): {e.response.status_code} - {e.response.text}") + raise Exception(f"AI请求错误 (sync): {e.response.status_code} - {e.response.text}") except httpx.RequestError as e: translater_logger.warning(f"AI请求连接错误 (sync): {repr(e)}\nprompt:{prompt}") except (KeyError, IndexError) as e: - translater_logger.error(f"AI响应格式错误 (sync): {repr(e)}") - return "" + raise Exception(f"AI响应格式错误 (sync): {repr(e)}") # 如果没有正常获取结果则重试 if retry and retry_count < MAX_RETRY_COUNT: if total_retry_counter.add(): diff --git a/docutranslate/translater.py b/docutranslate/translater.py index bcedb49..3836126 100644 --- a/docutranslate/translater.py +++ b/docutranslate/translater.py @@ -20,7 +20,7 @@ if DOCLING_FLAG: class FileTranslater: - def __init__(self, file_path: Path | str | None = None, chunksize: int = 2000, + def __init__(self, file_path: Path | str | None = None, chunksize: int = 3000, base_url="", key=None, model_id="", temperature=0.7, max_concurrent=30, timeout=2000, convert_engin: Literal["docling", "mineru"] = "mineru",