image-landscapeMaintaining Historical Dialogue

In a real-time digital human system, the character's behavior, tone, knowledge structure, and multi-turn dialogue "memory" are controlled through two mechanisms:

1. Conversation Item Creation Message (Unidirectional User Memory)

The system supports building context by sending historical user messages one by one, but this method has significant limitations:

conversationHistory.forEach((msg) => {
  if (msg.role === "user") {
    const messageConfig = {
      type: "conversation.item.create",
      item: {
        type: "message",
        role: "user",
        content: [{ type: "input_text", text: msg.content }]
      }
    };
    socket.send(JSON.stringify(messageConfig));
  }
});
circle-exclamation
triangle-exclamation

2. System Instructions Injection for Context

By using the instructions field in session.update, role definitions and historical context descriptions can be injected. This way, ${messageConfig} can fully retain the dialogue history between the user and AI, which helps to:

  • Maintain semantic coherence.

  • Support the AI's continuous understanding and memory.

  • Support ongoing control of the AI's tone and behavior.

circle-exclamation

Last updated