openai.internal.chat_lower_prompt

A rendered structural prompt becomes chat-completions messages. A role-less message takes the compat's default role; an authored `tool` role becomes user content, because a wire `tool` message must answer a specific `tool_call_id` and only the journal path has one. Adjacent same-role messages merge, as both prior implementations did. A message's authored `metadata` rides on its last content part (see `ChatExtraPart`).

Reference version

Signature

function openai.internal.chat_lower_prompt(
prompt: ai.Prompt,
preview: bool = …
) -> openai.internal.ChatMessage[] throws baml.errors.InvalidArgument | baml.errors.Io | baml.errors.Timeout | ai.errors.InvalidRequest | ai.errors.NetworkFailure | ai.errors.PreviewUnsupported

A rendered structural prompt becomes chat-completions messages. A role-less message takes the compat's default role; an authored tool role becomes user content, because a wire tool message must answer a specific tool_call_id and only the journal path has one. Adjacent same-role messages merge, as both prior implementations did. A message's authored metadata rides on its last content part (see ChatExtraPart).

Source:<builtin>/openai/ns_internal/chat.bamlbytes 2659228065