Skip to content

Commit d224cef

Browse files
authored
Added Google Search support
1 parent 31d3eb8 commit d224cef

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Sources/GoogleAI/FunctionCalling.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ public struct Tool {
164164
/// Enables the model to execute code as part of generation.
165165
let codeExecution: CodeExecution?
166166

167+
/// Enables the Google Search
168+
let googleSearch: GoogleSearch?
169+
167170
/// Constructs a new `Tool`.
168171
///
169172
/// - Parameters:
@@ -177,9 +180,11 @@ public struct Tool {
177180
/// ``ModelContent/role`` "function", providing generation context for the next model turn.
178181
/// - codeExecution: Enables the model to execute code as part of generation, if provided.
179182
public init(functionDeclarations: [FunctionDeclaration]? = nil,
180-
codeExecution: CodeExecution? = nil) {
183+
codeExecution: CodeExecution? = nil,
184+
googleSearch: GoogleSearch? = nil) {
181185
self.functionDeclarations = functionDeclarations
182186
self.codeExecution = codeExecution
187+
self.googleSearch = googleSearch
183188
}
184189
}
185190

@@ -259,6 +264,12 @@ public struct CodeExecution {
259264
public init() {}
260265
}
261266

267+
/// Tool for grounding with Google Search
268+
public struct GoogleSearch {
269+
/// Constructs a new `GoogleSearch` tool.
270+
public init() {}
271+
}
272+
262273
/// Code generated by the model that is meant to be executed, and the result returned to the model.
263274
///
264275
/// Only generated when using the ``CodeExecution`` tool, in which case the code will automatically
@@ -351,6 +362,8 @@ extension FunctionResponse: Encodable {}
351362

352363
extension CodeExecution: Encodable {}
353364

365+
extension GoogleSearch: Encodable {}
366+
354367
extension ExecutableCode: Codable {}
355368

356369
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)

0 commit comments

Comments
 (0)