mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix: NotRequired for file_size TypedDict field; defensive seek(0) before file_data
This commit is contained in:
parent
cc6406f16c
commit
1f38a63e3f
2 changed files with 6 additions and 2 deletions
|
|
@ -446,6 +446,10 @@ async def create_file( # noqa: PLR0915
|
|||
# Pass file.file (the underlying SpooledTemporaryFile / BytesIO) rather than
|
||||
# reading all bytes into memory — the IO object is fully compatible with
|
||||
# FileTypes and lets downstream providers stream the upload.
|
||||
# Ensure pointer is at 0 before any code reads from file.file, so that
|
||||
# subsequent seek-based operations (file_size, JSONL sniff, upload) start
|
||||
# from the beginning of the file regardless of prior reads.
|
||||
file.file.seek(0)
|
||||
file_data = (file.filename, file.file, file.content_type)
|
||||
|
||||
## check if model is a loadbalanced model
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ from pydantic import (
|
|||
field_validator,
|
||||
model_validator,
|
||||
)
|
||||
from typing_extensions import Required, TypedDict
|
||||
from typing_extensions import NotRequired, Required, TypedDict
|
||||
|
||||
from litellm._uuid import uuid
|
||||
from litellm.types.llms.base import (
|
||||
|
|
@ -3494,7 +3494,7 @@ class ExtractedFileData(TypedDict):
|
|||
content: Union[bytes, "IO[bytes]"]
|
||||
content_type: Optional[str]
|
||||
headers: Mapping[str, str]
|
||||
file_size: Optional[int]
|
||||
file_size: NotRequired[Optional[int]]
|
||||
|
||||
|
||||
class SpecialEnums(Enum):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue