File size: 1,322 Bytes
a0f56b7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | """Optional Decision Index integration."""
try:
from decision_index.engines.base import Engine, NativeAbstention, Unsupported
except ModuleNotFoundError as exc:
if exc.name not in ("decision_index", "decision_index.engines", "decision_index.engines.base"):
raise
class Unsupported(ValueError):
pass
class NativeAbstention(Exception):
def __init__(self, raw):
self.raw = raw
super().__init__("Native model selected its additional abstention outcome")
class Engine:
name = "engine"
provenance = {}
latency = "In-process request wall time including prompt construction; excludes model loading."
def __init__(self, **options):
self.options = options
def __call__(self, state, questions):
raise NotImplementedError
def warmup(self):
warm = {"warmup": {"type": "choice", "instructions": "Which color is named?", "criteria": {"red": "red", "blue": "blue"}}}
for _ in range(2):
try:
self("The color is red.", warm)
except NativeAbstention:
pass
def runtime(self):
return {}
def synchronize(self):
pass
def close(self):
pass
|