Skip to content

Commit d9e6cda

Browse files
authored
Merge pull request #56 from ForgeOpus/fix-finetuning-methods
Fix finetuning methods
2 parents 1fa8088 + fe55a1f commit d9e6cda

23 files changed

Lines changed: 389 additions & 824 deletions

Frontend/package-lock.json

Lines changed: 29 additions & 365 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Frontend/src/App.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// src/App.jsx
22
import React, { useState, useEffect } from 'react';
3-
import { BrowserRouter as Router, Routes, Route, useNavigate } from 'react-router-dom';
3+
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
44
import Navbar from './components/Navbar';
55
import LandingPage from './pages/AppLanding';
66
import DetectHardwarePage from './pages/DetectHardwarePage';
77
import FinetuneSettings from './pages/FinetuningSettingsPage';
88
import Loading from './pages/Loading';
99
import TechnicalDetailsPage from './pages/TechnicalDetailsPage';
10-
import ListModels from './pages/ListModels';
1110
import './index.css';
1211
import ListAllModels from "./pages/ListAllModels";
1312

Frontend/src/components/Navbar.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ const Navbar = ({ appName = "ModelForge" }) => {
8585
);
8686
};
8787

88-
// We're removing the footer since it's not in the screenshot
89-
const renderFooter = () => {
90-
return null;
91-
};
9288

9389
return (
9490
<>

Frontend/src/pages/FinetuningSettingsPage.jsx

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useState, useEffect } from 'react';
22
import { useNavigate } from 'react-router-dom';
3-
import { config, getSystemInfo, uploadDataset, startTraining } from '../services/api';
3+
import { config, getSystemInfo, validateDatasetPath, startTraining } from '../services/api';
44

55
const FinetuneSettings = ({ defaultValues, updateSettings }) => {
66
const navigate = useNavigate();
77
const [showAdvanced, setShowAdvanced] = useState(false);
8-
const [selectedFile, setSelectedFile] = useState(null);
8+
const [datasetPath, setDatasetPath] = useState('');
99
const [formState, setFormState] = useState({});
1010
const [settingsUpdated, setSettingsUpdated] = useState(false);
1111
const [activeTooltip, setActiveTooltip] = useState(null);
@@ -67,7 +67,6 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => {
6767
};
6868

6969
console.log("Merged form state:", mergedState);
70-
defaultValues = mergedState;
7170
setFormState(mergedState);
7271
} catch (err) {
7372
console.error("Error fetching settings:", err);
@@ -95,9 +94,8 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => {
9594
}
9695
}, [defaultValues]);
9796

