injectJsonInstructionIntoMessages

fun injectJsonInstructionIntoMessages(messages: List<ModelMessage>, schema: JsonElement? = null, schemaPrefix: String? = if (schema != null) DEFAULT_SCHEMA_PREFIX else null, schemaSuffix: String? = if (schema != null) DEFAULT_SCHEMA_SUFFIX else DEFAULT_GENERIC_SUFFIX): List<ModelMessage>(source)

Splice injectJsonInstruction into a message list's system prompt.

If the first message is a MessageRole.System message, its text is used as the prompt seed and the whole leading system message is replaced by the injected one. Otherwise a fresh system message is prepended. The remaining messages pass through untouched.

This is the provider-side entry point a LiteRt LanguageModel would call before generation when the caller requested structured output but the engine has no native JSON mode.

Since

0.3.0-beta01