How to retrieve file_id when streaming a response from an agent? #12044
-
I'm curious if there's a way to retrieve a file_id (not of type .png or any other image type) when streaming a response from an agent. For example, if I ask the agent (using the code interpreter) to create a plot pie with some random data, the resulting file_id (containing the generated image) is available in the response object under response.content.items as an object of type StreamingFileReferenceContent. However, if I ask the model to generate another file type (such as a text file containing 5 random names) the file_id does not appear in any of the chunks yielded by the streamed response. Is there a way to access the file_id in such cases? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @GabrelBulz, the By the way the reference Which agent type are you working with? |
Beta Was this translation helpful? Give feedback.
Hi @GabrelBulz, the
file_id
handle should be included as part of theStreamingAnnotationContent
'sfile_id
attribute. When you canStreamingChatMessageContent
back from the agent, check for thatStreamingAnnotationContent
item type inside of theitems
collection.By the way the reference
file_id
I am assuming you're working with SK Python (please correct me if I am wrong). You may need to use theon_intermediate_message
callback to get a handle to intermediate messages, if the annotation content isn't returned with the final response.Which agent type are you working with?