File size: 695 Bytes
883a747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Adapter for the separately installed official Decision Index kit."""

from decision_index.engines import Engine, Unsupported

from model import DecisionModel


class ModelEngine(Engine):
    name = "decision-4b-preview"

    def __init__(self, **options):
        super().__init__(**options)
        self.model = DecisionModel(options.get("folder"))

    def __call__(self, state, questions):
        try:
            response = self.model.decide({"state": state, "questions": questions})
        except ValueError as error:
            if "complete input exceeds limit" in str(error):
                raise Unsupported(str(error)) from error
            raise
        return response, None