Vitalis_Core / vitalis /flags.py
FerrellSyntheticIntelligence
Restructure as bolt-on cognitive framework
454a778
Raw
History Blame Contribute Delete
732 Bytes
from typing import Optional
from .config import EXPERIMENTAL_CONFIDENCE_THRESHOLD, FLAGS_ENABLED
EXPERIMENTAL_PREFIX = "[EXPERIMENTAL]"
UNCERTAIN_PREFIX = "[UNCERTAIN]"
def flag_response(response: str, confidence: float, is_experimental_code: bool = False) -> str:
if not FLAGS_ENABLED:
return response
prefix = ""
if is_experimental_code:
prefix = EXPERIMENTAL_PREFIX
elif confidence < EXPERIMENTAL_CONFIDENCE_THRESHOLD:
prefix = UNCERTAIN_PREFIX
if prefix and not response.startswith(prefix):
return f"{prefix} {response}"
return response
def is_flagged(response: str) -> bool:
return response.startswith(EXPERIMENTAL_PREFIX) or response.startswith(UNCERTAIN_PREFIX)