98-
const handleFileChange = (e) => {
99-
const file = e.target.files[0];
100-
setSelectedFile(file);
97+
const handleDatasetPathChange = (e) => {
98+
setDatasetPath(e.target.value);
10199
};
102100

103101
const handleInputChange = (e) => {
@@ -144,16 +142,16 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => {
144142
return;
145143
}
146144

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;
155153
} else {
156-
throw new Error("Please select a dataset file");
154+
throw new Error("Please enter the path to your dataset file");
157155
}
158156

159157
// Step 2: Prepare training configuration
@@ -240,7 +238,7 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => {
240238
learning_rate: "How quickly the model adapts to new information",
241239
per_device_train_batch_size: "How many examples are processed at once",
242240
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)",
244242
lora_r: "Controls model capacity and training speed",
245243
lora_alpha: "Controls how much the model changes during training",
246244
quantization: "Reduces model size to fit in memory",
@@ -496,39 +494,21 @@ const FinetuneSettings = ({ defaultValues, updateSettings }) => {
496494

497495
<div className="col-span-full">
498496
<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
501499
</label>
502500
</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+
/>
530510
<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
532512
</p>
533513
</div>
534514
</div>

Frontend/src/pages/ListModels.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { useState, useEffect } from 'react';
3-
import { Link, useLocation } from 'react-router-dom';
43

54
const ListModelsPage = () => {
65
const [models, setModels] = useState([]);

Frontend/src/pages/Loading.jsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ const Loading = () => {
2121
"Starting training loop...",
2222
"Training in progress..."
2323
];
24-
25-
// Function to manually set idle status (for demo purposes)
26-
const setTrainingComplete = () => {
27-
setIsIdle(true);
28-
setProgress(100);
29-
setCurrentStep(steps.length - 1);
30-
if (statusIntervalRef.current) {
31-
clearInterval(statusIntervalRef.current);
32-
}
33-
};
3424

3525
// Function to check backend status
3626
useEffect(() => {
@@ -112,19 +102,19 @@ const Loading = () => {
112102
const modelPathResponse = await fetch(`${config.baseURL}/playground/model_path`, {
113103
method: 'GET'
114104
});
115-
105+
116106
if (!modelPathResponse.ok) {
117107
throw new Error('Failed to get model path');
118108
}
119-
109+
120110
// Extract the model path from the response
121111
const modelPathData = await modelPathResponse.json();
122112
const modelPath = modelPathData.model_path;
123-
113+
124114
console.log("Received model path:", modelPath);
125-
115+
126116
// Now send POST request with the model path
127-
const response = await fetch(`${config.baseURL}/playground/new`, {
117+
await fetch(`${config.baseURL}/playground/new`, {
128118
method: 'POST',
129119
headers: {
130120
'Content-Type': 'application/json'
@@ -133,10 +123,10 @@ const Loading = () => {
133123
model_path: modelPath
134124
})
135125
});
136-
126+
137127
// After successful POST request, redirect to homepage
138128
navigate('/');
139-
129+
140130
} catch (error) {
141131
console.error('Error starting AI chat:', error);
142132
// Show an error message to the user

Frontend/src/pages/TechnicalDetailsPage.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useState } from 'react';
2-
import { Link } from 'react-router-dom';
32

43
const TechnicalDetailsPage = () => {
54
const [activeTab, setActiveTab] = useState('architecture');

Frontend/src/services/api.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,26 @@ export const getSystemInfo = async () => {
3030
};
3131

3232
/**
33-
* Upload dataset file
34-
* @param {File} file - Dataset file (JSON/JSONL)
35-
* @param {Object} settings - Training settings
36-
* @returns {Promise<Object>} Upload response
33+
* Validate a local dataset file path
34+
* @param {string} datasetPath - Local file path to the dataset
35+
* @returns {Promise<Object>} Validation response with file_path
3736
*/
38-
export const uploadDataset = async (file, settings) => {
37+
export const validateDatasetPath = async (datasetPath) => {
3938
try {
40-
const formData = new FormData();
41-
formData.append('json_file', file, file.name);
42-
formData.append('settings', JSON.stringify(settings));
43-
44-
const response = await fetch(`${config.baseURL}/finetune/load_settings`, {
39+
const response = await fetch(`${config.baseURL}/finetune/validate_dataset_path`, {
4540
method: 'POST',
46-
body: formData,
41+
headers: config.headers,
42+
body: JSON.stringify({ dataset_path: datasetPath }),
4743
});
4844

4945
if (!response.ok) {
5046
const errorData = await response.json().catch(() => ({}));
51-
throw new Error(errorData.detail || `Upload failed: ${response.status}`);
47+
throw new Error(errorData.detail || `Validation failed: ${response.status}`);
5248
}
5349

5450
return await response.json();
5551
} catch (error) {
56-
console.error('Error uploading dataset:', error);
52+
console.error('Error validating dataset path:', error);
5753
throw error;
5854
}
5955
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"files": {
33
"main.css": "/static/css/main.9680427d.css",
4-
"main.js": "/static/js/main.630cdb63.js",
4+
"main.js": "/static/js/main.9df15fbf.js",
55
"static/js/453.ad6eb26e.chunk.js": "/static/js/453.ad6eb26e.chunk.js",
66
"index.html": "/index.html",
77
"main.9680427d.css.map": "/static/css/main.9680427d.css.map",
8-
"main.630cdb63.js.map": "/static/js/main.630cdb63.js.map",
8+
"main.9df15fbf.js.map": "/static/js/main.9df15fbf.js.map",
99
"453.ad6eb26e.chunk.js.map": "/static/js/453.ad6eb26e.chunk.js.map"
1010
},
1111
"entrypoints": [
1212
"static/css/main.9680427d.css",
13-
"static/js/main.630cdb63.js"
13+
"static/js/main.9df15fbf.js"
1414
]
1515
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ModelForge</title><script defer="defer" src="/static/js/main.630cdb63.js"></script><link href="/static/css/main.9680427d.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ModelForge</title><script defer="defer" src="/static/js/main.9df15fbf.js"></script><link href="/static/css/main.9680427d.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

0 commit comments

Comments
 (0)