respond(to:generating:includeSchemaInPrompt:options:)
Produces a generable object as a response to a prompt.
Declaration
@discardableResult nonisolated(nonsending) final func respond<Content>(to prompt: String, generating type: Content.Type = Content.self, includeSchemaInPrompt: Bool = true, options: GenerationOptions = GenerationOptions()) async throws -> LanguageModelSession.Response<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.
Mentioned in
Return Value
An instance of the Generable type.
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.