Skip to content

Commit

Permalink
Use Swift 5.9 AccessLevelOnImport
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Feb 14, 2024
1 parent 9af554c commit af7d783
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
29 changes: 22 additions & 7 deletions FirebaseVertexAI/Sources/VertexAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

import Foundation

public import FirebaseCore
public import class GoogleGenerativeAI.Chat
public import protocol GoogleGenerativeAI.PartsRepresentable
public import struct GoogleGenerativeAI.GenerateContentResponse
public import struct GoogleGenerativeAI.ModelContent

import FirebaseCoreExtension
import FirebaseAppCheckInterop
import FirebaseCore
import GoogleGenerativeAI

// Avoids exposing internal FirebaseCore APIs to Swift users.
@_implementationOnly import FirebaseCoreExtension
private import GoogleGenerativeAI

@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
@objc(FIRVertexAI)
Expand All @@ -40,9 +44,20 @@ open class VertexAI: NSObject {
return provider.vertexAI(location: location, modelResourceName: modelResourceName)
}

public func generateContentStream(prompt: String) async
-> AsyncThrowingStream<GenerateContentResponse, Error> {
return model.generateContentStream(prompt)
public func generateContentStream(_ parts: GoogleGenerativeAI
.PartsRepresentable...)
-> AsyncThrowingStream<GoogleGenerativeAI.GenerateContentResponse, Error> {
return model.generateContentStream([GoogleGenerativeAI.ModelContent(parts: parts)])
}

public func generateContentStream(_ content: [GoogleGenerativeAI.ModelContent])
-> AsyncThrowingStream<GoogleGenerativeAI.GenerateContentResponse, Error> {
return model.generateContentStream(content)
}

public func startChat(history: [GoogleGenerativeAI.ModelContent] = []) -> GoogleGenerativeAI
.Chat {
return model.startChat(history: history)
}

// MARK: - Private
Expand Down
8 changes: 4 additions & 4 deletions FirebaseVertexAI/Sources/VertexAIComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import FirebaseAppCheckInterop
import FirebaseCore
import Foundation

// Avoids exposing internal FirebaseCore APIs to Swift users.
@_implementationOnly import FirebaseCoreExtension
public import FirebaseCore

import FirebaseAppCheckInterop
import FirebaseCoreExtension

@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
@objc(FIRVertexAIProvider)
Expand Down
9 changes: 6 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7.1
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to
// build this package.

Expand Down Expand Up @@ -189,7 +189,7 @@ let package = Package(
.package(url: "https://github.com/google/app-check.git", "10.18.0" ..< "11.0.0"),
.package(
url: "https://github.com/google/generative-ai-swift.git",
revision: "efcee26db89d1948ebd581b3097c94186d615282"
revision: "4fe215743fd02c8182efdcfff5e7571873d2c158"
),
],
targets: [
Expand Down Expand Up @@ -1315,7 +1315,10 @@ let package = Package(
"FirebaseCoreExtension",
.product(name: "GoogleGenerativeAI", package: "generative-ai-swift"),
],
path: "FirebaseVertexAI/Sources"
path: "FirebaseVertexAI/Sources",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport"),
]
),
] + firestoreTargets(),
cLanguageStandard: .c99,
Expand Down

0 comments on commit af7d783

Please sign in to comment.