Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -51,12 +51,21 @@ def generate_response(input_text):
|
|
51 |
|
52 |
|
53 |
def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
|
|
|
|
|
54 |
# Récupération du fichier à partir de l'URL fournie
|
55 |
response = requests.get(dataset_path)
|
56 |
dataset_lines = response.text.strip().split('\n')
|
57 |
|
58 |
-
#
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
# Créer un Dataset Hugging Face
|
62 |
dataset = Dataset.from_dict({
|
@@ -114,6 +123,7 @@ def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
|
|
114 |
return "Fine-tuning terminé et modèle sauvegardé."
|
115 |
|
116 |
|
|
|
117 |
# Interface Gradio
|
118 |
with gr.Blocks() as demo:
|
119 |
with gr.Tab("Chatbot"):
|
|
|
51 |
|
52 |
|
53 |
def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
|
54 |
+
import json # Assurez-vous que json est importé
|
55 |
+
|
56 |
# Récupération du fichier à partir de l'URL fournie
|
57 |
response = requests.get(dataset_path)
|
58 |
dataset_lines = response.text.strip().split('\n')
|
59 |
|
60 |
+
# Vérifier si le fichier est au format JSONL ou JSON
|
61 |
+
if dataset_path.endswith('.jsonl'):
|
62 |
+
# Convertir les lignes en dictionnaires pour JSONL
|
63 |
+
dataset_dict = [json.loads(line) for line in dataset_lines if line]
|
64 |
+
elif dataset_path.endswith('.json'):
|
65 |
+
# Charger le fichier JSON directement
|
66 |
+
dataset_dict = json.loads(response.text)
|
67 |
+
else:
|
68 |
+
raise ValueError("Format de fichier non supporté. Utilisez .jsonl ou .json.")
|
69 |
|
70 |
# Créer un Dataset Hugging Face
|
71 |
dataset = Dataset.from_dict({
|
|
|
123 |
return "Fine-tuning terminé et modèle sauvegardé."
|
124 |
|
125 |
|
126 |
+
|
127 |
# Interface Gradio
|
128 |
with gr.Blocks() as demo:
|
129 |
with gr.Tab("Chatbot"):
|