Skip to content

pixano.features.schemas.entities.conversation

Conversation(created_at=None, updated_at=None, **data)

Bases: Entity

A Conversation entity.

A conversation is an object refered by Message annotations via their entity_ref attribute.

Attributes:

Name Type Description
kind str

Agnostic metadata to store information of the conversation.

with_model SourceRef

Model source reference, or may refer to the groundtruth source.

Source code in pixano/features/schemas/base_schema.py
def __init__(self, /, created_at: datetime | None = None, updated_at: datetime | None = None, **data: Any):
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.

    Args:
        created_at: The creation date of the object.
        updated_at: The last modification date of the object.
        data: The data of the object validated by Pydantic.
    """
    created_at, updated_at = validate_and_init_create_at_and_update_at(created_at, updated_at)
    data.update({"created_at": created_at, "updated_at": updated_at})
    super().__init__(**data)

create_conversation(kind, with_model=SourceRef.none(), id='', item_ref=ItemRef.none(), view_ref=ViewRef.none(), parent_ref=EntityRef.none())

Create a Conversation instance.

Parameters:

Name Type Description Default
kind str

Agnostic metadata to store information of the conversation.

required
with_model SourceRef

Model source reference, or may refer to the groundtruth source.

none()
id str

Conversation ID.

''
item_ref ItemRef

Item reference.

none()
view_ref ViewRef

View reference.

none()
parent_ref EntityRef

Entity reference.

none()

Returns:

Type Description
Conversation

The created Conversation instance.

Source code in pixano/features/schemas/entities/conversation.py
def create_conversation(
    kind: str,
    with_model: SourceRef = SourceRef.none(),
    id: str = "",
    item_ref: ItemRef = ItemRef.none(),
    view_ref: ViewRef = ViewRef.none(),
    parent_ref: EntityRef = EntityRef.none(),
) -> Conversation:
    """Create a `Conversation` instance.

    Args:
        kind: Agnostic metadata to store information of the conversation.
        with_model: Model source reference, or may refer to the groundtruth source.
        id: Conversation ID.
        item_ref: Item reference.
        view_ref: View reference.
        parent_ref: Entity reference.

    Returns:
        The created `Conversation` instance.
    """
    return Conversation(
        id=id,
        item_ref=item_ref,
        view_ref=view_ref,
        parent_ref=parent_ref,
        kind=kind,
        with_model=with_model,
    )

is_conversation(cls, strict=False)

Check if the given class is a Conversation or a subclass of Conversation.

Source code in pixano/features/schemas/entities/conversation.py
def is_conversation(cls: type, strict: bool = False) -> bool:
    """Check if the given class is a `Conversation` or a subclass of `Conversation`."""
    return issubclass_strict(cls, Conversation, strict)