Skip to content

datarobot_genai.core.pipeline_interactions

pipeline_interactions

Pipeline-interaction primitives for agent runs.

Each framework agent records its run as a MultiTurnSample: an ordered list of HumanMessage / AIMessage / ToolMessage turns. The chat layer serialises that sample to JSON and ships it as the pipeline_interactions field, which DataRobot moderations reads back to score the run (e.g. agent goal accuracy).

These types used to come from ragas (ragas.MultiTurnSample and ragas.messages). ragas is an unmaintained package with a large, CVE-heavy dependency chain, and we only ever used it to build and JSON-serialise this payload. datarobot-moderations now ships dependency-light equivalents of the message primitives, so we reuse those and keep only a slim, locally-owned MultiTurnSample here. That lets us drop the ragas dependency entirely.

MultiTurnSample

Bases: BaseModel

A multi-turn conversation between the human, the agent and its tools.

Slim replacement for ragas' MultiTurnSample. The only field the downstream moderations consumer reads is user_input; reference is kept for parity with the moderations model.

Source code in datarobot_genai/core/pipeline_interactions.py
class MultiTurnSample(BaseModel):
    """A multi-turn conversation between the human, the agent and its tools.

    Slim replacement for ragas' ``MultiTurnSample``. The only field the downstream
    moderations consumer reads is ``user_input``; ``reference`` is kept for parity
    with the moderations model.
    """

    # Plain (non-discriminated) union, matching the old ragas ``MultiTurnSample``.
    user_input: list[HumanMessage | AIMessage | ToolMessage]
    reference: str | None = None

    def to_dict(self) -> dict[str, Any]:
        """Serialise to a plain dict, dropping unset/None fields."""
        return self.model_dump(exclude_none=True)

to_dict

to_dict() -> dict[str, Any]

Serialise to a plain dict, dropping unset/None fields.

Source code in datarobot_genai/core/pipeline_interactions.py
def to_dict(self) -> dict[str, Any]:
    """Serialise to a plain dict, dropping unset/None fields."""
    return self.model_dump(exclude_none=True)