FirebaseAILogic Framework Reference

LanguageModelSession

extension FoundationModels.LanguageModelSession: _ModelSession
  • Returns true if the session has history (i.e., it has already had one or more chat turns).

    Declaration

    Swift

    public var _hasHistory: Bool { get }
  • Sends a prompt to the model and returns a _ModelSessionResponse.

    Declaration

    Swift

    public func _respond(to prompt: [any Part], schema: FirebaseAI.GenerationSchema?,
                         includeSchemaInPrompt: Bool,
                         options: any GenerationOptionsRepresentable) async throws
      -> _ModelSessionResponse

    Parameters

    prompt

    The content to send to the model.

    schema

    An optional schema for structured outputs.

    includeSchemaInPrompt

    Whether to include the schema in the request to the model; if false, structured output (JSON) is requested but the schema is not strictly enforced.

    options

    A set of options, represented as a GenerationOptionsRepresentable type.

  • Sends a prompt to the model and streams the model's response.

    Declaration

    Swift

    public func _streamResponse(to prompt: [any Part], schema: FirebaseAI.GenerationSchema?,
                                includeSchemaInPrompt: Bool,
                                options: any GenerationOptionsRepresentable)
      -> sending AsyncThrowingStream<_ModelSessionResponse, any Error>

    Parameters

    prompt

    The content to send to the model.

    schema

    An optional schema for structured outputs.

    includeSchemaInPrompt

    Whether to include the schema in the request to the model; if false, structured output (JSON) is requested but the schema is not strictly enforced.

    options

    A set of options, represented as a GenerationOptionsRepresentable type.