Model version
openai_model_registry.model_version
¶
Model version handling for OpenAI models.
This module provides utilities for parsing and comparing model versions in the format YYYY-MM-DD.
Classes¶
ModelVersion
¶
Represents a model version in YYYY-MM-DD format.
This class handles parsing, validation, and comparison of model version dates.
Attributes:
Name | Type | Description |
---|---|---|
year |
The year component of the version |
|
month |
The month component of the version |
|
day |
The day component of the version |
Source code in src/openai_model_registry/model_version.py
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 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 104 105 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 146 147 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 202 203 204 |
|
Functions¶
__eq__(other)
¶
Check if two versions are equal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
object
|
The other version to compare with |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if versions are equal, False otherwise |
Source code in src/openai_model_registry/model_version.py
37 38 39 40 41 42 43 44 45 46 47 48 |
|
__ge__(other)
¶
Check if this version is later than or equal to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
ModelVersion
|
The other version to compare with |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this version is later or equal, False otherwise |
Source code in src/openai_model_registry/model_version.py
87 88 89 90 91 92 93 94 95 96 |
|
__gt__(other)
¶
Check if this version is later than another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
ModelVersion
|
The other version to compare with |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this version is later, False otherwise |
Source code in src/openai_model_registry/model_version.py
76 77 78 79 80 81 82 83 84 85 |
|
__init__(year, month, day)
¶
Initialize a model version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year
|
int
|
The year component (e.g., 2024) |
required |
month
|
int
|
The month component (1-12) |
required |
day
|
int
|
The day component (1-31) |
required |
Source code in src/openai_model_registry/model_version.py
25 26 27 28 29 30 31 32 33 34 35 |
|
__le__(other)
¶
Check if this version is earlier than or equal to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
ModelVersion
|
The other version to compare with |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this version is earlier or equal, False otherwise |
Source code in src/openai_model_registry/model_version.py
65 66 67 68 69 70 71 72 73 74 |
|
__lt__(other)
¶
Check if this version is earlier than another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
ModelVersion
|
The other version to compare with |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this version is earlier, False otherwise |
Source code in src/openai_model_registry/model_version.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
__repr__()
¶
Get string representation of the version.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Version in YYYY-MM-DD format |
Source code in src/openai_model_registry/model_version.py
98 99 100 101 102 103 104 |
|
from_string(version_str)
classmethod
¶
Create a version from a string in YYYY-MM-DD format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_str
|
str
|
The version string to parse |
required |
Returns:
Type | Description |
---|---|
ModelVersion
|
A new ModelVersion instance |
Raises:
Type | Description |
---|---|
InvalidDateError
|
If the string is not a valid version |
Source code in src/openai_model_registry/model_version.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 146 147 148 149 150 151 152 153 154 155 |
|
is_dated_model(model_name)
staticmethod
¶
Check if a model name follows the dated model format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The model name to check |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the model name follows the dated format (with YYYY-MM-DD suffix) |
Source code in src/openai_model_registry/model_version.py
194 195 196 197 198 199 200 201 202 203 204 |
|
parse_from_model(model)
staticmethod
¶
Parse a model name into base name and version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
str
|
Full model name with version (e.g., "gpt-4o-2024-08-06") |
required |
Returns:
Name | Type | Description |
---|---|---|
str
|
Tuple of (base_name, version) |
|
Example |
ModelVersion
|
("gpt-4o", ModelVersion(2024, 8, 6)) |
Raises:
Type | Description |
---|---|
ModelFormatError
|
If the model name does not follow the expected format |
InvalidDateError
|
If the date part of the model name is invalid |
Source code in src/openai_model_registry/model_version.py
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 |
|