From d224cef6d600089e801dda1e13a352bc7c08f6cb Mon Sep 17 00:00:00 2001 From: Ilya <100840225+ILYA-2606@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:51:43 +0300 Subject: [PATCH 1/2] Added Google Search support --- Sources/GoogleAI/FunctionCalling.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/GoogleAI/FunctionCalling.swift b/Sources/GoogleAI/FunctionCalling.swift index 159c8b4..627ecdf 100644 --- a/Sources/GoogleAI/FunctionCalling.swift +++ b/Sources/GoogleAI/FunctionCalling.swift @@ -164,6 +164,9 @@ public struct Tool { /// Enables the model to execute code as part of generation. let codeExecution: CodeExecution? + /// Enables the Google Search + let googleSearch: GoogleSearch? + /// Constructs a new `Tool`. /// /// - Parameters: @@ -177,9 +180,11 @@ public struct Tool { /// ``ModelContent/role`` "function", providing generation context for the next model turn. /// - codeExecution: Enables the model to execute code as part of generation, if provided. public init(functionDeclarations: [FunctionDeclaration]? = nil, - codeExecution: CodeExecution? = nil) { + codeExecution: CodeExecution? = nil, + googleSearch: GoogleSearch? = nil) { self.functionDeclarations = functionDeclarations self.codeExecution = codeExecution + self.googleSearch = googleSearch } } @@ -259,6 +264,12 @@ public struct CodeExecution { public init() {} } +/// Tool for grounding with Google Search +public struct GoogleSearch { + /// Constructs a new `GoogleSearch` tool. + public init() {} +} + /// Code generated by the model that is meant to be executed, and the result returned to the model. /// /// Only generated when using the ``CodeExecution`` tool, in which case the code will automatically @@ -351,6 +362,8 @@ extension FunctionResponse: Encodable {} extension CodeExecution: Encodable {} +extension GoogleSearch: Encodable {} + extension ExecutableCode: Codable {} @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) From a3013ba3f07ca452fcd699ec7b94fa75716f1cc7 Mon Sep 17 00:00:00 2001 From: Ilya <100840225+ILYA-2606@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:39:58 +0300 Subject: [PATCH 2/2] Update FunctionCalling.swift --- Sources/GoogleAI/FunctionCalling.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/GoogleAI/FunctionCalling.swift b/Sources/GoogleAI/FunctionCalling.swift index 627ecdf..3775895 100644 --- a/Sources/GoogleAI/FunctionCalling.swift +++ b/Sources/GoogleAI/FunctionCalling.swift @@ -179,6 +179,7 @@ public struct Tool { /// ``FunctionResponse`` in ``ModelContent/Part/functionResponse(_:)`` with the /// ``ModelContent/role`` "function", providing generation context for the next model turn. /// - codeExecution: Enables the model to execute code as part of generation, if provided. + /// - googleSearch: Enables the Google Search. public init(functionDeclarations: [FunctionDeclaration]? = nil, codeExecution: CodeExecution? = nil, googleSearch: GoogleSearch? = nil) {