@@ -63,6 +63,11 @@ public struct GoogleSearch: Sendable {
63
63
public init ( ) { }
64
64
}
65
65
66
+ @available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
67
+ public struct URLContext : Sendable {
68
+ public init ( ) { }
69
+ }
70
+
66
71
/// A helper tool that the model may use when generating responses.
67
72
///
68
73
/// A `Tool` is a piece of code that enables the system to interact with external systems to perform
@@ -76,14 +81,17 @@ public struct Tool: Sendable {
76
81
let googleSearch : GoogleSearch ?
77
82
78
83
let codeExecution : CodeExecution ?
79
-
80
- init ( functionDeclarations: [ FunctionDeclaration ] ? = nil ,
81
- googleSearch: GoogleSearch ? = nil ,
82
- codeExecution: CodeExecution ? = nil ) {
83
- self . functionDeclarations = functionDeclarations
84
- self . googleSearch = googleSearch
85
- self . codeExecution = codeExecution
86
- }
84
+ let urlContext : URLContext ?
85
+
86
+ init ( functionDeclarations: [ FunctionDeclaration ] ? = nil ,
87
+ googleSearch: GoogleSearch ? = nil ,
88
+ urlContext: URLContext ? = nil ,
89
+ codeExecution: CodeExecution ? = nil ) {
90
+ self . functionDeclarations = functionDeclarations
91
+ self . googleSearch = googleSearch
92
+ self . urlContext = urlContext
93
+ self . codeExecution = codeExecution
94
+ }
87
95
88
96
/// Creates a tool that allows the model to perform function calling.
89
97
///
@@ -128,6 +136,11 @@ public struct Tool: Sendable {
128
136
return self . init ( googleSearch: googleSearch)
129
137
}
130
138
139
+
140
+ public static func urlContext( _ urlContext: URLContext = URLContext ( ) ) -> Tool {
141
+ return self . init ( urlContext: urlContext)
142
+ }
143
+
131
144
/// Creates a tool that allows the model to execute code.
132
145
///
133
146
/// For more details, see ``CodeExecution``.
@@ -222,5 +235,8 @@ extension FunctionCallingConfig.Mode: Encodable {}
222
235
@available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
223
236
extension GoogleSearch : Encodable { }
224
237
238
+ @available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
239
+ extension URLContext : Encodable { }
240
+
225
241
@available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
226
242
extension ToolConfig : Encodable { }
0 commit comments