一些agent请求错误直接抛出异常,增大了块大小
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user