feat(provider): 添加API密钥加密存储

This commit is contained in:
2026-08-30 10:56:57 +08:00
parent 0842413d29
commit 0836807aa2
10 changed files with 455 additions and 5 deletions
+8 -2
View File
@@ -14,7 +14,7 @@ from app.contracts import (
ModelRequest,
)
from app.providers.base import ProviderError, ProviderToolCall, ProviderTurn
from app.providers.credentials import CredentialResolver
from app.providers.credentials import CredentialResolver, CredentialStoreError
from app.providers.http_base import TurnStreamingMixin, decode_tool_arguments
@@ -263,7 +263,13 @@ class OpenAICompatibleProvider(TurnStreamingMixin):
def _headers(self) -> dict[str, str]:
headers = {"Content-Type": "application/json"}
api_key = self.credentials.resolve(self.credential_id)
try:
api_key = self.credentials.resolve(self.credential_id)
except CredentialStoreError as exc:
raise ProviderError(
"PROVIDER_CREDENTIAL_UNAVAILABLE",
"Credential could not be decrypted by the AI Core.",
) from exc
if self.credential_id and not api_key:
raise ProviderError(
"PROVIDER_CREDENTIAL_MISSING",