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

Function _async_transform_file

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

Source from the content-addressed store, hash-verified

105
106
107async def _async_transform_file(file: FileTypes) -> HttpxFileTypes:
108 if is_file_content(file):
109 if isinstance(file, os.PathLike):
110 path = anyio.Path(file)
111 return (path.name, await path.read_bytes())
112
113 return file
114
115 if is_tuple_t(file):
116 return (file[0], await async_read_file_content(file[1]), *file[2:])
117
118 raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
119
120
121async def async_read_file_content(file: FileContent) -> HttpxFileContent:

Callers 1

async_to_httpx_filesFunction · 0.85

Calls 3

is_file_contentFunction · 0.85
is_tuple_tFunction · 0.85
async_read_file_contentFunction · 0.85

Tested by

no test coverage detected