Constraints
openai_model_registry.constraints
¶
Parameter constraints for the model registry.
This module defines the constraint types used to validate parameters for model calls.
Classes¶
EnumConstraint
¶
Constraint for enumerated parameters.
Source code in src/openai_model_registry/constraints.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
Functions¶
__init__(allowed_values, description='')
¶
Initialize enum constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allowed_values
|
List[str]
|
List of allowed string values |
required |
description
|
str
|
Description of the parameter |
''
|
Source code in src/openai_model_registry/constraints.py
109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
validate(name, value)
¶
Validate a value against this constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Parameter name for error messages |
required |
value
|
Any
|
Value to validate |
required |
Raises:
Type | Description |
---|---|
ModelRegistryError
|
If validation fails |
Source code in src/openai_model_registry/constraints.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
NumericConstraint
¶
Constraint for numeric parameters.
Source code in src/openai_model_registry/constraints.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
Functions¶
__init__(min_value=0.0, max_value=None, allow_float=True, allow_int=True, description='')
¶
Initialize numeric constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_value
|
float
|
Minimum allowed value |
0.0
|
max_value
|
Optional[float]
|
Maximum allowed value, or None for no upper limit |
None
|
allow_float
|
bool
|
Whether floating point values are allowed |
True
|
allow_int
|
bool
|
Whether integer values are allowed |
True
|
description
|
str
|
Description of the parameter |
''
|
Source code in src/openai_model_registry/constraints.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
validate(name, value)
¶
Validate a value against this constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Parameter name for error messages |
required |
value
|
Any
|
Value to validate |
required |
Raises:
Type | Description |
---|---|
ModelRegistryError
|
If validation fails |
Source code in src/openai_model_registry/constraints.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
ObjectConstraint
¶
Constraint for object/dictionary parameters.
Source code in src/openai_model_registry/constraints.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
Functions¶
__init__(description='', required_keys=None, allowed_keys=None)
¶
Initialize object constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description
|
str
|
Description of the parameter |
''
|
required_keys
|
Optional[List[str]]
|
List of required keys in the object |
None
|
allowed_keys
|
Optional[List[str]]
|
List of allowed keys (if None, any keys are allowed) |
None
|
Source code in src/openai_model_registry/constraints.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
validate(name, value)
¶
Validate a value against this constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Parameter name for error messages |
required |
value
|
Any
|
Value to validate |
required |
Raises:
Type | Description |
---|---|
ModelRegistryError
|
If validation fails |
Source code in src/openai_model_registry/constraints.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
ParameterReference
dataclass
¶
Reference to a parameter constraint with optional metadata.
Source code in src/openai_model_registry/constraints.py
17 18 19 20 21 22 23 |
|