conversation

A conversation between a user and a bot, as a conversation file holds it.

A conversation file is a JSON list of messages, in the order they happened:

  • {"role": "user", "content": ...}: what the user said in one turn.

  • {"role": "assistant", "content": ...}: everything the bot said between two user turns, however turn detection or a function call split it. A turn in which the bot said nothing is not a turn, so the Nth assistant message is bot turn N, the turn a metric’s verdict names.

  • {"role": "tool_call", "name": ..., "arguments": {...}, "cancelled": ...}: a function the bot called, placed before the bot turn it was made in.

The file holds what each side said and the calls the bot made, which is what the judge reads. It has no system prompt, no tool results, and no timing. The harness saves one for every simulation run, and EvalConversationObserver records one from a bot’s own pipeline. Example:

[
  {"role": "assistant", "content": "Hi, how can I help?"},
  {"role": "user", "content": "A table for four on Friday, please."},
  {"role": "tool_call", "name": "check_availability",
   "arguments": {"day": "Friday", "party_size": 4}, "cancelled": false},
  {"role": "assistant", "content": "Let me check. Friday at seven works."}
]
class pipecat.evals.conversation.EvalConversation[source]

Bases: object

Builds a conversation’s messages as the conversation happens.

The user’s turns and the bot’s calls are added as they come. What the bot says gathers into its current turn, which the next user turn, or end_bot_turn(), closes.

__init__()[source]

Initialize an empty conversation.

property messages: list[dict]

The messages so far, without the bot’s turn in progress.

property user_spoke_last: bool

Whether a user turn is the last thing said, with nothing from the bot since.

add_user_message(text: str) → None[source]

Add a user turn, which ends the bot’s turn; empty text only ends the bot’s turn.

add_assistant_message(text: str) → None[source]

Add a segment of what the bot said to its current turn.

add_tool_call(name: str, arguments: dict) → None[source]

Add a function the bot called.

cancel_tool_call(name: str) → None[source]

Mark the bot’s latest call to name that is not cancelled yet as cancelled.

end_bot_turn() → None[source]

End the bot’s turn: what it said since the user last spoke becomes one message.