Hi @GenixPRO
I understand that you are encountering an issue with accessing the files via the assistant API. Here are some potential solutions. To retrieve files saved in your Data files sandbox, you can utilize the files. Content endpoint.
from openai import AzureOpenAI
client = AzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-05-01-preview",
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
)
# Replace 'your_file_id' with your actual File ID
file_data = client.files.content("your_file_id")
with open("downloaded_file.pdf", "wb") as file:
file.write(file_data.read())
After retrieving the file, saving it to a public URL is a recommended method for sharing. You can use services such as Azure Blob Storage to host your files publicly and obtain the URL. Currently, accessing files directly from the Data files location with a fully qualified public URL is not straightforward, as it is more of a secure sandbox. The suggested approach is to download the file programmatically and then upload it to a public storage solution.
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.