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