LanguageModelSession
extension FoundationModels.LanguageModelSession: _ModelSession-
Returns
trueif 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 -> _ModelSessionResponseParameters
promptThe content to send to the model.
schemaAn optional schema for structured outputs.
includeSchemaInPromptWhether to include the
schemain the request to the model; iffalse, structured output (JSON) is requested but the schema is not strictly enforced.optionsA set of options, represented as a
GenerationOptionsRepresentabletype. -
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
promptThe content to send to the model.
schemaAn optional schema for structured outputs.
includeSchemaInPromptWhether to include the
schemain the request to the model; iffalse, structured output (JSON) is requested but the schema is not strictly enforced.optionsA set of options, represented as a
GenerationOptionsRepresentabletype.