Repository navigation
Expand file tree
/
Copy pathmodels.py
More file actions
77 lines (63 loc) · 1.97 KB
/
Copy pathmodels.py
File metadata and controls
77 lines (63 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
from typing import Any
from pydantic import BaseModel
from config import CODEX_MODELS
MODEL_METADATA: dict[str, dict[str, Any]] = {
"gpt-5.5": {
"context_window": 272_000,
"max_output_tokens": 128_000,
"reasoning": True,
"input_modalities": ["text", "image"],
},
"gpt-5.4": {
"context_window": 1_050_000,
"max_output_tokens": 128_000,
"reasoning": True,
"input_modalities": ["text", "image"],
},
"gpt-5.4-mini": {
"context_window": 400_000,
"max_output_tokens": 128_000,
"reasoning": True,
"input_modalities": ["text", "image"],
},
"gpt-5.3-codex": {
"context_window": 272_000,
"max_output_tokens": 128_000,
"reasoning": True,
"input_modalities": ["text", "image"],
},
"gpt-5.3-codex-spark": {
"context_window": 128_000,
"max_output_tokens": 128_000,
"reasoning": True,
"input_modalities": ["text"],
},
"gpt-image-2": {
"reasoning": False,
"input_modalities": ["text", "image"],
},
}
class ModelInfo(BaseModel):
id: str
object: str = "model"
created: int = 1700000000
owned_by: str = "openai"
permission: list[Any] = []
root: str = ""
parent: str | None = None
context_window: int | None = None
max_output_tokens: int | None = None
reasoning: bool | None = None
input_modalities: list[str] | None = None
class ModelListResponse(BaseModel):
object: str = "list"
data: list[ModelInfo]
def _build_model_info(model_id: str) -> ModelInfo:
return ModelInfo(id=model_id, root=model_id, **MODEL_METADATA.get(model_id, {}))
def get_model_list() -> ModelListResponse:
models = [_build_model_info(model_id) for model_id in CODEX_MODELS]
return ModelListResponse(data=models)
def get_model_info(model_id: str) -> ModelInfo | None:
if model_id in CODEX_MODELS:
return _build_model_info(model_id)
return None