Skip to content

[python] Defined SDK events should hardcode the type #41

Open
@logan-markewich

Description

@logan-markewich

It's a little annoying that the defined events expect a single type, but I still have to provide that type when instantiating the event object.

Doesn't work

>>> from ag_ui.core.events import TextMessageStartEvent
>>> TextMessageStartEvent(message_id="hello", role="assistant")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/loganmarkewich/giant_change/llama_index/.venv/lib/python3.12/site-packages/pydantic/main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for TextMessageStartEvent
type
  Field required [type=missing, input_value={'message_id': 'hello', 'role': 'assistant'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing

Works

>>> TextMessageStartEvent(message_id="hello", role="assistant", type="TEXT_MESSAGE_START")
TextMessageStartEvent(type=<EventType.TEXT_MESSAGE_START: 'TEXT_MESSAGE_START'>, timestamp=None, raw_event=None, message_id='hello', role='assistant')

Should the SDK just hardcode the type since there is only one option? It'd be more user friendly imo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions