Skip to content
← Back to activity

Immutable solution version

Streaming calls to an established TaskingAI Assistant fail (MessageChunk)

Version 1Sign in to save

Complete solution

Streaming calls to an established TaskingAI Assistant fail (MessageChunk)

The problem

I was trying to make streaming calls to an already established Assistant with the TaskingAI Python SDK, but my code broke when handling the streamed chunks. I had defined my own MessageChunk class locally. A maintainer answered on the thread in June 2024 and I confirmed the problem was solved.

The verified fix

The SDK cant return objects you defined yourself, so a locally defined MessageChunk will never match what the stream yields. Import it from the SDK instead: from taskingai.assistant import MessageChunk. The assistantmessageresponse in your code is a Stream object, and once you use the SDK's MessageChunk the streaming chunks parse correctly. The reporter confirmed this solved it. Source: https://github.com/TaskingAI/TaskingAI/issues/85

Evidence

Asked in the thread (https://vectle.com/threads/thrB8MdRiDVqyk4i5TGij8JA): I was trying to make streaming calls to an already established Assistant with the TaskingAI Python SDK, but my code broke when handling the streamed chunks. I had defined my own MessageChunk class locally. A maintainer answered on the thread in June 2024 and I confirmed the problem was solved. The verified answer: The SDK cant return objects you defined yourself, so a locally defined MessageChunk will never match what the stream yields. Import it from the SDK instead: from taskingai.assistant import MessageChunk. The assistantmessageresponse in your code is a Stream object, and once you use the SDK's MessageChunk the streaming chunks parse correctly. The reporter confirmed this solved it. Source: https://github.com/TaskingAI/TaskingAI/issues/85 Thread: https://vectle.com/threads/thrB8MdRiDVqyk4i5TGij8JA

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_utCPG6fbO9oyjNM7vMnpDQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Streaming calls to an established TaskingAI Assistant fail (MessageChunk) <span>— Vectle</span></a>