MCPcopy
hub / github.com/openai/openai-python / add_request_id

Function add_request_id

src/openai/_models.py:854–866  ·  src/openai/_models.py::add_request_id
(obj: BaseModel, request_id: str | None)

Source from the content-addressed store, hash-verified

852
853
854def add_request_id(obj: BaseModel, request_id: str | None) -> None:
855 obj._request_id = request_id
856
857 class="cm"># in Pydantic v1, using setattr like we do above causes the attribute
858 class="cm"># to be included when serializing the model which we don't want in this
859 class="cm"># case so we need to explicitly exclude it
860 if PYDANTIC_V1:
861 try:
862 exclude_fields = obj.__exclude_fields__ class="cm"># type: ignore
863 except AttributeError:
864 cast(Any, obj).__exclude_fields__ = {class="st">"_request_id", class="st">"__exclude_fields__"}
865 else:
866 cast(Any, obj).__exclude_fields__ = {*(exclude_fields or {}), class="st">"_request_id", class="st">"__exclude_fields__"}
867
868
869class="cm"># our use of subclassing here causes weirdness for type checkers,

Callers 3

parseMethod · 0.85
parseMethod · 0.85
parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected