Source code for agentc_core.activity.models.log
import pydantic
import typing
import uuid
from ..models.content import Content
from agentc_core.version import VersionDescriptor
[docs]
class Log(pydantic.BaseModel):
    """A :py:class:`Log` instance represents a single log record that is bound to a part of the application
    **versioned** according to :py:attr:`catalog_version`.
    .. attention::
        :py:class:`Log` instances are **immutable** and should not be instantiated directly.
        Only :py:class:`Content` instances should be created directly, and then passed to a :py:class:`Span` instance
        via the :py:meth:`agentc.span.Span.log` method.
    """
[docs]
    class Span(pydantic.BaseModel):
        model_config = pydantic.ConfigDict(use_enum_values=True, frozen=True)
        session: str = pydantic.Field(
            description="The 'session' (a runtime identifier) that this span is associated with.",
            default_factory=lambda: uuid.uuid4().hex,
        )
        name: list[str] = pydantic.Field(
            description="The name of the span. This is a list of names that represent the span hierarchy.",
            examples=[["my_application", "my_agent", "my_task"], ["my_application", "my_agent"]],
        ) 
    model_config = pydantic.ConfigDict(use_enum_values=True, frozen=True)
    identifier: str = pydantic.Field(
        description="A unique identifier for this record. This field is typically a UUID.",
        default_factory=lambda: uuid.uuid4().hex,
    )
    span: "Log.Span" = pydantic.Field(
        description="The span (i.e., a list of names and a session ID) that this record is associated with."
    )
    timestamp: pydantic.AwareDatetime = pydantic.Field(
        description="Timestamp of the generated record. This field must have a timezone attached as well.",
        examples=["2024-08-26T12:02:59.500Z", "2024-08-26T12:02:59.500+00:00"],
    )
    content: Content = pydantic.Field(
        description="The content of the record. This should be as close to the producer as possible.",
        discriminator="kind",
    )
    annotations: typing.Optional[typing.Dict] = pydantic.Field(
        description="Additional annotations that can be added to the message.", default=None
    )
    catalog_version: VersionDescriptor = pydantic.Field(
        description="A unique identifier that defines a catalog version / snapshot / commit."
    )