mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(types/utils.py): support openai 'file' message type
Closes https://github.com/BerriAI/litellm/issues/9365
This commit is contained in:
parent
fe24b9d90b
commit
8ef9129556
2 changed files with 33 additions and 0 deletions
|
|
@ -436,12 +436,24 @@ class ChatCompletionDocumentObject(TypedDict):
|
|||
citations: Optional[CitationsObject]
|
||||
|
||||
|
||||
class ChatCompletionFileObjectFile(TypedDict):
|
||||
file_data: Optional[str]
|
||||
file_id: Optional[str]
|
||||
filename: Optional[str]
|
||||
|
||||
|
||||
class ChatCompletionFileObject(TypedDict):
|
||||
type: Literal["file"]
|
||||
file: ChatCompletionFileObjectFile
|
||||
|
||||
|
||||
OpenAIMessageContentListBlock = Union[
|
||||
ChatCompletionTextObject,
|
||||
ChatCompletionImageObject,
|
||||
ChatCompletionAudioObject,
|
||||
ChatCompletionDocumentObject,
|
||||
ChatCompletionVideoObject,
|
||||
ChatCompletionFileObject,
|
||||
]
|
||||
|
||||
OpenAIMessageContent = Union[
|
||||
|
|
@ -523,6 +535,7 @@ ValidUserMessageContentTypes = [
|
|||
"input_audio",
|
||||
"document",
|
||||
"video_url",
|
||||
"file",
|
||||
] # used for validating user messages. Prevent users from accidentally sending anthropic messages.
|
||||
|
||||
AllMessageValues = Union[
|
||||
|
|
|
|||
|
|
@ -1094,6 +1094,26 @@ def test_is_base64_encoded_2():
|
|||
[
|
||||
([{"role": "user", "content": "hi"}], True),
|
||||
([{"role": "user", "content": [{"type": "text", "text": "hi"}]}], True),
|
||||
(
|
||||
[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "file",
|
||||
"file": {
|
||||
"file_id": "123",
|
||||
"file_name": "test.txt",
|
||||
"file_size": 100,
|
||||
"file_type": "text/plain",
|
||||
"file_url": "https://example.com/test.txt",
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
True,
|
||||
),
|
||||
(
|
||||
[
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue