From 834bb72d78623288113c6b840cd77893e8755cbc Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Thu, 4 Sep 2025 11:46:05 -0400 Subject: [PATCH] [Firebase AI] Temporarily test Files API support --- .../GenerateContentIntegrationTests.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift b/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift index 5b70223ece4..c78af2bcd4f 100644 --- a/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift +++ b/FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift @@ -100,6 +100,24 @@ struct GenerateContentIntegrationTests { (usageMetadata.promptTokenCount + usageMetadata.candidatesTokenCount)) } + @Test + func generateContent_imageInput_filesAPI() async throws { + let imageFile = FileDataPart( + uri: "https://generativelanguage.googleapis.com/v1beta/files/bfphtqoghnx0", + mimeType: "image/jpeg" + ) + let model = FirebaseAI.componentInstance(.googleAI_v1beta).generativeModel( + modelName: ModelNames.gemini2FlashLite, + generationConfig: generationConfig + ) + let prompt = "Which province is shown in this image? Answer with the name of the province only." + + let response = try await model.generateContent(prompt, imageFile) + + let text = try #require(response.text).trimmingCharacters(in: .whitespacesAndNewlines) + #expect(text == "Quebec") + } + @Test( "Generate an enum and provide a system instruction", arguments: InstanceConfig.allConfigs