Skip to content

create_ag2_event

fastagency.runtimes.ag2.ag2.create_ag2_event #

create_ag2_event(
    type: Optional[str] = None, **kwargs: Any
) -> BaseEvent
Source code in fastagency/runtimes/ag2/ag2.py
def create_ag2_event(type: Optional[str] = None, **kwargs: Any) -> "BaseEvent":
    type = type or "text"
    if type not in EVENT_CLASSES:
        raise ValueError(f"Unknown event type: {type}")

    # Get the ag2 event class
    cls = EVENT_CLASSES[type]

    content = kwargs.pop("content", {})
    kwargs.update(content)

    return cls(**kwargs)