12.5
This commit is contained in:
parent
a81c6c3d61
commit
6bb7d334d9
@ -97,23 +97,26 @@ def qianwen_long(file_id, user_query, max_retries=2, backoff_factor=1.0):
|
|||||||
error_code, error_code_string = extract_error_details(str(exc))
|
error_code, error_code_string = extract_error_details(str(exc))
|
||||||
print(f"第 {attempt} 次尝试失败,查询:'{user_query}',错误:{exc}")
|
print(f"第 {attempt} 次尝试失败,查询:'{user_query}',错误:{exc}")
|
||||||
|
|
||||||
if error_code == 429:
|
if error_code == 429: #超qps/qpm
|
||||||
if attempt <= max_retries:
|
if attempt <= max_retries:
|
||||||
sleep_time = backoff_factor * (2 ** (attempt - 1)) # 指数退避
|
sleep_time = backoff_factor * (2 ** (attempt - 1)) # 指数退避
|
||||||
print(f"错误代码为 429,将在 {sleep_time} 秒后重试...")
|
print(f"错误代码为 429,将在 {sleep_time} 秒后重试...")
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
else:
|
else:
|
||||||
print(f"查询 '{user_query}' 的所有 {max_retries + 1} 次尝试均失败(429 错误)。")
|
print(f"查询 '{user_query}' 的所有 {max_retries + 1} 次尝试均失败(429 错误)。")
|
||||||
|
break
|
||||||
elif error_code == 400 and error_code_string in ['data_inspection_failed', 'ResponseTimeout','DataInspectionFailed','response_timeout','request_timeout',"RequestTimeOut"]:
|
elif error_code == 400 and error_code_string in ['data_inspection_failed', 'ResponseTimeout','DataInspectionFailed','response_timeout','request_timeout',"RequestTimeOut"]:
|
||||||
if attempt == 1: # 只重试一次
|
if attempt == 1: # 只重试一次
|
||||||
print(f"错误代码为 400 - {error_code_string},将立即重试...")
|
print(f"错误代码为 400 - {error_code_string},将立即重试...")
|
||||||
continue # 直接跳到下一次循环(即重试一次)
|
continue # 直接跳到下一次循环(即重试一次)
|
||||||
else:
|
else:
|
||||||
print(f"查询 '{user_query}' 的所有 {max_retries + 1} 次尝试均失败(400 - {error_code_string})。")
|
print(f"查询 '{user_query}' 的所有 {max_retries + 1} 次尝试均失败(400 - {error_code_string})。")
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
# 对于非 429 和非特定 400 错误,不进行重试,直接抛出异常
|
# 对于非 429 和非特定 400 错误,不进行重试,直接抛出异常
|
||||||
print(f"遇到非 429 或非 'data_inspection_failed' 的 400 错误(错误代码:{error_code}),不进行重试。")
|
print(f"遇到非 429 或非 'data_inspection_failed' 的 400 错误(错误代码:{error_code}),不进行重试。")
|
||||||
|
break
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,9 +273,9 @@ def goods_bid_main(output_folder, file_path, file_type, unique_id):
|
|||||||
#TODO:把所有未知都删掉。
|
#TODO:把所有未知都删掉。
|
||||||
#TODO:考虑把解析失败的调用豆包,全文上传。
|
#TODO:考虑把解析失败的调用豆包,全文上传。
|
||||||
|
|
||||||
#TODO:同系统下的多个货物,记录一下数量
|
|
||||||
#TODO:设备前面带星,而不是要求前面带星。
|
|
||||||
#TODO:重置一下投标文件格式提取那部分的代码
|
#TODO:重置一下投标文件格式提取那部分的代码
|
||||||
|
#TODO:qianwenlong重试那边,改流式
|
||||||
|
#TODO:小解析考虑提速:1:直接pdf转文本,再切分 2.多线程读取每页是否有图片
|
||||||
#商务标这里改为列表最里层
|
#商务标这里改为列表最里层
|
||||||
#good_list 金额 截取上下文
|
#good_list 金额 截取上下文
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user