Skip to content

Commit bf7c84d

Browse files
committed
[AI] API docs for URLContext
1 parent 609bb97 commit bf7c84d

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

FirebaseAI/Sources/GenerateContentResponse.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public struct GenerateContentResponse: Sendable {
2626
/// The total number of tokens across the generated response candidates.
2727
public let candidatesTokenCount: Int
2828

29-
/// The number of tokens present in tool-use prompt(s).
29+
/// The number of tokens in the results from tool executions, which are provided back to the
30+
/// model as input.
3031
public let toolUsePromptTokenCount: Int
3132

3233
/// The number of tokens used by the model's internal "thinking" process.
@@ -42,13 +43,14 @@ public struct GenerateContentResponse: Sendable {
4243
/// The total number of tokens in both the request and response.
4344
public let totalTokenCount: Int
4445

45-
/// The breakdown, by modality, of how many tokens are consumed by the prompt
46+
/// The breakdown, by modality, of how many tokens are consumed by the prompt.
4647
public let promptTokensDetails: [ModalityTokenCount]
4748

4849
/// The breakdown, by modality, of how many tokens are consumed by the candidates
4950
public let candidatesTokensDetails: [ModalityTokenCount]
5051

51-
/// List of modalities that were processed for tool-use request inputs.
52+
/// A list of tokens used by tools whose usage was triggered from a prompt, broken down by
53+
/// modality.
5254
public let toolUsePromptTokensDetails: [ModalityTokenCount]
5355
}
5456

FirebaseAI/Sources/Tool.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ public struct Tool: Sendable {
131131
return self.init(googleSearch: googleSearch)
132132
}
133133

134+
/// Creates a tool that allows you to provide additional context to the models in the form of
135+
/// public web URLs.
136+
///
137+
/// By including URLs in your request, the Gemini model will access the content from those pages
138+
/// to inform and enhance its response.
134139
public static func urlContext() -> Tool {
135140
return self.init(urlContext: URLContext())
136141
}

FirebaseAI/Sources/Types/Public/URLContextMetadata.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/// Metadata related to the ``Tool/urlContext()`` tool.
15+
/// Metadata related to ``URLContextTool``.
1616
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
1717
public struct URLContextMetadata: Sendable, Hashable {
18-
/// List of URL context.
18+
/// List of URL metadata used to provide context to the Gemini model.
1919
public let urlMetadata: [URLMetadata]
2020
}
2121

FirebaseAI/Sources/Types/Public/URLMetadata.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
import Foundation
1616

17-
/// Context of a single URL retrieval.
17+
/// The number of tokens in the results from tool executions, which are provided back to the model
18+
/// as input.
1819
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
1920
public struct URLMetadata: Sendable, Hashable {
2021
/// Status of the URL retrieval.
@@ -27,19 +28,19 @@ public struct URLMetadata: Sendable, Hashable {
2728
case unsafe = "URL_RETRIEVAL_STATUS_UNSAFE"
2829
}
2930

30-
/// Internal only - default value.
31+
/// Internal only - Unspecified retrieval status.
3132
static let unspecified = URLRetrievalStatus(kind: .unspecified)
3233

33-
/// URL retrieval succeeded.
34+
/// The URL retrieval was successful.
3435
public static let success = URLRetrievalStatus(kind: .success)
3536

36-
/// URL retrieval failed due to an error.
37+
/// The URL retrieval failed.
3738
public static let error = URLRetrievalStatus(kind: .error)
3839

39-
/// URL retrieval failed failed because the content is behind paywall.
40+
/// The URL retrieval failed because the content is behind a paywall.
4041
public static let paywall = URLRetrievalStatus(kind: .paywall)
4142

42-
/// URL retrieval failed because the content is unsafe.
43+
/// The URL retrieval failed because the content is unsafe.
4344
public static let unsafe = URLRetrievalStatus(kind: .unsafe)
4445

4546
/// Returns the raw string representation of the `URLRetrievalStatus` value.
@@ -49,7 +50,7 @@ public struct URLMetadata: Sendable, Hashable {
4950
AILog.MessageCode.urlMetadataUnrecognizedURLRetrievalStatus
5051
}
5152

52-
/// The URL retrieved by the ``Tool/urlContext()`` tool.
53+
/// The retrieved URL.
5354
public let retrievedURL: URL?
5455

5556
/// The status of the URL retrieval.

0 commit comments

Comments
 (0)