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

Function _transform_file

src/openai/_files.py:65–76  ·  view source on GitHub ↗
(file: FileTypes)

Source from the content-addressed store, hash-verified

63
64
65def _transform_file(file: FileTypes) -> HttpxFileTypes:
66 if is_file_content(file):
67 if isinstance(file, os.PathLike):
68 path = pathlib.Path(file)
69 return (path.name, path.read_bytes())
70
71 return file
72
73 if is_tuple_t(file):
74 return (file[0], read_file_content(file[1]), *file[2:])
75
76 raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
77
78
79def read_file_content(file: FileContent) -> HttpxFileContent:

Callers 1

to_httpx_filesFunction · 0.85

Calls 3

is_file_contentFunction · 0.85
is_tuple_tFunction · 0.85
read_file_contentFunction · 0.85

Tested by

no test coverage detected