Spaces:
Sleeping
Sleeping
Commit
·
26574d0
1
Parent(s):
1c54318
added loading when space is starting
Browse files- frontend/src/App.jsx +22 -0
- frontend/src/components/Options.jsx +16 -5
frontend/src/App.jsx
CHANGED
|
@@ -15,6 +15,7 @@ function App() {
|
|
| 15 |
const [linearLambdas, setLinearLambdas] = useState([0.5, 0.5]);
|
| 16 |
const [mergedName, setMergedName] = useState("merged");
|
| 17 |
const [numLayers, setNumLayers] = useState(12);
|
|
|
|
| 18 |
|
| 19 |
const { fetchModels, checkTaskStatus } = useAPI();
|
| 20 |
|
|
@@ -32,15 +33,20 @@ function App() {
|
|
| 32 |
(result) => {
|
| 33 |
if (result && Array.isArray(result.response)) {
|
| 34 |
setModels(result.response);
|
|
|
|
| 35 |
}
|
| 36 |
},
|
| 37 |
(error) => {
|
| 38 |
devError("Failed to load models:", error);
|
|
|
|
| 39 |
}
|
| 40 |
);
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
} catch (error) {
|
| 43 |
devError("Error fetching models:", error);
|
|
|
|
| 44 |
}
|
| 45 |
};
|
| 46 |
|
|
@@ -78,6 +84,21 @@ function App() {
|
|
| 78 |
</svg>
|
| 79 |
</a>
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
<Options
|
| 82 |
models={models}
|
| 83 |
selectedModel1={selectedModel1}
|
|
@@ -92,6 +113,7 @@ function App() {
|
|
| 92 |
setModels={setModels}
|
| 93 |
mergedName={mergedName}
|
| 94 |
setMergedName={setMergedName}
|
|
|
|
| 95 |
/>
|
| 96 |
<Recipe
|
| 97 |
layerRecipe={layerRecipe}
|
|
|
|
| 15 |
const [linearLambdas, setLinearLambdas] = useState([0.5, 0.5]);
|
| 16 |
const [mergedName, setMergedName] = useState("merged");
|
| 17 |
const [numLayers, setNumLayers] = useState(12);
|
| 18 |
+
const [isSpaceLoading, setIsSpaceLoading] = useState(true);
|
| 19 |
|
| 20 |
const { fetchModels, checkTaskStatus } = useAPI();
|
| 21 |
|
|
|
|
| 33 |
(result) => {
|
| 34 |
if (result && Array.isArray(result.response)) {
|
| 35 |
setModels(result.response);
|
| 36 |
+
setIsSpaceLoading(false);
|
| 37 |
}
|
| 38 |
},
|
| 39 |
(error) => {
|
| 40 |
devError("Failed to load models:", error);
|
| 41 |
+
setIsSpaceLoading(false); // Set to false even on error
|
| 42 |
}
|
| 43 |
);
|
| 44 |
+
} else {
|
| 45 |
+
setIsSpaceLoading(false);
|
| 46 |
}
|
| 47 |
} catch (error) {
|
| 48 |
devError("Error fetching models:", error);
|
| 49 |
+
setIsSpaceLoading(false); // Set to false even on error
|
| 50 |
}
|
| 51 |
};
|
| 52 |
|
|
|
|
| 84 |
</svg>
|
| 85 |
</a>
|
| 86 |
|
| 87 |
+
{/* Loading Overlay */}
|
| 88 |
+
{isSpaceLoading && (
|
| 89 |
+
<div className="fixed inset-0 bg-background/90 backdrop-blur-sm z-50 flex items-center justify-center">
|
| 90 |
+
<div className="text-center">
|
| 91 |
+
<div className="animate-spin w-12 h-12 border-4 border-primary-500 border-t-transparent rounded-full mx-auto mb-4"></div>
|
| 92 |
+
<h2 className="text-xl font-semibold text-foreground mb-2">
|
| 93 |
+
Space is starting up...
|
| 94 |
+
</h2>
|
| 95 |
+
<p className="text-secondary-600">
|
| 96 |
+
Initializing Evolution Transformer
|
| 97 |
+
</p>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
)}
|
| 101 |
+
|
| 102 |
<Options
|
| 103 |
models={models}
|
| 104 |
selectedModel1={selectedModel1}
|
|
|
|
| 113 |
setModels={setModels}
|
| 114 |
mergedName={mergedName}
|
| 115 |
setMergedName={setMergedName}
|
| 116 |
+
isSpaceLoading={isSpaceLoading}
|
| 117 |
/>
|
| 118 |
<Recipe
|
| 119 |
layerRecipe={layerRecipe}
|
frontend/src/components/Options.jsx
CHANGED
|
@@ -20,6 +20,7 @@ const Options = ({
|
|
| 20 |
setModels,
|
| 21 |
mergedName,
|
| 22 |
setMergedName,
|
|
|
|
| 23 |
}) => {
|
| 24 |
const [isLoading, setIsLoading] = useState(false);
|
| 25 |
const [mergeStatus, setMergeStatus] = useState("");
|
|
@@ -130,8 +131,10 @@ const Options = ({
|
|
| 130 |
onSelect={setSelectedModel1}
|
| 131 |
options={models}
|
| 132 |
placeholder="Select base model..."
|
| 133 |
-
loading={models.length === 0}
|
| 134 |
-
loadingMessage=
|
|
|
|
|
|
|
| 135 |
emptyMessage="No models available"
|
| 136 |
showSearch={true}
|
| 137 |
searchPlaceholder="Search models..."
|
|
@@ -143,8 +146,10 @@ const Options = ({
|
|
| 143 |
onSelect={setSelectedModel2}
|
| 144 |
options={models}
|
| 145 |
placeholder="Select target model..."
|
| 146 |
-
loading={models.length === 0}
|
| 147 |
-
loadingMessage=
|
|
|
|
|
|
|
| 148 |
emptyMessage="No models available"
|
| 149 |
showSearch={true}
|
| 150 |
searchPlaceholder="Search models..."
|
|
@@ -218,6 +223,7 @@ const Options = ({
|
|
| 218 |
<button
|
| 219 |
onClick={handleMerge}
|
| 220 |
disabled={
|
|
|
|
| 221 |
isLoading ||
|
| 222 |
!selectedModel1 ||
|
| 223 |
!selectedModel2 ||
|
|
@@ -226,7 +232,12 @@ const Options = ({
|
|
| 226 |
}
|
| 227 |
className="w-full py-2.5 px-3 bg-gradient-to-r from-accent-500 to-primary-500 text-background font-medium rounded-lg hover:from-accent-600 hover:to-primary-600 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center space-x-2 text-sm"
|
| 228 |
>
|
| 229 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
<>
|
| 231 |
<div className="animate-spin w-3.5 h-3.5 border-2 border-background border-t-transparent rounded-full"></div>
|
| 232 |
<span>Merging...</span>
|
|
|
|
| 20 |
setModels,
|
| 21 |
mergedName,
|
| 22 |
setMergedName,
|
| 23 |
+
isSpaceLoading,
|
| 24 |
}) => {
|
| 25 |
const [isLoading, setIsLoading] = useState(false);
|
| 26 |
const [mergeStatus, setMergeStatus] = useState("");
|
|
|
|
| 131 |
onSelect={setSelectedModel1}
|
| 132 |
options={models}
|
| 133 |
placeholder="Select base model..."
|
| 134 |
+
loading={isSpaceLoading || models.length === 0}
|
| 135 |
+
loadingMessage={
|
| 136 |
+
isSpaceLoading ? "Space is starting up..." : "Loading models..."
|
| 137 |
+
}
|
| 138 |
emptyMessage="No models available"
|
| 139 |
showSearch={true}
|
| 140 |
searchPlaceholder="Search models..."
|
|
|
|
| 146 |
onSelect={setSelectedModel2}
|
| 147 |
options={models}
|
| 148 |
placeholder="Select target model..."
|
| 149 |
+
loading={isSpaceLoading || models.length === 0}
|
| 150 |
+
loadingMessage={
|
| 151 |
+
isSpaceLoading ? "Space is starting up..." : "Loading models..."
|
| 152 |
+
}
|
| 153 |
emptyMessage="No models available"
|
| 154 |
showSearch={true}
|
| 155 |
searchPlaceholder="Search models..."
|
|
|
|
| 223 |
<button
|
| 224 |
onClick={handleMerge}
|
| 225 |
disabled={
|
| 226 |
+
isSpaceLoading ||
|
| 227 |
isLoading ||
|
| 228 |
!selectedModel1 ||
|
| 229 |
!selectedModel2 ||
|
|
|
|
| 232 |
}
|
| 233 |
className="w-full py-2.5 px-3 bg-gradient-to-r from-accent-500 to-primary-500 text-background font-medium rounded-lg hover:from-accent-600 hover:to-primary-600 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center space-x-2 text-sm"
|
| 234 |
>
|
| 235 |
+
{isSpaceLoading ? (
|
| 236 |
+
<>
|
| 237 |
+
<div className="animate-spin w-3.5 h-3.5 border-2 border-background border-t-transparent rounded-full"></div>
|
| 238 |
+
<span>Starting up...</span>
|
| 239 |
+
</>
|
| 240 |
+
) : isLoading ? (
|
| 241 |
<>
|
| 242 |
<div className="animate-spin w-3.5 h-3.5 border-2 border-background border-t-transparent rounded-full"></div>
|
| 243 |
<span>Merging...</span>
|