Appends an assistant (AI) message. Used to synchronize the Session state to the "Replied" state, typically for restoring historical dialogues.
This interface ensures the integrity of the conversation's historical chain. If a new User message is appended directly without appending the Assistant's reply, the AI might generate redundant responses due to context breakage.
void LiteRtLm_AppendAssistantMessage(void* conv_ptr, const char* text);
| Parameter | Responsibility |
|---|---|
conv_ptr |
Valid Session handle. |
text |
The AI response plain text content to append. |
// Restore previous conversation turns
LiteRtLm_AppendUserMessage(Conv, "Hello");
LiteRtLm_AppendAssistantMessage(Conv, "Hello! I am your AI assistant.");
// The Session is now in the "Replied" state, waiting for the next user message
LiteRtLm_AppendUserMessage(Conv, "Help me write some C++ code");