Skip to content
C

Conversation History Builder

Easypython

Build a conversation history list — the same {"role": ..., "content": ...} structure every chat-based AI API expects — from a system prompt and an alternating sequence of user/assistant messages.

Approach: start the history with the system message, then append each given message, alternating role "user" then "assistant" as the notes' own chatbot pattern does.

Input: First line: the system prompt. Second line: how many messages follow, n. Next n lines: the messages, alternating user then assistant.

Output: One line per history entry (n + 1 total): the entry as a Python dict.

Input (stdin)

Output

Run your code to see output here...