- Package Name: azure-ai-projects
- Package Version: Version: 1.0.0b7
- Operating System: Windows 11
- Python Version: 3.12
Describe the bug
When using exact sample code at
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/async_samples/sample_agents_with_file_search_attachment_async.py
also documented at
https://learn.microsoft.com/en-us/python/api/overview/azure/ai-projects-readme?view=azure-python-preview
https://learn.microsoft.com/en-us/azure/ai-services/agents/how-to/tools/file-search?tabs=python&pivots=upload-files-code-examples
substituting only the connection string (which works correctly otherwise) and filepath (to a local .txt, .docx, or .pdf file), the following error is always returned:
raise HttpResponseError(response=response)
azure.core.exceptions.HttpResponseError: (invalidPayload) purpose contains an invalid purpose.
Code: invalidPayload
Message: purpose contains an invalid purpose
The relevant command triggering the error is:
file_obj = await project_client.agents.upload_file_and_poll(
file_path=temp_path,
purpose=FilePurpose.AGENTS
)
However, this is not the case with the non-async code at https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/sample_agents_file_search.py. The issue appears to be async-only.
To Reproduce
Steps to reproduce the behaviour:
- Run the script https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/agents/async_samples/sample_agents_with_file_search_attachment_async.py, with appropriate working connection string and file to be uploaded.
- I have also tried changing purpose=FilePurpose.AGENTS to purpose="assistants", on basis of the definition of the field at https://learn.microsoft.com/en-us/python/api/azure-ai-projects/azure.ai.projects.operations.agentsoperations?view=azure-python-preview#azure-ai-projects-operations-agentsoperations-upload-file-and-poll, but the error remains the same.
Expected behaviour
I expected the file to be uploaded and polled per the sample script, and per the behaviour with non-async projects.