Skip to content

[Feat]: Send Streaming Message returns Task or Message as an initial response #965

@sokoliva

Description

@sokoliva

Is your feature request related to a problem? Please describe.

Send Streaming Message
Stream Response object containing:
Initial response: Task object OR Message object

Currently this is not enforced:
While modifying hello_world client sample to expect Task or Message object as an initial response

async def _handle_stream(
    stream: Any, current_task_id: str | None
) -> str | None:
    async for event in stream:
        print(event)
        if event.HasField('message'):
            print(f'Message: {get_message_text(event.message, delimiter=" ")}')
            continue
        if not current_task_id:
            if not event.HasField('task'):
                raise RuntimeError(
                    'Expected first streaming event to be a Task or Message, '
                )
            current_task_id = event.task.id
            print(f'Task created with id: {current_task_id}')
        if not current_task_id:
            current_task_id = event.task.id

it returned an error:
Expected first streaming event to be a Task or Message.

Describe the solution you'd like

Enforce first streaming event to be Task or Message object by modifying on_message_send_stream method in DefaultRequestHandlerV2. It should check if the current event is the first event and construct a new_task if it is not neither Task nor Message.

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions