Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/anthropic/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes:
return file

if is_tuple_t(file):
return (file[0], read_file_content(file[1]), *file[2:])
if len(file) > 1:
return (file[0], read_file_content(file[1]), *file[2:])
return (None, read_file_content(file[0]))

raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")

Expand Down Expand Up @@ -111,7 +113,9 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes:
return file

if is_tuple_t(file):
return (file[0], await async_read_file_content(file[1]), *file[2:])
if len(file) > 1:
return (file[0], await async_read_file_content(file[1]), *file[2:])
return (None, await async_read_file_content(file[0]))

raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")

Expand Down