added neutralization option to indexing new connections
This commit is contained in:
parent
93cb6939dc
commit
4a840e9e6e
1 changed files with 32 additions and 8 deletions
|
|
@ -165,11 +165,28 @@ class AiService:
|
|||
if request.options and request.options.operationType == OperationTypeEnum.SPEECH_TEAMS:
|
||||
return await self._handleSpeechTeams(request)
|
||||
|
||||
_opType = request.options.operationType if request.options else None
|
||||
_isNeutralizationCall = _opType in (
|
||||
OperationTypeEnum.NEUTRALIZATION_TEXT,
|
||||
OperationTypeEnum.NEUTRALIZATION_IMAGE,
|
||||
)
|
||||
|
||||
if not _isNeutralizationCall:
|
||||
# FAIL-SAFE: Pre-flight billing validation (like 0 CHF credit card check)
|
||||
self._preflightBillingCheck()
|
||||
|
||||
# Balance & provider permission checks
|
||||
await self._checkBillingBeforeAiCall()
|
||||
else:
|
||||
# Neutralization calls are system-level operations (connector anonymization).
|
||||
# They run without a mandate context (e.g. personal-scope connections) and
|
||||
# are billed the same way as embedding calls: best-effort, skipped when no
|
||||
# billing settings exist for an empty mandate.
|
||||
logger.debug(
|
||||
"callAi: skipping billing preflight for neutralization call "
|
||||
"(operationType=%s, user=%s)",
|
||||
_opType,
|
||||
getattr(getattr(self.services, 'user', None), 'id', 'unknown'),
|
||||
)
|
||||
|
||||
# Calculate effective allowedProviders: RBAC ∩ Workflow
|
||||
effectiveProviders = self._calculateEffectiveProviders()
|
||||
|
|
@ -218,6 +235,13 @@ class AiService:
|
|||
Rehydration happens on the final AiCallResponse (not on individual str deltas).
|
||||
"""
|
||||
await self.ensureAiObjectsInitialized()
|
||||
|
||||
_streamOpType = request.options.operationType if request.options else None
|
||||
_isNeutralizationStream = _streamOpType in (
|
||||
OperationTypeEnum.NEUTRALIZATION_TEXT,
|
||||
OperationTypeEnum.NEUTRALIZATION_IMAGE,
|
||||
)
|
||||
if not _isNeutralizationStream:
|
||||
self._preflightBillingCheck()
|
||||
await self._checkBillingBeforeAiCall()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue