MCPcopy Create free account
hub / github.com/openai/openai-python / add_request_id

Function add_request_id

src/openai/_models.py:854–866  ·  view source on GitHub ↗
(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 # in Pydantic v1, using setattr like we do above causes the attribute
858 # to be included when serializing the model which we don't want in this
859 # case so we need to explicitly exclude it
860 if PYDANTIC_V1:
861 try:
862 exclude_fields = obj.__exclude_fields__ # type: ignore
863 except AttributeError:
864 cast(Any, obj).__exclude_fields__ = {"_request_id", "__exclude_fields__"}
865 else:
866 cast(Any, obj).__exclude_fields__ = {*(exclude_fields or {}), "_request_id", "__exclude_fields__"}
867
868
869# 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