Skip to content

Commit 48f2a60

Browse files
andrewheardG.Dev.Ssomsak
authored andcommitted
Add function calling support (google-gemini#116)
1 parent 6f24a5c commit 48f2a60

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Sources/GoogleAI/Chat.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ public class Chat {
3030
/// model. This will be provided to the model for each message sent as context for the discussion.
3131
public var history: [ModelContent]
3232

33-
/// Sends a message using the existing history of this chat as context. If successful, the message
34-
/// and response will be added to the history. If unsuccessful, history will remain unchanged.
35-
/// - Parameter parts: The new content to send as a single chat message.
36-
/// - Returns: The model's response if no error occurred.
37-
/// - Throws: A ``GenerateContentError`` if an error occurred.
33+
/// See ``sendMessage(_:)-3ify5``.
3834
public func sendMessage(_ parts: any ThrowingPartsRepresentable...) async throws
3935
-> GenerateContentResponse {
4036
return try await sendMessage([ModelContent(parts: parts)])
@@ -102,10 +98,7 @@ public class Chat {
10298
return try await sendMessage([functionResponseContent])
10399
}
104100

105-
/// Sends a message using the existing history of this chat as context. If successful, the message
106-
/// and response will be added to the history. If unsuccessful, history will remain unchanged.
107-
/// - Parameter parts: The new content to send as a single chat message.
108-
/// - Returns: A stream containing the model's response or an error if an error occurred.
101+
/// See ``sendMessageStream(_:)-4abs3``.
109102
@available(macOS 12.0, *)
110103
public func sendMessageStream(_ parts: any ThrowingPartsRepresentable...)
111104
-> AsyncThrowingStream<GenerateContentResponse, Error> {
@@ -182,7 +175,7 @@ public class Chat {
182175
case let .text(str):
183176
combinedText += str
184177

185-
case .data, .fileData, .functionCall, .functionResponse:
178+
case .data, .functionCall, .functionResponse:
186179
// Don't combine it, just add to the content. If there's any text pending, add that as
187180
// a part.
188181
if !combinedText.isEmpty {

0 commit comments

Comments
 (0)