Skip to content

Commit 2935d18

Browse files
committed
debugging
1 parent ce97fd5 commit 2935d18

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

src/renderer/components/Experiment/Foundation/RunModelButton.tsx

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ export default function RunModelButton({
179179
}
180180

181181
useEffect(() => {
182-
if (!data || !pipelineTagLoaded || supportedEngines.length === 0) return;
182+
// Add this single line to wait for pipeline tag loading
183+
if (!data || !pipelineTagLoaded) return;
183184

184185
let objExperimentInfo = null;
185186
if (experimentInfo?.config?.inferenceParams) {
@@ -190,34 +191,57 @@ export default function RunModelButton({
190191
}
191192
}
192193

194+
// Check if current engine is still supported after filtering
193195
const currentEngine = objExperimentInfo?.inferenceEngine;
194196
const currentEngineIsSupported = supportedEngines.some(
195197
(engine) => engine.uniqueId === currentEngine,
196198
);
197199

198-
if (!currentEngine || !currentEngineIsSupported) {
199-
const firstEngine = supportedEngines[0];
200-
const newSettings = {
201-
inferenceEngine: firstEngine.uniqueId,
202-
inferenceEngineFriendlyName: firstEngine.name,
203-
};
204-
setInferenceSettings(newSettings);
205-
206-
if (experimentInfo?.id) {
207-
fetch(
208-
chatAPI.Endpoints.Experiment.UpdateConfig(
209-
experimentInfo.id,
210-
'inferenceParams',
211-
JSON.stringify(newSettings),
212-
),
213-
).catch(console.error);
200+
if (
201+
objExperimentInfo == null ||
202+
objExperimentInfo?.inferenceEngine == null ||
203+
!currentEngineIsSupported // Add this condition
204+
) {
205+
// If there are supportedEngines, set the first one from supported engines as default
206+
if (supportedEngines.length > 0) {
207+
const firstEngine = supportedEngines[0];
208+
const newInferenceSettings = {
209+
inferenceEngine: firstEngine.uniqueId || null,
210+
inferenceEngineFriendlyName: firstEngine.name || '',
211+
};
212+
setInferenceSettings(newInferenceSettings);
213+
214+
// Update the experiment config with the first supported engine
215+
if (experimentInfo?.id) {
216+
fetch(
217+
chatAPI.Endpoints.Experiment.UpdateConfig(
218+
experimentInfo.id,
219+
'inferenceParams',
220+
JSON.stringify(newInferenceSettings),
221+
),
222+
).catch(() => {
223+
console.error(
224+
'Failed to update inferenceParams in experiment config',
225+
);
226+
});
227+
}
228+
} else {
229+
// This preserves the older logic where we try to get the default inference engine for a blank experiment
230+
(async () => {
231+
const { inferenceEngine, inferenceEngineFriendlyName } =
232+
await getDefaultinferenceEngines();
233+
setInferenceSettings({
234+
inferenceEngine: inferenceEngine || null,
235+
inferenceEngineFriendlyName: inferenceEngineFriendlyName || null,
236+
});
237+
})();
214238
}
215239
} else {
216240
setInferenceSettings(objExperimentInfo);
217241
}
218242
}, [
219243
data,
220-
pipelineTagLoaded,
244+
pipelineTagLoaded, // Add this dependency
221245
supportedEngines,
222246
experimentInfo?.id,
223247
experimentInfo?.config?.inferenceParams,

0 commit comments

Comments
 (0)