Simple question, I uploaded a CSV file to my assistant. Now, when my assistant requires action and calls my function find_matching_columns(), I need this function to use the uploaded CSV file and then open it with Pandas. But I can’t get the function to access and pull this uploaded file! Please help, I assume it’s via the file id!
def find_matching_columns(query, file_id, client):
# HOW DO I LOAD THE FILE_ID INTO PANDAS
file_content = client.files.retrieve(file_id)
df = pd.read_csv(io.StringIO(file_content.decode('utf-8')))
column_names = df.columns.tolist()
file = client.files.create(
file=open('data/ap_mock_data.csv', 'rb'),
purpose='assistants'
)
file_id = file.id
assistant = client.beta.assistants.create(
name=assistant_details['name'],
instructions=assistant_details['instructions'],
model=assistant_details['model'],
tools=assistant_details['tools'],
tool_resources={"code_interpreter": {"file_ids": [file.id]}},
)
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=user_message_content,
attachments=[
{
"file_id": file.id,
"tools": [{"type": "code_interpreter"}]
}
]
)