I have streaming implemented however I do not want the stream to include the ‘annotations’ for citing sources in its response ie: 【20:0†source】
It’s my understanding the stream I have directly below is getting the annotations (citing sources)…
with client.beta.threads.runs.create_and_stream(
thread_id=thread_id,
assistant_id=assistant_id,
event_handler=event_handler,
) as stream:
stream.until_done()
I ‘believe’ the steam is gather the data from the content block - an example below:
{
"id": "msg_abc123",
"object": "thread.message",
"created_at": 1699073585,
"thread_id": "thread_abc123",
"role": "assistant",
"content": [
{
"type": "text",
"text": {
"value": "The rows of the CSV file have been shuffled and saved to a new CSV file. You can download the shuffled CSV file from the following link:\n\n[Download Shuffled CSV File](sandbox:/mnt/data/shuffled_file.csv)",
"annotations": [
{
"type": "file_path",
"text": "sandbox:/mnt/data/shuffled_file.csv",
"start_index": 167,
"end_index": 202,
"file_path": {
"file_id": "file-abc123"
}
}
]
}
}
],
"file_ids": [
"file-abc456"
],
...
},
BUT, how can I stream just the text but without the annotations - see a few examples on the api doc site below:
with client.beta.threads.runs.stream(
thread_id=thread.id,
assistant_id=assistant.id
) as stream:
for event in stream:
# Print the text from text delta events
if event.type == "thread.message.delta" and event.data.delta.content:
print(event.data.delta.content[0].text)
with client.beta.threads.runs.stream(
thread_id=thread.id,
assistant_id=assistant.id
) as stream:
for text in stream.text_deltas:
print(text)