AttributeError: 'Message' object has no attribute 'delta'

I encountered this error when asking my assistant to generate a response. Here’s my code:

user_message = taskingai.assistant.create_message(
    assistant_id=assistant.assistant_id,
    chat_id=chat.chat_id,
    text="who are you"
)

assistant_message_response = taskingai.assistant.generate_message(
    assistant_id=assistant.assistant_id,
    chat_id=chat.chat_id,
    stream=True,
)

for item in assistant_message_response:
    print(item.delta)

Does that mean there’s a chunk of empty data?

Yes Michael, your assumption is correct. The last chunk of the stream will have no delta, it is the identifier of the end of the streamed response.

Before printing the delta, first check if the delta exists. If it does not contain delta, it represents the end of the stream, and you may check the finish reason at item.finish_reason.