关闭ssl认证

This commit is contained in:
xunbu
2025-05-31 23:31:34 +08:00
parent ff2d215cfa
commit c92a62d7b8
3 changed files with 9 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
__version__="0.2.32" __version__="0.2.33"

View File

@@ -43,8 +43,8 @@ class Agent:
self.model_id = model_id.strip() self.model_id = model_id.strip()
self.system_prompt = system_prompt self.system_prompt = system_prompt
self.temperature = temperature self.temperature = temperature
self.client = httpx.Client() self.client = httpx.Client(trust_env=False,proxy=None,verify=False)
self.client_async = httpx.AsyncClient() self.client_async = httpx.AsyncClient(trust_env=False,proxy=None,verify=False)
self.max_concurrent = max_concurrent self.max_concurrent = max_concurrent
self.timeout = timeout self.timeout = timeout
def _prepare_request_data(self, prompt: str, system_prompt: str, temperature=None, top_p=0.9): def _prepare_request_data(self, prompt: str, system_prompt: str, temperature=None, top_p=0.9):

View File

@@ -16,7 +16,7 @@ timeout = httpx.Timeout(
) )
client = httpx.Client(trust_env=False,timeout=timeout) client = httpx.Client(trust_env=False,timeout=timeout,proxy=None,verify=False)
# TODO: 提供更详细的logger # TODO: 提供更详细的logger
@@ -124,24 +124,17 @@ def get_md_from_zip_url_with_inline_images(
except httpx.HTTPStatusError as e: except httpx.HTTPStatusError as e:
print(f"HTTP 错误 (httpx): {e.response.status_code} - {e.request.url}") raise Exception(f"HTTP 错误 (httpx): {e.response.status_code} - {e.request.url}\n响应内容: {e.response.text[:200]}...")
print(f"响应内容: {e.response.text[:200]}...")
return None
except httpx.RequestError as e: except httpx.RequestError as e:
print(f"下载ZIP文件时发生错误 (httpx): {e}") raise Exception(f"下载ZIP文件时发生错误 (httpx): {e}")
return None
except zipfile.BadZipFile: except zipfile.BadZipFile:
print("错误: 下载的文件不是一个有效的ZIP压缩文件或已损坏。") raise Exception("错误: 下载的文件不是一个有效的ZIP压缩文件或已损坏。")
return None
except UnicodeDecodeError: except UnicodeDecodeError:
print(f"错误: 无法使用 '{encoding}' 编码解码文件 '{filename_in_zip}' 的内容。") raise Exception(f"错误: 无法使用 '{encoding}' 编码解码文件 '{filename_in_zip}' 的内容。")
print("请尝试其他编码,如 'gbk', 'latin1' 等,或确认文件本身的编码。")
return None
except Exception as e: except Exception as e:
print(f"发生未知错误: {e}")
import traceback import traceback
traceback.print_exc() # 打印完整的堆栈跟踪,便于调试 traceback.print_exc() # 打印完整的堆栈跟踪,便于调试
return None raise Exception(f"发生未知错误: {e}")
if __name__ == '__main__': if __name__ == '__main__':