-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[AI] Server Prompt Templates #15402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[AI] Server Prompt Templates #15402
Conversation
Generated by 🚫 Danger |
|
||
/// A chat session that allows for conversation with a model. | ||
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) | ||
public class TemplateChatSession { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick thing I noticed: public final class TemplateChatSession: Sendable
. This would likely require some refactoring with the history. I'm wondering if we should extract
firebase-ios-sdk/FirebaseAI/Sources/Chat.swift
Lines 29 to 52 in 455d291
private let historyLock = NSLock() | |
private nonisolated(unsafe) var _history: [ModelContent] = [] | |
/// The previous content from the chat that has been successfully sent and received from the | |
/// model. This will be provided to the model for each message sent as context for the discussion. | |
public var history: [ModelContent] { | |
get { | |
historyLock.withLock { _history } | |
} | |
set { | |
historyLock.withLock { _history = newValue } | |
} | |
} | |
private func appendHistory(contentsOf: [ModelContent]) { | |
historyLock.withLock { | |
_history.append(contentsOf: contentsOf) | |
} | |
} | |
private func appendHistory(_ newElement: ModelContent) { | |
historyLock.withLock { | |
_history.append(newElement) | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 004fb94
No description provided.