Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ah/release-10.26-merge-ca'
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed May 13, 2024
2 parents 520fb3e + 301399f commit 1696c5c
Show file tree
Hide file tree
Showing 117 changed files with 9,100 additions and 11 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/vertexai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: vertexai

on:
pull_request:
paths:
- 'FirebaseVertexAI**'
- '.github/workflows/vertexai.yml'
- 'Gemfile*'
schedule:
# Run every day at 11pm (PST) - cron uses UTC times
- cron: '0 7 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
spm:
strategy:
matrix:
target: [iOS, macOS, catalyst]
os: [macos-13]
include:
- os: macos-13
xcode: Xcode_15.2
runs-on: ${{ matrix.os }}
env:
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
steps:
- uses: actions/checkout@v4
- name: Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
- name: Initialize xcodebuild
run: scripts/setup_spm_tests.sh
- uses: nick-fields/retry@v3
with:
timeout_minutes: 120
max_attempts: 3
retry_on: error
retry_wait_seconds: 120
command: scripts/build.sh FirebaseVertexAIUnit ${{ matrix.target }} spm

sample:
strategy:
matrix:
# Test build with debug and release configs (whether or not DEBUG is set and optimization level)
build: [build]
include:
- os: macos-13
xcode: Xcode_15.0.1
- os: macos-14
xcode: Xcode_15.2
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
- name: Initialize xcodebuild
run: xcodebuild -list
- name: Placeholder GoogleService-Info.plist for build testing
run: cp FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist FirebaseVertexAI/Sample/
- uses: nick-fields/retry@v3
with:
timeout_minutes: 120
max_attempts: 3
retry_on: error
retry_wait_seconds: 120
command: scripts/build.sh VertexSample iOS
5 changes: 4 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def labelsForModifiedFiles()
labels.push("api: performance") if @has_performance_changes
labels.push("api: remoteconfig") if @has_remoteconfig_changes
labels.push("api: storage") if @has_storage_changes
labels.push("api: vertexai") if @has_vertexai_changes
labels.push("release-tooling") if @has_releasetooling_changes
labels.push("public-api-change") if @has_api_changes
return labels
Expand Down Expand Up @@ -100,7 +101,8 @@ has_license_changes = didModify(["LICENSE"])
"Messaging",
"Performance",
"RemoteConfig",
"Storage"
"Storage",
"VertexAI"
]

## Product directories
Expand Down Expand Up @@ -149,6 +151,7 @@ has_license_changes = didModify(["LICENSE"])
@has_remoteconfig_changes = hasChangesIn("FirebaseRemoteConfig")
@has_remoteconfig_api_changes = hasChangesIn("FirebaseRemoteConfig/Sources/Public/")
@has_storage_changes = hasChangesIn("FirebaseStorage")
@has_vertexai_changes = hasChangesIn("FirebaseVertexAI")

@has_releasetooling_changes = hasChangesIn("ReleaseTooling/")
@has_public_additions = hasAdditionsIn("Public/")
Expand Down
1 change: 1 addition & 0 deletions FirebaseCore/Sources/FIRApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ + (void)registerSwiftComponents {
@"FIRSessions" : @"fire-ses",
@"FIRFunctionsComponent" : @"fire-fun",
@"FIRStorageComponent" : @"fire-str",
@"FIRVertexAIComponent" : @"fire-vertex",
};
for (NSString *className in swiftComponents.allKeys) {
Class klass = NSClassFromString(className);
Expand Down
2 changes: 1 addition & 1 deletion FirebaseCore/Sources/FIROptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ - (NSString *)libraryVersionID {
// The unit tests are set up to catch anything that does not properly convert.
NSString *version = FIRFirebaseVersion();
NSArray *components = [version componentsSeparatedByString:@"."];
NSString *major = [components objectAtIndex:0];
NSString *major = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:0] intValue]];
NSString *minor = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:1] intValue]];
NSString *patch = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:2] intValue]];
kFIRLibraryVersionID = [NSString stringWithFormat:@"%@%@%@000", major, minor, patch];
Expand Down
12 changes: 6 additions & 6 deletions FirebaseCore/Tests/Unit/FIROptionsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ - (void)testVersionConsistency {
int minor = (versionString[2] - '0') * 10 + versionString[3] - '0';
int patch = (versionString[4] - '0') * 10 + versionString[5] - '0';
NSString *str = [NSString stringWithFormat:@"%d.%d.%d", major, minor, patch];
XCTAssertEqualObjects(str, FIRFirebaseVersion());
XCTAssertTrue([FIRFirebaseVersion() hasPrefix:str]);
}

