Skip to content

Commit 10e4e4c

Browse files
[AI] API docs for URLContext (#15341)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 609bb97 commit 10e4e4c

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

FirebaseAI/Sources/GenerateContentResponse.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ 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 used by tools.
3030
public let toolUsePromptTokenCount: Int
3131

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

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

4848
/// The breakdown, by modality, of how many tokens are consumed by the candidates
4949
public let candidatesTokensDetails: [ModalityTokenCount]
5050

51-
/// List of modalities that were processed for tool-use request inputs.
51+
/// The breakdown, by modality, of how many tokens were consumed by the tools used to process
52+
/// the request.
5253
public let toolUsePromptTokensDetails: [ModalityTokenCount]
5354
}
5455

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// Metadata related to the ``Tool/urlContext()`` tool.
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616

17-
/// Context of a single URL retrieval.
17+
/// Metadata for a single URL retrieved by the ``Tool/urlContext()`` tool.
1818
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
1919
public struct URLMetadata: Sendable, Hashable {
2020
/// Status of the URL retrieval.
@@ -27,19 +27,19 @@ public struct URLMetadata: Sendable, Hashable {
2727
case unsafe = "URL_RETRIEVAL_STATUS_UNSAFE"
2828
}
2929

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

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

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

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

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

4545
/// Returns the raw string representation of the `URLRetrievalStatus` value.
@@ -49,7 +49,7 @@ public struct URLMetadata: Sendable, Hashable {
4949
AILog.MessageCode.urlMetadataUnrecognizedURLRetrievalStatus
5050
}
5151

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

5555
/// The status of the URL retrieval.

0 commit comments

Comments
 (0)