Is there a way I can remove Annotations in a streaming event so they never print out in the response?
For example, I have an Assistant up and I’m using Flask websockets. Currently this is my implementation of the stream:
event_handler = EventHandler()
with client.beta.threads.runs.stream(
thread_id=thread_id,
assistant_id=assistant_id,
event_handler=event_handler,
tool_choice={"type": "file_search"},
) as stream:
for text in stream.text_deltas:
pass
The event handler Class has a method - on_text_delta()
def on_text_delta(delta, snapshot):
config.socketio.emit('assistant_message', {'text': delta.value}
I’m emitting the value of the TextDelta, but when debugging and printing out the TextDelta stream, I see this:
TextDelta(annotations=None, value=' blank')
TextDelta(annotations=None, value=' on')
TextDelta(annotations=None, value=' the')
TextDelta(annotations=None, value=' form')
TextDelta(annotations=[FileCitationDeltaAnnotation(index=0, type='file_citation', end_index=234, file_citation=FileCitation(file_id='file-xxxxxxxxxxxxx', quote=''), start_index=222, text='【4:1†source】')], value='【4:1†source】')
TextDelta(annotations=None, value='.')
I believe the delta.value is printing out value='【4:1†source】
Is there anywhere to remove this while streaming?