// Repeat test with more Objective-C.
Expand All @@ -638,11 +638,11 @@ - (void)testVersionConsistency2 {
NSRange major = NSMakeRange(0, 2);
NSRange minor = NSMakeRange(2, 2);
NSRange patch = NSMakeRange(4, 2);
NSString *str =
[NSString stringWithFormat:@"%@.%d.%d", [kFIRLibraryVersionID substringWithRange:major],
[[kFIRLibraryVersionID substringWithRange:minor] intValue],
[[kFIRLibraryVersionID substringWithRange:patch] intValue]];
XCTAssertEqualObjects(str, FIRFirebaseVersion());
NSString *str = [NSString
stringWithFormat:@"%d.%d.%d", [[kFIRLibraryVersionID substringWithRange:major] intValue],
[[kFIRLibraryVersionID substringWithRange:minor] intValue],
[[kFIRLibraryVersionID substringWithRange:patch] intValue]];
XCTAssertTrue([FIRFirebaseVersion() hasPrefix:str]);
}

#pragma mark - Helpers
Expand Down
55 changes: 55 additions & 0 deletions FirebaseVertexAI-Docs.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Pod::Spec.new do |s|
s.name = 'FirebaseVertexAI'
s.version = '10.26.0'
s.summary = 'Firebase VertexAI'

s.description = <<-DESC
Placeholder podspec for docsgen only. Do not use this pod.
DESC

s.homepage = 'https://firebase.google.com'
s.license = { :type => 'Apache-2.0', :file => 'LICENSE' }
s.authors = 'Google, Inc.'

s.source = {
:git => 'https://github.com/firebase/firebase-ios-sdk.git',
# TODO: this should be `'CocoaPods-' + s.version.to_s` (after May 14 2024)
:tag => 'release-10.26'
}

s.social_media_url = 'https://twitter.com/Firebase'

ios_deployment_target = '15.0'
osx_deployment_target = '10.14'

s.ios.deployment_target = ios_deployment_target
s.osx.deployment_target = osx_deployment_target

s.cocoapods_version = '>= 1.12.0'
s.prefix_header_file = false

s.source_files = [
'FirebaseVertexAI/Sources/**/*.swift',
'FirebaseCore/Extension/*.h',
'FirebaseAuth/Interop/*.h',
]

s.swift_version = '5.3'

s.framework = 'Foundation'
s.ios.framework = 'UIKit'
s.osx.framework = 'AppKit'
s.tvos.framework = 'UIKit'
s.watchos.framework = 'WatchKit'

s.dependency 'FirebaseCore', '~> 10.0'
s.dependency 'FirebaseCoreExtension'
s.dependency 'FirebaseAuthInterop'
s.dependency 'FirebaseAppCheckInterop', '~> 10.17'

s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"',
'OTHER_CFLAGS' => '-fno-autolink'
}
end
6 changes: 6 additions & 0 deletions FirebaseVertexAI/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 10.26.0

- [feature] Initial release of the Vertex AI for Firebase SDK (public preview).
Learn how to
[get started](https://firebase.google.com/docs/vertex-ai/get-started?platform=ios)
with the SDK in your app.
8 changes: 8 additions & 0 deletions FirebaseVertexAI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Vertex AI for Firebase SDK

**Preview**: Vertex AI for Firebase is in Public Preview, which means that the product is
not subject to any SLA or deprecation policy and could change in backwards-incompatible
ways.

- For developer documentation, please visit https://firebase.google.com/docs/vertex-ai.
- Try out the [sample app](Sample/README.md) to get started.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
64 changes: 64 additions & 0 deletions FirebaseVertexAI/Sample/ChatSample/Models/ChatMessage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

enum Participant {
case system
case user
}

struct ChatMessage: Identifiable, Equatable {
let id = UUID().uuidString
var message: String
let participant: Participant
var pending = false

static func pending(participant: Participant) -> ChatMessage {
Self(message: "", participant: participant, pending: true)
}
}

extension ChatMessage {
static var samples: [ChatMessage] = [
.init(message: "Hello. What can I do for you today?", participant: .system),
.init(message: "Show me a simple loop in Swift.", participant: .user),
.init(message: """
Sure, here is a simple loop in Swift:
# Example 1
```
for i in 1...5 {
print("Hello, world!")
}
```
This loop will print the string "Hello, world!" five times. The for loop iterates over a range of numbers,
in this case the numbers from 1 to 5. The variable i is assigned each number in the range, and the code inside the loop is executed.
**Here is another example of a simple loop in Swift:**
```swift
var sum = 0
for i in 1...100 {
sum += i
}
print("The sum of the numbers from 1 to 100 is \\(sum).")
```
This loop calculates the sum of the numbers from 1 to 100. The variable sum is initialized to 0, and then the for loop iterates over the range of numbers from 1 to 100. The variable i is assigned each number in the range, and the value of i is added to the sum variable. After the loop has finished executing, the value of sum is printed to the console.
""", participant: .system),
]

static var sample = samples[0]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 1696c5c

Please sign in to comment.