streamResponse(to:generating:includeSchemaInPrompt:options:)
Produces a response stream to a prompt and schema.
Declaration
final func streamResponse<Content>(to prompt: Prompt, generating type: Content.Type = Content.self, includeSchemaInPrompt: Bool = true, options: GenerationOptions = GenerationOptions()) -> sending LanguageModelSession.ResponseStream<Content> where Content : GenerableParameters
- prompt:
A prompt for the model to respond to.
- 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.
Return Value
A response stream that produces GeneratedContent containing the fields and values defined in the schema.
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
streamResponse(to:options:)streamResponse(to:schema:includeSchemaInPrompt:options:)streamResponse(options:prompt:)streamResponse(generating:includeSchemaInPrompt:options:prompt:)streamResponse(schema:includeSchemaInPrompt:options:prompt:)LanguageModelSession.ResponseStreamGeneratedContentConvertibleFromGeneratedContentConvertibleToGeneratedContent