Skip to content

Commit

Permalink
Fix optional VertexAIProvider unwrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Feb 22, 2024
1 parent 49979ef commit 44073e5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FirebaseVertexAI/Sources/VertexAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ open class VertexAI: NSObject {
/// Returns an instance of `GoogleGenerativeAI.GenerativeModel` that uses the Vertex AI API.
public static func generativeModel(app: FirebaseApp, modelName: String,
location: String) -> GoogleGenerativeAI.GenerativeModel {
let provider = ComponentType<VertexAIProvider>.instance(for: VertexAIProvider.self,
in: app.container)
guard let provider = ComponentType<VertexAIProvider>.instance(for: VertexAIProvider.self,
in: app.container) else {
fatalError("No \(VertexAIProvider.self) instance found for Firebase app: \(app.name)")
}
let modelResourceName = modelResourceName(app: app, modelName: modelName, location: location)
return provider.vertexAI(location: location, modelResourceName: modelResourceName).model
let vertexAI = provider.vertexAI(location: location, modelResourceName: modelResourceName)

return vertexAI.model
}

// MARK: - Private
Expand Down

0 comments on commit 44073e5

Please sign in to comment.