@@ -2171,46 +2171,45 @@ async def __aexit__(self, *args):
21712171
21722172@pytest .mark .asyncio
21732173async def test_preprocess_request_unsupported_mime_type (gemini_llm ):
2174- """Verifies that MS Office files are escaped to a text reference."""
2175- unsupported_part = types .Part (
2176- file_data = types .FileData (
2177- mime_type = "application/vnd.ms-excel" ,
2178- file_uri = "gs://bucket/data.xls" ,
2179- display_name = "data.xls"
2180- )
2181- )
2182- req = LlmRequest (
2183- model = "gemini-2.0-flash" ,
2184- contents = [types .Content (parts = [unsupported_part ])]
2185- )
2174+ """Verifies that MS Office files are escaped to a text reference."""
2175+ unsupported_part = types .Part (
2176+ file_data = types .FileData (
2177+ mime_type = "application/vnd.ms-excel" ,
2178+ file_uri = "gs://bucket/data.xls" ,
2179+ display_name = "data.xls" ,
2180+ )
2181+ )
2182+ req = LlmRequest (
2183+ model = "gemini-2.0-flash" ,
2184+ contents = [types .Content (parts = [unsupported_part ])],
2185+ )
21862186
2187- await gemini_llm ._preprocess_request (req )
2187+ await gemini_llm ._preprocess_request (req )
21882188
2189- processed_part = req .contents [0 ].parts [0 ]
2190- # File_data should be stripped to avoid the 400 error
2191- assert processed_part .file_data is None
2192- # Text fallback should be present
2193- assert '[File reference: "data.xls"]' in processed_part .text
2189+ processed_part = req .contents [0 ].parts [0 ]
2190+ # File_data should be stripped to avoid the 400 error
2191+ assert processed_part .file_data is None
2192+ # Text fallback should be present
2193+ assert '[File reference: "data.xls"]' in processed_part .text
21942194
21952195
21962196@pytest .mark .asyncio
21972197async def test_preprocess_request_supported_mime_type (gemini_llm ):
2198- """Verifies that PDF files are passed through without modification."""
2199- supported_part = types .Part (
2200- file_data = types .FileData (
2201- mime_type = "application/pdf" ,
2202- file_uri = "gs://bucket/doc.pdf" ,
2203- display_name = "doc.pdf"
2204- )
2205- )
2206- req = LlmRequest (
2207- model = "gemini-2.0-flash" ,
2208- contents = [types .Content (parts = [supported_part ])]
2209- )
2198+ """Verifies that PDF files are passed through without modification."""
2199+ supported_part = types .Part (
2200+ file_data = types .FileData (
2201+ mime_type = "application/pdf" ,
2202+ file_uri = "gs://bucket/doc.pdf" ,
2203+ display_name = "doc.pdf" ,
2204+ )
2205+ )
2206+ req = LlmRequest (
2207+ model = "gemini-2.0-flash" , contents = [types .Content (parts = [supported_part ])]
2208+ )
22102209
2211- await gemini_llm ._preprocess_request (req )
2210+ await gemini_llm ._preprocess_request (req )
22122211
2213- processed_part = req .contents [0 ].parts [0 ]
2214- # file_data should still be intact
2215- assert processed_part .file_data is not None
2216- assert processed_part .file_data .mime_type == "application/pdf"
2212+ processed_part = req .contents [0 ].parts [0 ]
2213+ # file_data should still be intact
2214+ assert processed_part .file_data is not None
2215+ assert processed_part .file_data .mime_type == "application/pdf"
0 commit comments