Hi Amin Elsehemy,
Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!
I understand that you are encountering a 404 NotFoundError.
Here are some troubleshooting steps to help resolve this issue:
- Ensure that the file path you're specifying is correct. Double-check the file location and the path provided in your code.
- Verify that your environment variables for the Azure OpenAI endpoint and API key are correctly set. You can confirm this by printing os.getenv("AZURE_OPENAI_ENDPOINT") and os.getenv("AZURE_OPENAI_API_KEY") to ensure the correct values are being passed.
- Make sure that the Azure OpenAI service is available and configured correctly in your resource group, and that you are using the right API version (2024-05-01-preview or later, depending on your specific service setup).
- Test uploading a simple file from the same directory as your script to verify that there isn’t an issue with the file path.
Here’s the updated code for your reference:
# Upload fine-tuning files
import os
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-05-01-preview" # This API version or later is required to access seed/events/checkpoint capabilities
)
training_file_name = 'file path'
validation_file_name = 'file path'
# Upload the training and validation dataset files to Azure OpenAI with the SDK.
training_response = client.files.create(
file=open(training_file_name, "rb"), purpose="fine-tune"
)
training_file_id = training_response.id
validation_response = client.files.create(
file=open(validation_file_name, "rb"), purpose="fine-tune"
)
validation_file_id = validation_response.id
print("Training file ID:", training_file_id)
print("Validation file ID:", validation_file_id)
Here is the screenshot of my results for your reference:
Please refer for more information: Prepare your training and validation data
If you continue to experience difficulties, please feel free to reach out and will escalate the issue to the appropriate team to ensure it is resolved promptly.
I hope this information helps.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful.