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
2 changes: 2 additions & 0 deletions FirebaseVertexAI/Sources/FunctionCalling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 18 additions & 22 deletions FirebaseVertexAI/Sources/GenerativeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down Expand Up @@ -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, *)
Expand Down Expand Up @@ -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)])
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion FirebaseVertexAI/Sources/ModelContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions FirebaseVertexAI/Sources/Types/Public/Part.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading