diff --git a/FirebaseVertexAI/Sources/FunctionCalling.swift b/FirebaseVertexAI/Sources/FunctionCalling.swift index 7bf366a7132..69c90b18e10 100644 --- a/FirebaseVertexAI/Sources/FunctionCalling.swift +++ b/FirebaseVertexAI/Sources/FunctionCalling.swift @@ -35,6 +35,8 @@ public struct FunctionDeclaration { /// with a maximum length of 63. /// - description: A brief description of the function. /// - parameters: Describes the parameters to this function. + /// - optionalParameters: The names of parameters that may be omitted by the model in function + /// calls; by default, all parameters are considered required. public init(name: String, description: String, parameters: [String: Schema], optionalParameters: [String] = []) { self.name = name diff --git a/FirebaseVertexAI/Sources/GenerativeModel.swift b/FirebaseVertexAI/Sources/GenerativeModel.swift index 0ac58732e11..c920a0daa88 100644 --- a/FirebaseVertexAI/Sources/GenerativeModel.swift +++ b/FirebaseVertexAI/Sources/GenerativeModel.swift @@ -97,17 +97,17 @@ public final class GenerativeModel { } /// Generates content from String and/or image inputs, given to the model as a prompt, that are - /// representable as one or more ``ModelContent/Part``s. + /// representable as one or more ``Part``s. /// - /// Since ``ModelContent/Part``s do not specify a role, this method is intended for generating - /// content from + /// Since ``Part``s do not specify a role, this method is intended for generating content from /// [zero-shot](https://developers.google.com/machine-learning/glossary/generative#zero-shot-prompting) /// or "direct" prompts. For /// [few-shot](https://developers.google.com/machine-learning/glossary/generative#few-shot-prompting) - /// prompts, see `generateContent(_ content: @autoclosure () throws -> [ModelContent])`. + /// prompts, see `generateContent(_ content: [ModelContent])`. /// - /// - Parameter content: The input(s) given to the model as a prompt (see ``PartsRepresentable`` - /// for conforming types). + /// - Parameters: + /// - parts: The input(s) given to the model as a prompt (see ``PartsRepresentable`` for + /// conforming types). /// - Returns: The content generated by the model. /// - Throws: A ``GenerateContentError`` if the request failed. public func generateContent(_ parts: any PartsRepresentable...) @@ -153,17 +153,17 @@ public final class GenerativeModel { } /// Generates content from String and/or image inputs, given to the model as a prompt, that are - /// representable as one or more ``ModelContent/Part``s. + /// representable as one or more ``Part``s. /// - /// Since ``ModelContent/Part``s do not specify a role, this method is intended for generating - /// content from + /// Since ``Part``s do not specify a role, this method is intended for generating content from /// [zero-shot](https://developers.google.com/machine-learning/glossary/generative#zero-shot-prompting) /// or "direct" prompts. For /// [few-shot](https://developers.google.com/machine-learning/glossary/generative#few-shot-prompting) /// prompts, see `generateContentStream(_ content: @autoclosure () throws -> [ModelContent])`. /// - /// - Parameter content: The input(s) given to the model as a prompt (see - /// ``PartsRepresentable`` for conforming types). + /// - Parameters: + /// - parts: The input(s) given to the model as a prompt (see ``PartsRepresentable`` for + /// conforming types). /// - Returns: A stream wrapping content generated by the model or a ``GenerateContentError`` /// error if an error occurred. @available(macOS 12.0, *) @@ -228,21 +228,20 @@ public final class GenerativeModel { } /// Runs the model's tokenizer on String and/or image inputs that are representable as one or more - /// ``ModelContent/Part``s. + /// ``Part``s. /// - /// Since ``ModelContent/Part``s do not specify a role, this method is intended for tokenizing + /// Since ``Part``s do not specify a role, this method is intended for tokenizing /// [zero-shot](https://developers.google.com/machine-learning/glossary/generative#zero-shot-prompting) /// or "direct" prompts. For /// [few-shot](https://developers.google.com/machine-learning/glossary/generative#few-shot-prompting) /// input, see `countTokens(_ content: @autoclosure () throws -> [ModelContent])`. /// - /// - Parameter content: The input(s) given to the model as a prompt (see ``PartsRepresentable`` - /// for conforming types). + /// - Parameters: + /// - parts: The input(s) given to the model as a prompt (see ``PartsRepresentable`` for + /// conforming types). /// - Returns: The results of running the model's tokenizer on the input; contains /// ``CountTokensResponse/totalTokens``. - /// - Throws: A ``CountTokensError`` if the tokenization request failed. - public func countTokens(_ parts: any PartsRepresentable...) async throws - -> CountTokensResponse { + public func countTokens(_ parts: any PartsRepresentable...) async throws -> CountTokensResponse { return try await countTokens([ModelContent(parts: parts)]) } @@ -251,10 +250,7 @@ public final class GenerativeModel { /// - Parameter content: The input given to the model as a prompt. /// - Returns: The results of running the model's tokenizer on the input; contains /// ``CountTokensResponse/totalTokens``. - /// - Throws: A ``CountTokensError`` if the tokenization request failed or the input content was - /// invalid. - public func countTokens(_ content: [ModelContent]) async throws - -> CountTokensResponse { + public func countTokens(_ content: [ModelContent]) async throws -> CountTokensResponse { let countTokensRequest = CountTokensRequest( model: modelResourceName, contents: content, diff --git a/FirebaseVertexAI/Sources/ModelContent.swift b/FirebaseVertexAI/Sources/ModelContent.swift index 9697a97a5bf..885d209e0a1 100644 --- a/FirebaseVertexAI/Sources/ModelContent.swift +++ b/FirebaseVertexAI/Sources/ModelContent.swift @@ -33,7 +33,7 @@ extension [ModelContent] { /// A type describing data in media formats interpretable by an AI model. Each generative AI /// request or response contains an `Array` of ``ModelContent``s, and each ``ModelContent`` value -/// may comprise multiple heterogeneous ``ModelContent/Part``s. +/// may comprise multiple heterogeneous ``Part``s. @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) public struct ModelContent: Equatable, Sendable { enum InternalPart: Equatable, Sendable { diff --git a/FirebaseVertexAI/Sources/Types/Public/Part.swift b/FirebaseVertexAI/Sources/Types/Public/Part.swift index 1eba33ae018..8cc25de1db2 100644 --- a/FirebaseVertexAI/Sources/Types/Public/Part.swift +++ b/FirebaseVertexAI/Sources/Types/Public/Part.swift @@ -104,11 +104,11 @@ public struct FunctionCallPart: Part { } } -/// Result output from a ``FunctionCall``. +/// Result output from a function call. /// /// Contains a string representing the `FunctionDeclaration.name` and a structured JSON object /// containing any output from the function is used as context to the model. This should contain the -/// result of a ``FunctionCall`` made based on model prediction. +/// result of a ``FunctionCallPart`` made based on model prediction. @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) public struct FunctionResponsePart: Part { let functionResponse: FunctionResponse