conversation_observer
Observer that records a bot’s conversation as a conversation file holds it.
It lets a call the harness didn’t drive, such as a production one, be judged
with pipecat eval judge against a rubric
(EvalRubric) or a simulation’s success
and metrics.
- class pipecat.evals.conversation_observer.EvalConversationEndedMessage(conversation: list[dict])[source]
Bases:
objectA message accompanying
on_conversation_ended.- Parameters:
conversation – The conversation’s messages, as a conversation file holds them (see
pipecat.evals.conversation).
- class pipecat.evals.conversation_observer.EvalConversationObserver(**kwargs)[source]
Bases:
BaseObserverRecords a bot’s conversation, and reports it once the pipeline is done.
Each side’s turn is what the context aggregators write to the LLM context, so the user’s turns are what the bot heard and the bot’s turns are what it said, cut where the user interrupted it. Text a client sends with RTVI’s
send-textis a user turn too, since it goes to the context as is. Each turn is recorded as it is written, so summarizing the context later doesn’t lose it, and the context’s other messages, such as Flows’ tool changes, stay out.It records what passes through the worker it is attached to: in a bot with several workers, that is the one holding the conversation’s context, and calls made in other workers are not in it.
- Events:
- on_conversation_ended(observer, message): Emitted once the pipeline
is done, with an
EvalConversationEndedMessageholding the conversation.
Example:
observer = EvalConversationObserver() @observer.event_handler("on_conversation_ended") async def on_conversation_ended(observer, message: EvalConversationEndedMessage): Path("call.conversation.json").write_text(json.dumps(message.conversation, indent=2), encoding="utf-8") worker = PipelineWorker(pipeline, observers=[observer])
- __init__(**kwargs)[source]
Initialize the observer.
- Parameters:
**kwargs – Additional arguments passed to the parent class.
- async on_push_frame(data: FramePushed)[source]
Add what a frame says about the conversation to it.
- Parameters:
data – The frame push event data.