fix(gateway): 适配器瞬时错误消息脱敏——只留类名+状态码不泄漏厂商响应体(CR-M2-2)
This commit is contained in:
@@ -22,6 +22,7 @@ from .base import (
|
||||
ProviderUsage,
|
||||
StreamChunk,
|
||||
is_transient_by_name,
|
||||
provider_error_summary,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -131,7 +132,9 @@ class AnthropicAdapter:
|
||||
return await self._complete_text(req, model)
|
||||
except Exception as exc:
|
||||
if _is_transient(exc):
|
||||
raise TransientProviderError(str(exc), provider=self.provider) from exc
|
||||
raise TransientProviderError(
|
||||
provider_error_summary(exc), provider=self.provider
|
||||
) from exc
|
||||
raise
|
||||
|
||||
async def _complete_text(self, req: LlmRequest, model: str) -> ProviderResult:
|
||||
@@ -187,5 +190,7 @@ class AnthropicAdapter:
|
||||
yield StreamChunk(usage=_usage_from(usage))
|
||||
except Exception as exc:
|
||||
if _is_transient(exc):
|
||||
raise TransientProviderError(str(exc), provider=self.provider) from exc
|
||||
raise TransientProviderError(
|
||||
provider_error_summary(exc), provider=self.provider
|
||||
) from exc
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user