Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,40 @@ struct ServerPromptTemplateIntegrationTests {
#expect(text.localizedCaseInsensitiveContains("museum"))
}

@Test(arguments: [
InstanceConfig.googleAI_v1beta,
])
Comment on lines +91 to +93
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider including InstanceConfig.vertexAI_v1beta in the test arguments. This ensures that the prompt template and grounding metadata mapping are verified across both Google AI and Vertex AI platforms, maintaining consistency with other integration tests in this file.

  @Test(arguments: [
    InstanceConfig.googleAI_v1beta,
    InstanceConfig.vertexAI_v1beta,
  ])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caught error: BackendError(httpResponseCode: 404, message: "Publisher Model projects/ios-opensource-samples/locations/us-central1/publishers/google/models/gemini-3-flash-preview was not found or your project does not have access to it. Please ensure you are using a valid model version. For more information, see: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions", status: FirebaseAILogic.RPCStatus.notFound, details: [])

and

Caught error: BackendError(httpResponseCode: 404, message: "Publisher Model projects/ios-opensource-samples/locations/us-central1/publishers/google/models/gemini-3-flash was not found or your project does not have access to it. Please ensure you are using a valid model version. For more information, see: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions", status: FirebaseAILogic.RPCStatus.notFound, details: [])

And there is no location specifier in the template ...

func generateContentWithTemplateMapsGroundingSnippet(_ config: InstanceConfig) async throws {
let latAndLong = CLLocationCoordinate2D(latitude: 30.2672, longitude: -97.7431)
let retrievalConfig = RetrievalConfig(location: latAndLong, languageCode: "en_US")
let templateToolConfig = TemplateToolConfig(retrievalConfig: retrievalConfig)

let model = FirebaseAI.componentInstance(config).templateGenerativeModel()
let response = try await model.generateContent(
templateID: "grounding-with-google-maps-v1-0-0",
inputs: [
"question": "restaurants near me?",
],
toolConfig: templateToolConfig
)

let text = try #require(response.text)
#expect(!text.isEmpty)

// Validate grounding metadata
let candidate = try #require(response.candidates.first)
let groundingMetadata = try #require(candidate.groundingMetadata)
let mapChunks = groundingMetadata.groundingChunks.compactMap { $0.maps }
try #require(!mapChunks.isEmpty)
for mapsChunk in mapChunks {
#expect(mapsChunk.url != nil)
let title = try #require(mapsChunk.title)
#expect(!title.isEmpty)
let placeID = try #require(mapsChunk.placeID)
#expect(!placeID.isEmpty)
}
}

@Test(arguments: [
InstanceConfig.googleAI_v1beta,
InstanceConfig.vertexAI_v1beta,
Expand Down
Loading