refactor: 文档维护点收归mipu-api,新增SDK
- 移除 docs/ 和 Release CI,文档维护点收归 mipu-api 子模块 - 新增 sdk/mipu_requests Python SDK(构造参数传入凭据) - 新增 CLAUDE.md 标注文档维护路径 - 精简 README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
33
sdk/mipu_requests/exceptions.py
Normal file
33
sdk/mipu_requests/exceptions.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""mipu_requests 异常类 — 兼容 requests 异常命名"""
|
||||
|
||||
|
||||
class RequestException(Exception):
|
||||
"""基异常(对应 requests.exceptions.RequestException)"""
|
||||
pass
|
||||
|
||||
|
||||
class APIError(RequestException):
|
||||
"""Bluebird API 返回非零 code"""
|
||||
|
||||
def __init__(self, response):
|
||||
self.response = response
|
||||
code = response.get("code", "?") if isinstance(response, dict) else "?"
|
||||
msg = response.get("msg", "") if isinstance(response, dict) else str(response)
|
||||
super().__init__(f"API error: code={code}, msg={msg}")
|
||||
|
||||
|
||||
class HTTPError(RequestException):
|
||||
"""目标网站返回 HTTP 错误状态码(对应 requests.exceptions.HTTPError)"""
|
||||
|
||||
def __init__(self, response):
|
||||
self.response = response
|
||||
super().__init__(f"{response.status_code} for {response.url}")
|
||||
|
||||
|
||||
class PollTimeoutError(RequestException):
|
||||
"""异步轮询超时"""
|
||||
|
||||
def __init__(self, agent_request_id, max_attempts=0):
|
||||
self.agent_request_id = agent_request_id
|
||||
self.max_attempts = max_attempts
|
||||
super().__init__(f"Poll timeout after {max_attempts} attempts for {agent_request_id}")
|
||||
Reference in New Issue
Block a user