回退httpx版本,优化提示词(有关表格),修复了ai报错过多时卡死的问题
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
__version__="0.2.41"
|
||||
__version__="0.2.42"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,9 +32,7 @@ class TotalErrorCounter:
|
||||
self.count += 1
|
||||
if self.count>MAX_TOTAL_ERROR_COUNT:
|
||||
translater_logger.info(f"错误响应过多")
|
||||
raise Exception("错误响应过多")
|
||||
self.lock.release()
|
||||
|
||||
return self.reach_limit()
|
||||
|
||||
def reach_limit(self):
|
||||
@@ -89,7 +87,7 @@ class Agent:
|
||||
{"role": "user", "content": prompt}
|
||||
],
|
||||
"temperature": temperature,
|
||||
"top_p": top_p
|
||||
"top_p": top_p,
|
||||
}
|
||||
return headers, data
|
||||
|
||||
@@ -121,7 +119,8 @@ class Agent:
|
||||
raise Exception(f"AI响应格式错误 (async): {repr(e)}")
|
||||
# 如果没有正常获取结果则重试
|
||||
if retry and retry_count < MAX_RETRY_COUNT:
|
||||
total_error_counter.add()
|
||||
if total_error_counter.add():
|
||||
return prompt
|
||||
translater_logger.info(f"正在重试,重试次数{retry_count}")
|
||||
await asyncio.sleep(0.5)
|
||||
return await self.send_async(prompt, system_prompt, retry=True, retry_count=retry_count + 1)
|
||||
@@ -187,12 +186,13 @@ class Agent:
|
||||
raise Exception(f"AI响应格式错误 (sync): {repr(e)}")
|
||||
# 如果没有正常获取结果则重试
|
||||
if retry and retry_count < MAX_RETRY_COUNT:
|
||||
total_error_counter.add()
|
||||
if total_error_counter.add():
|
||||
return prompt
|
||||
translater_logger.info(f"正在重试,重试次数{retry_count}")
|
||||
time.sleep(0.5)
|
||||
return self.send(prompt, system_prompt, retry=True, retry_count=retry_count + 1)
|
||||
else:
|
||||
translater_logger.error(f"达到重试次数上限,返回空行")
|
||||
translater_logger.error(f"达到重试次数上限")
|
||||
return prompt
|
||||
|
||||
def _send_prompt_count(self, prompt: str, system_prompt: None | str, count: PromptsCounter) -> str:
|
||||
|
||||
@@ -57,6 +57,7 @@ class MDTranslateAgent(Agent):
|
||||
不能改变形如<ph-xxxxxx>的占位符
|
||||
code、latex和HTML只翻译说明文字,其余保持原文
|
||||
公式无论长短必须表示为能被解析的合法latex公式,公式需被$或\\(\\)或$$正确包裹,如不正确则进行修正
|
||||
表格如果是table标签请改为普通表格写法,注意表格正确性
|
||||
去除、修正明显异常的字符、但不能改变原意
|
||||
引用参考文献时请严格保持原文,不要翻译。参考文献格式示例如下:
|
||||
[1] Author A, Author B. "Original Title". Journal, 2023.
|
||||
|
||||
Reference in New Issue
Block a user