@@ -2143,46 +2143,45 @@ async def __aexit__(self, *args):
21432143
21442144@pytest .mark .asyncio
21452145async def test_preprocess_request_unsupported_mime_type (gemini_llm ):
2146- """Verifies that MS Office files are escaped to a text reference."""
2147- unsupported_part = types .Part (
2148- file_data = types .FileData (
2149- mime_type = "application/vnd.ms-excel" ,
2150- file_uri = "gs://bucket/data.xls" ,
2151- display_name = "data.xls"
2152- )
2153- )
2154- req = LlmRequest (
2155- model = "gemini-2.0-flash" ,
2156- contents = [types .Content (parts = [unsupported_part ])]
2157- )
2146+ """Verifies that MS Office files are escaped to a text reference."""
2147+ unsupported_part = types .Part (
2148+ file_data = types .FileData (
2149+ mime_type = "application/vnd.ms-excel" ,
2150+ file_uri = "gs://bucket/data.xls" ,
2151+ display_name = "data.xls" ,
2152+ )
2153+ )
2154+ req = LlmRequest (
2155+ model = "gemini-2.0-flash" ,
2156+ contents = [types .Content (parts = [unsupported_part ])],
2157+ )
21582158
2159- await gemini_llm ._preprocess_request (req )
2159+ await gemini_llm ._preprocess_request (req )
21602160
2161- processed_part = req .contents [0 ].parts [0 ]
2162- # File_data should be stripped to avoid the 400 error
2163- assert processed_part .file_data is None
2164- # Text fallback should be present
2165- assert '[File reference: "data.xls"]' in processed_part .text
2161+ processed_part = req .contents [0 ].parts [0 ]
2162+ # File_data should be stripped to avoid the 400 error
2163+ assert processed_part .file_data is None
2164+ # Text fallback should be present
2165+ assert '[File reference: "data.xls"]' in processed_part .text
21662166
21672167
21682168@pytest .mark .asyncio
21692169async def test_preprocess_request_supported_mime_type (gemini_llm ):
2170- """Verifies that PDF files are passed through without modification."""
2171- supported_part = types .Part (
2172- file_data = types .FileData (
2173- mime_type = "application/pdf" ,
2174- file_uri = "gs://bucket/doc.pdf" ,
2175- display_name = "doc.pdf"
2176- )
2177- )
2178- req = LlmRequest (
2179- model = "gemini-2.0-flash" ,
2180- contents = [types .Content (parts = [supported_part ])]
2181- )
2170+ """Verifies that PDF files are passed through without modification."""
2171+ supported_part = types .Part (
2172+ file_data = types .FileData (
2173+ mime_type = "application/pdf" ,
2174+ file_uri = "gs://bucket/doc.pdf" ,
2175+ display_name = "doc.pdf" ,
2176+ )
2177+ )
2178+ req = LlmRequest (
2179+ model = "gemini-2.0-flash" , contents = [types .Content (parts = [supported_part ])]
2180+ )
21822181
2183- await gemini_llm ._preprocess_request (req )
2182+ await gemini_llm ._preprocess_request (req )
21842183
2185- processed_part = req .contents [0 ].parts [0 ]
2186- # file_data should still be intact
2187- assert processed_part .file_data is not None
2188- assert processed_part .file_data .mime_type == "application/pdf"
2184+ processed_part = req .contents [0 ].parts [0 ]
2185+ # file_data should still be intact
2186+ assert processed_part .file_data is not None
2187+ assert processed_part .file_data .mime_type == "application/pdf"
0 commit comments