mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
fix(managed files): skip chat messages and content items that are not objects
This commit is contained in:
parent
8cc51b31d7
commit
15e6516fe1
2 changed files with 4 additions and 2 deletions
|
|
@ -1735,13 +1735,13 @@ class _PROXY_LiteLLMManagedFiles(CustomLogger, BaseFileEndpoints):
|
|||
"""
|
||||
file_ids = []
|
||||
for message in messages:
|
||||
if message.get("role") == "user":
|
||||
if isinstance(message, dict) and message.get("role") == "user":
|
||||
content = message.get("content")
|
||||
if content:
|
||||
if isinstance(content, str):
|
||||
continue
|
||||
for c in content:
|
||||
if c.get("type") == "file":
|
||||
if isinstance(c, dict) and c.get("type") == "file":
|
||||
file_object_file_field = cast(Dict[str, object], c).get("file")
|
||||
if not isinstance(file_object_file_field, dict):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -337,9 +337,11 @@ def test_get_file_ids_from_messages_leaves_malformed_file_parts_to_request_valid
|
|||
DualCache(), prisma_client=MagicMock()
|
||||
)
|
||||
messages = [
|
||||
"not-a-message",
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
"not-a-part",
|
||||
{"type": "file"},
|
||||
{"type": "file", "file": "file-raw"},
|
||||
{"type": "file", "file": None},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue