hello, everyone.
My script works well in which, I upload a file and have the assistant use it to answer questions. So, what I did was, create an assistant in UI, then copy paste it’s id to a global var names ASSISTANT_ID then I pass it to run. Now, I tried to do the same with file ids but it doesn’t work that way for some reason. the bot keeps saying I have no access to those files. What could be the reason for this? the format? this is my full script:
ASSISTANT_ID = "ASSISTANT_ID_HERE"
FILE_ID = ['file1, 'file2']
thread = client.beta.threads.create()
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="QUESTION_HERE",
file_ids=FILE_ID
)
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=ASSISTANT_ID,
instructions="PROMPT_HERE"
)
# Poll the status until it is completed
while run.status != 'completed':
time.sleep(5) # Wait for 5 seconds before checking again
run = client.beta.threads.runs.retrieve(
thread_id=thread.id,
run_id=run.id
)
print("Run completed. Status:", run.status)
# Fetch the messages
messages = client.beta.threads.messages.list(
thread_id=thread.id
)
# Extracting assistant's message from the list of messages
assistant_messages = [msg.content for msg in messages.data if msg.role == 'assistant']
if assistant_messages:
assistant_content = assistant_messages[0][0].text.value
print("Assistant's Message Content:")
print(assistant_content)
else:
print("No assistant message found in the response.")