1+ import json
12from dataclasses import dataclass
2- from typing import List , Optional
3+ from typing import List , Optional , Union
34
45from mindee .input .polling_options import PollingOptions
56
67
8+ class DataSchema :
9+ """Modify the Data Schema."""
10+
11+ _replace : Optional [dict ] = None
12+
13+ def __init__ (self , replace : Optional [dict ] = None ):
14+ self ._replace = replace
15+
16+ @property
17+ def replace (self ):
18+ """If set, completely replaces the data schema of the model."""
19+ return self ._replace
20+
21+ @replace .setter
22+ def replace (self , value : Optional [Union [dict , str ]]) -> None :
23+ if value is None :
24+ _replace = None
25+ elif isinstance (value , str ):
26+ _replace = json .loads (value )
27+ elif isinstance (value , dict ):
28+ _replace = value
29+ else :
30+ raise TypeError ("Invalid type for data schema" )
31+ if _replace is not None and _replace == {}:
32+ raise ValueError ("Empty override provided" )
33+ self ._replace = _replace
34+
35+ def __str__ (self ) -> str :
36+ return json .dumps ({"replace" : self .replace })
37+
38+
739@dataclass
840class InferenceParameters :
941 """Inference parameters to set when sending a file."""
@@ -30,4 +62,12 @@ class InferenceParameters:
3062 close_file : bool = True
3163 """Whether to close the file after parsing."""
3264 text_context : Optional [str ] = None
33- """Additional text context used by the model during inference. Not recommended, for specific use only."""
65+ """
66+ Additional text context used by the model during inference.
67+ Not recommended, for specific use only.
68+ """
69+ data_schema : Optional [DataSchema ] = None
70+ """
71+ Dynamic changes to the data schema of the model for this inference.
72+ Not recommended, for specific use only.
73+ """
0 commit comments