|
1 | 1 | import React, { useState, useEffect } from 'react'; |
2 | 2 | import { useNavigate } from 'react-router-dom'; |
3 | | -import { config, getSystemInfo, uploadDataset, startTraining } from '../services/api'; |
| 3 | +import { config, getSystemInfo, validateDatasetPath, startTraining } from '../services/api'; |
4 | 4 |
|
5 | 5 | const FinetuneSettings = ({ defaultValues, updateSettings }) => { |
6 | 6 | const navigate = useNavigate(); |
7 | 7 | const [showAdvanced, setShowAdvanced] = useState(false); |
8 | | - const [selectedFile, setSelectedFile] = useState(null); |
| 8 | + const [datasetPath, setDatasetPath] = useState(''); |
9 | 9 | const [formState, setFormState] = useState({}); |
10 | 10 | const [settingsUpdated, setSettingsUpdated] = useState(false); |
11 | 11 | const [activeTooltip, setActiveTooltip] = useState(null); |
@@ -67,7 +67,6 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => { |
67 | 67 | }; |
68 | 68 |
|
69 | 69 | console.log("Merged form state:", mergedState); |
70 | | - defaultValues = mergedState; |
71 | 70 | setFormState(mergedState); |
72 | 71 | } catch (err) { |
73 | 72 | console.error("Error fetching settings:", err); |
@@ -95,9 +94,8 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => { |
95 | 94 | } |
96 | 95 | }, [defaultValues]); |
97 | 96 |
|
98 | | - const handleFileChange = (e) => { |
99 | | - const file = e.target.files[0]; |
100 | | - setSelectedFile(file); |
| 97 | + const handleDatasetPathChange = (e) => { |
| 98 | + setDatasetPath(e.target.value); |
101 | 99 | }; |
102 | 100 |
|
103 | 101 | const handleInputChange = (e) => { |
@@ -144,16 +142,16 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => { |
144 | 142 | return; |
145 | 143 | } |
146 | 144 |
|
147 | | - // Step 1: Upload dataset if provided |
148 | | - if (selectedFile) { |
149 | | - console.log("Uploading dataset..."); |
150 | | - const uploadResponse = await uploadDataset(selectedFile, formState); |
151 | | - console.log("Dataset uploaded:", uploadResponse); |
152 | | - |
153 | | - // Update form state with the uploaded file path |
154 | | - formState.dataset = uploadResponse.file_path; |
| 145 | + // Step 1: Validate dataset path |
| 146 | + if (datasetPath.trim()) { |
| 147 | + console.log("Validating dataset path..."); |
| 148 | + const validateResponse = await validateDatasetPath(datasetPath.trim()); |
| 149 | + console.log("Dataset validated:", validateResponse); |
| 150 | + |
| 151 | + // Update form state with the validated file path |
| 152 | + formState.dataset = validateResponse.file_path; |
155 | 153 | } else { |
156 | | - throw new Error("Please select a dataset file"); |
| 154 | + throw new Error("Please enter the path to your dataset file"); |
157 | 155 | } |
158 | 156 |
|
159 | 157 | // Step 2: Prepare training configuration |
@@ -240,7 +238,7 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => { |
240 | 238 | learning_rate: "How quickly the model adapts to new information", |
241 | 239 | per_device_train_batch_size: "How many examples are processed at once", |
242 | 240 | max_seq_length: "Maximum text length the model can handle", |
243 | | - dataset_file: "Your training examples in JSON format", |
| 241 | + dataset_file: "Path to your local training data file (JSON or JSONL format)", |
244 | 242 | lora_r: "Controls model capacity and training speed", |
245 | 243 | lora_alpha: "Controls how much the model changes during training", |
246 | 244 | quantization: "Reduces model size to fit in memory", |
@@ -496,39 +494,21 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => { |
496 | 494 |
|
497 | 495 | <div className="col-span-full"> |
498 | 496 | <Tooltip id="dataset_file"> |
499 | | - <label htmlFor="dataset_file" className="block text-sm font-medium text-gray-400 mb-1"> |
500 | | - Dataset File |
| 497 | + <label htmlFor="dataset_path" className="block text-sm font-medium text-gray-400 mb-1"> |
| 498 | + Dataset File Path |
501 | 499 | </label> |
502 | 500 | </Tooltip> |
503 | | - <div className="flex items-center"> |
504 | | - <label className="w-full flex items-center justify-center px-4 py-2 border border-gray-700 rounded-lg cursor-pointer bg-gray-900 hover:bg-gray-800 transition"> |
505 | | - <svg |
506 | | - xmlns="http://www.w3.org/2000/svg" |
507 | | - className="h-5 w-5 mr-2 text-gray-400" |
508 | | - fill="none" |
509 | | - viewBox="0 0 24 24" |
510 | | - stroke="currentColor" |
511 | | - > |
512 | | - <path |
513 | | - strokeLinecap="round" |
514 | | - strokeLinejoin="round" |
515 | | - strokeWidth={2} |
516 | | - d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" |
517 | | - /> |
518 | | - </svg> |
519 | | - <span className="text-white">Upload Dataset</span> |
520 | | - <input |
521 | | - type="file" |
522 | | - id="dataset_file" |
523 | | - name="dataset_file" |
524 | | - accept=".json,.jsonl" |
525 | | - className="hidden" |
526 | | - onChange={handleFileChange} |
527 | | - /> |
528 | | - </label> |
529 | | - </div> |
| 501 | + <input |
| 502 | + type="text" |
| 503 | + id="dataset_path" |
| 504 | + name="dataset_path" |
| 505 | + placeholder="C:\path\to\your\dataset.json" |
| 506 | + value={datasetPath} |
| 507 | + onChange={handleDatasetPathChange} |
| 508 | + className="bg-gray-900 border border-gray-700 rounded-lg p-3 w-full text-white focus:border-orange-500 focus:outline-none" |
| 509 | + /> |
530 | 510 | <p className="mt-2 text-sm text-gray-400"> |
531 | | - {selectedFile ? selectedFile.name : 'No file selected'} |
| 511 | + Enter the full path to your local JSON or JSONL dataset file |
532 | 512 | </p> |
533 | 513 | </div> |
534 | 514 | </div> |
|
0 commit comments