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:
|
if request.options and request.options.operationType == OperationTypeEnum.SPEECH_TEAMS:
|
||||||
return await self._handleSpeechTeams(request)
|
return await self._handleSpeechTeams(request)
|
||||||
|
|
||||||
# FAIL-SAFE: Pre-flight billing validation (like 0 CHF credit card check)
|
_opType = request.options.operationType if request.options else None
|
||||||
self._preflightBillingCheck()
|
_isNeutralizationCall = _opType in (
|
||||||
|
OperationTypeEnum.NEUTRALIZATION_TEXT,
|
||||||
|
OperationTypeEnum.NEUTRALIZATION_IMAGE,
|
||||||
|
)
|
||||||
|
|
||||||
# Balance & provider permission checks
|
if not _isNeutralizationCall:
|
||||||
await self._checkBillingBeforeAiCall()
|
# 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
|
# Calculate effective allowedProviders: RBAC ∩ Workflow
|
||||||
effectiveProviders = self._calculateEffectiveProviders()
|
effectiveProviders = self._calculateEffectiveProviders()
|
||||||
|
|
@ -218,8 +235,15 @@ class AiService:
|
||||||
Rehydration happens on the final AiCallResponse (not on individual str deltas).
|
Rehydration happens on the final AiCallResponse (not on individual str deltas).
|
||||||
"""
|
"""
|
||||||
await self.ensureAiObjectsInitialized()
|
await self.ensureAiObjectsInitialized()
|
||||||
self._preflightBillingCheck()
|
|
||||||
await self._checkBillingBeforeAiCall()
|
_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()
|
||||||
|
|
||||||
effectiveProviders = self._calculateEffectiveProviders()
|
effectiveProviders = self._calculateEffectiveProviders()
|
||||||
if effectiveProviders and request.options:
|
if effectiveProviders and request.options:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue