Contents

streamResponse(generating:includeSchemaInPrompt:options:prompt:)

Produces a response stream for a type.

Declaration

final func streamResponse<Content>(generating type: Content.Type = Content.self, includeSchemaInPrompt: Bool = true, options: GenerationOptions = GenerationOptions(), @PromptBuilder prompt: () throws -> Prompt) rethrows -> sending LanguageModelSession.ResponseStream<Content> where Content : Generable

Parameters

  • type:

    A type to produce as the response.

  • includeSchemaInPrompt:

    Inject the schema into the prompt to bias the model.

  • options:

    Options that control how tokens are sampled from the distribution the model produces.

  • prompt:

    A prompt for the model to respond to.

Mentioned in

Return Value

A response stream.

Discussion

Consider using the default value of true for includeSchemaInPrompt. The exception to the rule is when the model has knowledge about the expected response format, either because it has been trained on it, or because it has seen exhaustive examples during this session.

See Also

Streaming a response