artefactual.preprocessing.read_message#

artefactual.preprocessing.read_message(completion)[source]#

What the model said, or None if the payload carries no text.

The single reading of choices[0].message.content, so no caller has to index a raw payload and none has to decide what an unusable one means. None covers every way the text can be absent – no completion at all, as a failed batch line yields; an error object where the completion belongs; a completion with no choices; a choice whose message or content is null.

Parameters:

completion (Any) – A chat completion, as a mapping or an attribute-style object. A batch line’s completion is exactly this.

Return type:

str | None

Returns:

The assistant’s text, unmodified, or None.