How can I access file_citation?

Hi, I’m currently utilizing the Assistant API along with the retrieval function. I can obtain the output with RAG, but I’m unable to receive the file citations. I’ve been following the instructions on this page, yet regardless of the document I attempt to use with RAG, it doesn’t return any annotations—the section is always blank. I’d like to be able to access the referred documents to determine the length of the retrieved document. Any guidance would be appreciated. Thank you!

For your reference, here is the code I use.

data_name = "path_to_data"
instructions = "instruction"
content = "input"

file = client.files.create(
  file=open(path + f"data/{data_name}", "rb"),
  purpose='assistants'
)

assistant = client.beta.assistants.create(
  instructions=instructions,
  model="gpt-4-1106-preview",
  tools=[{"type": "retrieval"}],
  file_ids=[file.id]
)

thread = client.beta.threads.create()

message = client.beta.threads.messages.create(
    thread_id=thread.id,
    role="user",
    content=content
)

run = client.beta.threads.runs.create(
  thread_id=thread.id,
  assistant_id=assistant.id,
)

messages = client.beta.threads.messages.list(thread_id=thread.id)

message = client.beta.threads.messages.retrieve(
  thread_id=thread.id,
  message_id= messages.data[0].id 
)

message_content = message.content[0].text
annotations = message_content.annotations
annotations #This is always a blank list
1 Like

getting empty results as well. hopefully this is addressed soon.

I am having this same issue. The response string comes in with the annotations like this:

【0†source】【1†source】【2†source】【3†source】【4†source】【5†source】【6†source】【7†source】【8†source】【9†source】【10†source

But the message object returned from the api has an empty annotations array.

1 Like

Same empty array here… any updates fromn thew documentation?

So far the annotation results still are unpredictable. We have seen this issue consistently on our tests. For those following this thread, there is more information about how to improve the chances of your annotations working well here:

1 Like