I hope you are all doing good.
I'm having an issue with this code and I don't understand what I'm doing wrong... I'm a newby in all of this so that might be a dumb question.
I get this openai.error.InvalidRequestError: 'text-classification' is not one of ['fine-tune'] - 'purpose'
error whenever i try to load my code, I get the same error even if i change text-classification to other things such as answers or search.
Do you have any idea why?
This is the code I tried.
import openai
import os
openai.api_key = 'My Api key'
def envoyer_fichier_texte(fichier_texte, purpose):
response = openai.File.create(
file=fichier_texte,
purpose=purpose
)
return response['id']
dossier_texte = 'path to my files'
fichiers_texte = [fichier for fichier in os.listdir(dossier_texte) if fichier.endswith('.txt')]
purpose = "text-classification"
ids_fichiers = []
for fichier in fichiers_texte:
chemin_fichier = os.path.join(dossier_texte, fichier)
with open(chemin_fichier, 'r') as f:
contenu_fichier = f.read()
file_id = envoyer_fichier_texte(contenu_fichier, purpose)
ids_fichiers.append(file_id)
for i, file_id in enumerate(ids_fichiers):
print(f"ID du fichier {i+1} :", file_id)