Skip to content

Commit f705699

Browse files
committed
Make template chat APIs internal for now
1 parent 287dd12 commit f705699

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

FirebaseAI/Sources/TemplateChatSession.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
import Foundation
1616

17+
// TODO: Restore `public` to class and methods when determined to be releaseable.
18+
1719
/// A chat session that allows for conversation with a model.
1820
///
1921
/// **Public Preview**: This API is a public preview and may be subject to change.
2022
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
21-
public final class TemplateChatSession: Sendable {
23+
final class TemplateChatSession: Sendable {
2224
private let model: TemplateGenerativeModel
2325
private let templateID: String
2426
private let _history: History
@@ -49,7 +51,7 @@ public final class TemplateChatSession: Sendable {
4951
/// request timeout.
5052
/// - Returns: The content generated by the model.
5153
/// - Throws: A ``GenerateContentError`` if the request failed.
52-
public func sendMessage(_ content: [ModelContent],
54+
func sendMessage(_ content: [ModelContent],
5355
inputs: [String: Any],
5456
options: RequestOptions = RequestOptions()) async throws
5557
-> GenerateContentResponse {
@@ -79,7 +81,7 @@ public final class TemplateChatSession: Sendable {
7981
/// request timeout.
8082
/// - Returns: The content generated by the model.
8183
/// - Throws: A ``GenerateContentError`` if the request failed.
82-
public func sendMessage(_ message: any PartsRepresentable,
84+
func sendMessage(_ message: any PartsRepresentable,
8385
inputs: [String: Any],
8486
options: RequestOptions = RequestOptions()) async throws
8587
-> GenerateContentResponse {
@@ -100,7 +102,7 @@ public final class TemplateChatSession: Sendable {
100102
/// request timeout.
101103
/// - Returns: An `AsyncThrowingStream` that yields `GenerateContentResponse` objects.
102104
/// - Throws: A ``GenerateContentError`` if the request failed.
103-
public func sendMessageStream(_ content: [ModelContent],
105+
func sendMessageStream(_ content: [ModelContent],
104106
inputs: [String: Any],
105107
options: RequestOptions = RequestOptions()) throws
106108
-> AsyncThrowingStream<GenerateContentResponse, Error> {
@@ -155,7 +157,7 @@ public final class TemplateChatSession: Sendable {
155157
/// request timeout.
156158
/// - Returns: An `AsyncThrowingStream` that yields `GenerateContentResponse` objects.
157159
/// - Throws: A ``GenerateContentError`` if the request failed.
158-
public func sendMessageStream(_ message: any PartsRepresentable,
160+
func sendMessageStream(_ message: any PartsRepresentable,
159161
inputs: [String: Any],
160162
options: RequestOptions = RequestOptions()) throws
161163
-> AsyncThrowingStream<GenerateContentResponse, Error> {

FirebaseAI/Sources/TemplateGenerativeModel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ public final class TemplateGenerativeModel: Sendable {
122122
return generativeAIService.loadRequestStream(request: request)
123123
}
124124

125+
// TODO: Restore `public` determined to be releaseable along with the contents of TemplateChatSession.
126+
125127
/// Creates a new chat conversation using this model with the provided history and template.
126128
///
127129
/// - Parameters:
128130
/// - templateID: The ID of the prompt template to use.
129131
/// - history: The conversation history to use.
130132
/// - Returns: A new ``TemplateChatSession`` instance.
131-
public func startChat(templateID: String,
133+
func startChat(templateID: String,
132134
history: [ModelContent] = []) -> TemplateChatSession {
133135
return TemplateChatSession(
134136
model: self,

FirebaseAI/Tests/TestApp/Tests/Integration/ServerPromptTemplateIntegrationTests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import FirebaseAI
15+
// TODO: remove @testable when Template Chat is restored to the public API.
16+
@testable import FirebaseAILogic
1617
import Testing
1718
#if canImport(UIKit)
1819
import UIKit
@@ -118,7 +119,7 @@ struct ServerPromptTemplateIntegrationTests {
118119
let base64Image = imageBytes.base64EncodedString()
119120

120121
let stream = try model.generateContentStream(
121-
templateID: "media.prompt",
122+
templateID: "media",
122123
inputs: [
123124
"imageData": [
124125
"isInline": true,
@@ -165,7 +166,7 @@ struct ServerPromptTemplateIntegrationTests {
165166
ModelContent(role: "user", parts: "Hello!"),
166167
ModelContent(role: "model", parts: "Hi there! How can I help?"),
167168
]
168-
let chatSession = model.startChat(templateID: "chat_history.prompt", history: initialHistory)
169+
let chatSession = model.startChat(templateID: "chat-history", history: initialHistory)
169170

170171
let userMessage = "What's the weather like?"
171172

0 commit comments

Comments
 (0)