Skip to main content

test_assistant_message

Function test_assistant_message 

Source
pub fn test_assistant_message(text: &str) -> Message
Expand description

Create a test assistant Message with the given text.

Shorthand for Message::assistant(text). Useful for constructing conversation histories where the assistant has already replied. The returned message has Role::Assistant and a single MessagePart::Text variant.

Use this when simulating a multi-turn conversation where the assistant’s previous reply is part of the context sent to the model.

§Example

use loopctl::testing::test_assistant_message;
use loopctl::message::Role;

let msg = test_assistant_message("The answer is 4.");
assert_eq!(msg.role, Role::Assistant);