mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-25 22:35:43 -03:00
0.70
This commit is contained in:
@@ -10,10 +10,16 @@ app.registerExtension({
|
||||
"select_model_here",
|
||||
"",
|
||||
(v) => {
|
||||
// When model_list changes, update model_name
|
||||
const modelNameWidget = node.widgets.find(w => w.name === "model_name");
|
||||
if (modelNameWidget) {
|
||||
modelNameWidget.value = v;
|
||||
try {
|
||||
// When model_list changes, update model_name
|
||||
const modelNameWidget = node.widgets.find(w => w.name === "model_name");
|
||||
if (modelNameWidget) {
|
||||
modelNameWidget.value = v;
|
||||
} else {
|
||||
console.error('[Ollama Config] Model name widget not found');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Ollama Config] Error updating model name:', error);
|
||||
}
|
||||
},
|
||||
{ values: [] }
|
||||
@@ -26,13 +32,26 @@ app.registerExtension({
|
||||
value: "Update Models",
|
||||
callback: async function() {
|
||||
try {
|
||||
const url = node.widgets.find(w => w.name === "ollama_url").value;
|
||||
const url = node.widgets.find(w => w.name === "ollama_url")?.value;
|
||||
if (!url) {
|
||||
console.error('[Ollama Config] Ollama URL is not set');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[Ollama Config] Fetching models from:', url);
|
||||
const response = await fetch(`${url}/api/tags`);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('[Ollama Config] Server response not OK:', response.status, response.statusText);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.models) {
|
||||
const modelNames = data.models.map(m => m.name);
|
||||
if (modelNames.length > 0) {
|
||||
console.log('Found models:', modelNames);
|
||||
// Update model_list widget
|
||||
modelListWidget.options.values = modelNames;
|
||||
modelListWidget.value = modelNames[0];
|
||||
@@ -41,11 +60,22 @@ app.registerExtension({
|
||||
const modelNameWidget = node.widgets.find(w => w.name === "model_name");
|
||||
if (modelNameWidget) {
|
||||
modelNameWidget.value = modelNames[0];
|
||||
} else {
|
||||
console.error('[Ollama Config] Model name widget not found');
|
||||
}
|
||||
} else {
|
||||
console.error('[Ollama Config] No models found in response');
|
||||
}
|
||||
} else {
|
||||
console.error('[Ollama Config] Invalid response format:', data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error updating models:', error);
|
||||
console.error('[Ollama Config] Error updating models:', error);
|
||||
console.error('[Ollama Config] Error details:', {
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user