Errors
openai_model_registry.errors
¶
Error types for the OpenAI model registry.
This module defines the error types used by the model registry for various validation and compatibility issues.
Classes¶
ConfigFileNotFoundError
¶
Bases: ConfigurationError
Raised when a required configuration file is not found.
Examples:
>>> try:
... registry._load_config()
... except ConfigFileNotFoundError as e:
... print(f"Config file not found: {e.path}")
Source code in src/openai_model_registry/errors.py
38 39 40 41 42 43 44 45 46 47 48 |
|
ConfigurationError
¶
Bases: ModelRegistryError
Base class for configuration-related errors.
This is raised for errors related to configuration loading, parsing, or validation.
Source code in src/openai_model_registry/errors.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
Functions¶
__init__(message, path=None)
¶
Initialize configuration error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
path
|
Optional[str]
|
Optional path to the configuration file that caused the error |
None
|
Source code in src/openai_model_registry/errors.py
26 27 28 29 30 31 32 33 34 35 |
|
ConstraintNotFoundError
¶
Bases: ModelRegistryError
Raised when a constraint reference cannot be found.
Examples:
>>> try:
... registry.get_parameter_constraint("unknown.constraint")
... except ConstraintNotFoundError as e:
... print(f"Constraint not found: {e.ref}")
Source code in src/openai_model_registry/errors.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
Functions¶
__init__(message, ref)
¶
Initialize constraint not found error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
ref
|
str
|
The constraint reference that wasn't found |
required |
Source code in src/openai_model_registry/errors.py
263 264 265 266 267 268 269 270 271 272 |
|
ConstraintViolation
¶
Bases: ParameterValidationError
Raised when a parameter value violates a constraint.
Examples:
>>> try:
... registry.validate_parameter("temperature", 3.0, "gpt-4o")
... except ConstraintViolation as e:
... print(f"Constraint violated: {e.param} must {e.rule}")
Source code in src/openai_model_registry/errors.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
Functions¶
__init__(param, value, rule, provider=None, model=None)
¶
Initialize constraint violation error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param
|
str
|
Parameter name that violated the constraint |
required |
value
|
Any
|
The invalid value |
required |
rule
|
str
|
Description of the constraint rule |
required |
provider
|
Optional[str]
|
Provider name (optional) |
None
|
model
|
Optional[str]
|
Model name (optional) |
None
|
Source code in src/openai_model_registry/errors.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
InvalidConfigFormatError
¶
Bases: ConfigurationError
Raised when a configuration file has an invalid format.
Examples:
>>> try:
... registry._load_config()
... except InvalidConfigFormatError as e:
... print(f"Invalid config format: {e}")
Source code in src/openai_model_registry/errors.py
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 |
|
Functions¶
__init__(message, path=None, expected_type='dict')
¶
Initialize invalid format error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
path
|
Optional[str]
|
Optional path to the configuration file |
None
|
expected_type
|
str
|
Expected type of the configuration |
'dict'
|
Source code in src/openai_model_registry/errors.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
InvalidDateError
¶
Bases: ModelVersionError
Raised when a model version has an invalid date format.
Examples:
>>> try:
... ModelVersion.from_string("2024-13-01")
... except InvalidDateError as e:
... print(f"Date format error: {e}")
Source code in src/openai_model_registry/errors.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
Functions¶
__init__(message)
¶
Initialize invalid date error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message explaining the date format issue |
required |
Source code in src/openai_model_registry/errors.py
97 98 99 100 101 102 103 104 |
|
ModelFormatError
¶
Bases: ModelRegistryError
Raised when a model name has an invalid format.
Examples:
>>> try:
... ModelVersion.parse_from_model("invalid-model-name")
... except ModelFormatError as e:
... print(f"Invalid model format: {e.model}")
Source code in src/openai_model_registry/errors.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
Functions¶
__init__(message, model)
¶
Initialize model format error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
model
|
str
|
The invalid model name |
required |
Source code in src/openai_model_registry/errors.py
117 118 119 120 121 122 123 124 125 126 |
|
ModelNotSupportedError
¶
Bases: ModelRegistryError
Raised when a model is not supported by the registry.
This error indicates that the requested model is not in the registry of supported models. This is different from version-related errors, which indicate that the model exists but the specific version is invalid.
Examples:
>>> try:
... registry.get_capabilities("unsupported-model")
... except ModelNotSupportedError as e:
... print(f"Model {e.model} is not supported")
Source code in src/openai_model_registry/errors.py
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 202 203 204 205 206 207 208 209 |
|
Functions¶
__init__(message, model=None, available_models=None)
¶
Initialize model not supported error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
model
|
Optional[str]
|
The unsupported model name |
None
|
available_models
|
Optional[Union[List[str], Set[str], Dict[str, Any]]]
|
List of available models (optional) |
None
|
Source code in src/openai_model_registry/errors.py
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 |
|
__str__()
¶
Return string representation of the error.
Returns:
Type | Description |
---|---|
str
|
Error message |
Source code in src/openai_model_registry/errors.py
203 204 205 206 207 208 209 |
|
ModelRegistryError
¶
Bases: Exception
Base class for all registry-related errors.
This is the parent class for all registry-specific exceptions.
Source code in src/openai_model_registry/errors.py
10 11 12 13 14 15 16 |
|
ModelVersionError
¶
Bases: ModelRegistryError
Base class for version-related errors.
This is raised for any errors related to model versions.
Source code in src/openai_model_registry/errors.py
78 79 80 81 82 83 84 |
|
NetworkError
¶
Bases: ModelRegistryError
Raised when a network operation fails.
Examples:
>>> try:
... registry.refresh_from_remote()
... except NetworkError as e:
... print(f"Network error: {e}")
Source code in src/openai_model_registry/errors.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
|
Functions¶
__init__(message, url=None)
¶
Initialize network error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
url
|
Optional[str]
|
Optional URL that was being accessed |
None
|
Source code in src/openai_model_registry/errors.py
336 337 338 339 340 341 342 343 344 345 |
|
ParameterNotSupportedError
¶
Bases: ParameterValidationError
Raised when a parameter is not supported for a model.
Examples:
>>> try:
... capabilities.validate_parameter("unknown_param", "value")
... except ParameterNotSupportedError as e:
... print(f"Parameter {e.param_name} not supported for {e.model}")
Source code in src/openai_model_registry/errors.py
240 241 242 243 244 245 246 247 248 249 250 |
|
ParameterValidationError
¶
Bases: ModelRegistryError
Base class for parameter validation errors.
This is raised for errors related to parameter validation.
Source code in src/openai_model_registry/errors.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
Functions¶
__init__(message, param_name, value, model=None)
¶
Initialize parameter validation error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
param_name
|
str
|
The name of the parameter being validated |
required |
value
|
Any
|
The value that failed validation |
required |
model
|
Optional[str]
|
Optional model name for context |
None
|
Source code in src/openai_model_registry/errors.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
TokenParameterError
¶
Bases: ParameterValidationError
Raised when there's an issue with token-related parameters.
This error is used for issues with max_tokens, completion_tokens, etc.
Examples:
>>> try:
... capabilities.validate_parameter("max_completion_tokens", 100000)
... except TokenParameterError as e:
... print(f"Token error: {e}")
Source code in src/openai_model_registry/errors.py
311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
VersionTooOldError
¶
Bases: ModelVersionError
Raised when a model version is older than the minimum supported version.
Examples:
>>> try:
... registry.get_capabilities("gpt-4o-2024-07-01")
... except VersionTooOldError as e:
... print(f"Version error: {e}")
... print(f"Try using the alias: {e.alias}")
Source code in src/openai_model_registry/errors.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
Functions¶
__init__(message, model, min_version, alias=None)
¶
Initialize version too old error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Error message |
required |
model
|
str
|
The model that has a version too old |
required |
min_version
|
str
|
The minimum supported version |
required |
alias
|
Optional[str]
|
Suggested alias to use instead (if available) |
None
|
Source code in src/openai_model_registry/errors.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|