@@ -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
@@ -74,14 +79,24 @@ public struct Tool: Sendable {
74
79
/// Specifies the Google Search configuration.
75
80
let googleSearch : GoogleSearch ?
76
81
82
+ let urlContext : URLContext ?
83
+
77
84
init ( functionDeclarations: [ FunctionDeclaration ] ? ) {
78
85
self . functionDeclarations = functionDeclarations
79
86
googleSearch = nil
87
+ urlContext = nil
80
88
}
81
89
82
90
init ( googleSearch: GoogleSearch ) {
83
91
self . googleSearch = googleSearch
84
92
functionDeclarations = nil
93
+ urlContext = nil
94
+ }
95
+
96
+ init ( urlContext: URLContext ) {
97
+ self . urlContext = urlContext
98
+ functionDeclarations = nil
99
+ googleSearch = nil
85
100
}
86
101
87
102
/// Creates a tool that allows the model to perform function calling.
@@ -126,6 +141,10 @@ public struct Tool: Sendable {
126
141
public static func googleSearch( _ googleSearch: GoogleSearch = GoogleSearch ( ) ) -> Tool {
127
142
return self . init ( googleSearch: googleSearch)
128
143
}
144
+
145
+ public static func urlContext( _ urlContext: URLContext = URLContext ( ) ) -> Tool {
146
+ return self . init ( urlContext: urlContext)
147
+ }
129
148
}
130
149
131
150
/// Configuration for specifying function calling behavior.
@@ -214,5 +233,8 @@ extension FunctionCallingConfig.Mode: Encodable {}
214
233
@available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
215
234
extension GoogleSearch : Encodable { }
216
235
236
+ @available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
237
+ extension URLContext : Encodable { }
238
+
217
239
@available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
218
240
extension ToolConfig : Encodable { }
0 commit comments