Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions FirebaseAI/Sources/GenerateContentResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct GenerateContentResponse: Sendable {
/// The total number of tokens across the generated response candidates.
public let candidatesTokenCount: Int

/// The number of tokens present in tool-use prompt(s).
/// The number of tokens used by tools.
public let toolUsePromptTokenCount: Int

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

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

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

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

Expand Down
5 changes: 5 additions & 0 deletions FirebaseAI/Sources/Tool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public struct Tool: Sendable {
return self.init(googleSearch: googleSearch)
}

/// Creates a tool that allows you to provide additional context to the models in the form of
/// public web URLs.
///
/// By including URLs in your request, the Gemini model will access the content from those pages
/// to inform and enhance its response.
public static func urlContext() -> Tool {
return self.init(urlContext: URLContext())
}
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAI/Sources/Types/Public/URLContextMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// Metadata related to the ``Tool/urlContext()`` tool.
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
public struct URLContextMetadata: Sendable, Hashable {
/// List of URL context.
/// List of URL metadata used to provide context to the Gemini model.
public let urlMetadata: [URLMetadata]
}

Expand Down
14 changes: 7 additions & 7 deletions FirebaseAI/Sources/Types/Public/URLMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Foundation

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

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

/// URL retrieval succeeded.
/// The URL retrieval was successful.
public static let success = URLRetrievalStatus(kind: .success)

/// URL retrieval failed due to an error.
/// The URL retrieval failed.
public static let error = URLRetrievalStatus(kind: .error)

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

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

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

/// The URL retrieved by the ``Tool/urlContext()`` tool.
/// The retrieved URL.
public let retrievedURL: URL?

/// The status of the URL retrieval.
Expand Down
Loading