How to upload HTML string as file to OpenAI vector store?

While uploading a file via the playground works great, uploading the same file via API appears to succeed, and is listed in the Assistant’s Vector Store, but the Assistant won’t use it.

I have tried MANY variations on the API call (without the content_type, without io, without encoding the string at all, etc)

file_contents = '\<html>\<body>My info here\</body>\</html>'  
pseudo_file = io.BytesIO(file_contents.encode('utf-8'))      
meta_file = client.beta.vector_stores.files.upload_and_poll(vector_store_id=MY_ID, file=('my_file.html', pseudo_file , 'text/html'))

I have tried downloading the uploaded file to see what openAI did with/to it, but I get an error that it’s not permissible to download a file with an ‘assistants’ purpose.

Note that this is a serverless environment, so I don’t have an actual file when dealing with the API: I have a string. Hence all the encoding, IO, etc., which the API appears to explicitly support.

Welcome to the dev forum @AICurious

Are you updating the assistant to use this new vector store, once the files have been uploaded and processed?

1 Like