@@ -314,17 +314,17 @@ def _redact_file_uri_for_log(
314314 return f"{ parsed .scheme } ://<redacted>"
315315
316316
317- def _requires_file_uri_fallback (
317+ def _is_requires_file_uri_valid (
318318 provider : str , model : str , file_uri : str
319319) -> bool :
320320 """Returns True when `file_uri` should not be sent as a file content block."""
321321 if provider in _FILE_ID_REQUIRED_PROVIDERS :
322- return not _looks_like_openai_file_id (file_uri )
322+ return _looks_like_openai_file_id (file_uri )
323323 if provider == "anthropic" :
324- return True
324+ return False
325325 if provider == "vertex_ai" and not _is_litellm_gemini_model (model ):
326- return True
327- return False
326+ return False
327+ return True
328328
329329
330330def _decode_inline_text_data (raw_bytes : bytes ) -> str :
@@ -1131,21 +1131,17 @@ async def _get_content(
11311131 })
11321132 continue
11331133
1134- if _requires_file_uri_fallback (provider , model , part .file_data .file_uri ):
1135- logger .debug (
1136- "File URI %s not supported for provider %s, using text fallback" ,
1134+ if _is_requires_file_uri_valid (provider , model , part .file_data .file_uri ):
1135+ redact_file_uri = (
11371136 _redact_file_uri_for_log (
11381137 part .file_data .file_uri ,
11391138 display_name = part .file_data .display_name ,
11401139 ),
1141- provider ,
11421140 )
1143- identifier = part .file_data .display_name or part .file_data .file_uri
1144- content_objects .append ({
1145- "type" : "text" ,
1146- "text" : f'[File reference: "{ identifier } "]' ,
1147- })
1148- continue
1141+ raise ValueError (
1142+ f"File URI { redact_file_uri } not supported for provider:"
1143+ f" { provider } ."
1144+ )
11491145
11501146 file_object : ChatCompletionFileUrlObject = {
11511147 "file_id" : part .file_data .file_uri ,
0 commit comments