@@ -903,7 +903,22 @@ void ModelList::updateData(const QString &id, const QVector<QPair<int, QVariant>
903
903
break ;
904
904
}
905
905
case IsEmbeddingModelRole:
906
- info->isEmbeddingModel = value.toBool (); break ;
906
+ {
907
+ if (value.isValid ()) {
908
+ info->isEmbeddingModel = value.toBool ();
909
+ } else if (!info->checkedEmbeddingModel ) {
910
+ auto filename = info->filename ();
911
+ if (!info->installed || info->isOnline ) {
912
+ info->isEmbeddingModel = false ; // can only check installed offline models
913
+ } else {
914
+ // read GGUF and decide based on model architecture
915
+ auto path = (info->dirpath + filename).toStdString ();
916
+ info->isEmbeddingModel = LLModel::Implementation::isEmbeddingModel (path);
917
+ }
918
+ }
919
+ info->checkedEmbeddingModel = true ;
920
+ break ;
921
+ }
907
922
case TemperatureRole:
908
923
info->setTemperature (value.toDouble ()); break ;
909
924
case TopPRole:
@@ -956,21 +971,11 @@ void ModelList::updateData(const QString &id, const QVector<QPair<int, QVariant>
956
971
}
957
972
958
973
// Extra guarantee that these always remains in sync with filesystem
959
- QString modelPath = info->dirpath + info->filename ();
960
- const QFileInfo fileInfo (modelPath);
974
+ const QFileInfo fileInfo (info->dirpath + info->filename ());
961
975
info->installed = fileInfo.exists ();
962
976
const QFileInfo incompleteInfo (incompleteDownloadPath (info->filename ()));
963
977
info->isIncomplete = incompleteInfo.exists ();
964
978
965
- // check installed, discovered/sideloaded models only (including clones)
966
- if (!info->checkedEmbeddingModel && !info->isEmbeddingModel && info->installed
967
- && (info->isDiscovered () || info->description ().isEmpty ()))
968
- {
969
- // read GGUF and decide based on model architecture
970
- info->isEmbeddingModel = LLModel::Implementation::isEmbeddingModel (modelPath.toStdString ());
971
- info->checkedEmbeddingModel = true ;
972
- }
973
-
974
979
if (shouldSort) {
975
980
auto s = m_discoverSort;
976
981
auto d = m_discoverSortDirection;
@@ -999,9 +1004,6 @@ void ModelList::resortModel()
999
1004
1000
1005
void ModelList::updateDataByFilename (const QString &filename, QVector<QPair<int , QVariant>> data)
1001
1006
{
1002
- if (data.isEmpty ())
1003
- return ; // no-op
1004
-
1005
1007
QVector<QString> modelsById;
1006
1008
{
1007
1009
QMutexLocker locker (&m_mutex);
@@ -1015,6 +1017,12 @@ void ModelList::updateDataByFilename(const QString &filename, QVector<QPair<int,
1015
1017
return ;
1016
1018
}
1017
1019
1020
+ if (data.isEmpty ())
1021
+ return ;
1022
+
1023
+ if (data.constLast ().first != IsEmbeddingModelRole)
1024
+ data.append ({ IsEmbeddingModelRole, QVariant () });
1025
+
1018
1026
for (const QString &id : modelsById)
1019
1027
updateData (id, data);
1020
1028
}
@@ -1071,6 +1079,7 @@ QString ModelList::clone(const ModelInfo &model)
1071
1079
{ ModelList::RepeatPenaltyTokensRole, model.repeatPenaltyTokens () },
1072
1080
{ ModelList::PromptTemplateRole, model.promptTemplate () },
1073
1081
{ ModelList::SystemPromptRole, model.systemPrompt () },
1082
+ { ModelList::IsEmbeddingModelRole, QVariant () },
1074
1083
};
1075
1084
updateData (id, data);
1076
1085
return id;
@@ -1491,6 +1500,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
1491
1500
data.append ({ ModelList::PromptTemplateRole, obj[" promptTemplate" ].toString () });
1492
1501
if (obj.contains (" systemPrompt" ))
1493
1502
data.append ({ ModelList::SystemPromptRole, obj[" systemPrompt" ].toString () });
1503
+ data.append ({ ModelList::IsEmbeddingModelRole, QVariant () });
1494
1504
updateData (id, data);
1495
1505
}
1496
1506
@@ -1521,6 +1531,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
1521
1531
{ ModelList::QuantRole, " NA" },
1522
1532
{ ModelList::TypeRole, " GPT" },
1523
1533
{ ModelList::UrlRole, " https://api.openai.com/v1/chat/completions" },
1534
+ { ModelList::IsEmbeddingModelRole, QVariant () },
1524
1535
};
1525
1536
updateData (id, data);
1526
1537
}
@@ -1549,6 +1560,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
1549
1560
{ ModelList::QuantRole, " NA" },
1550
1561
{ ModelList::TypeRole, " GPT" },
1551
1562
{ ModelList::UrlRole, " https://api.openai.com/v1/chat/completions" },
1563
+ { ModelList::IsEmbeddingModelRole, QVariant () },
1552
1564
};
1553
1565
updateData (id, data);
1554
1566
}
@@ -1580,6 +1592,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
1580
1592
{ ModelList::QuantRole, " NA" },
1581
1593
{ ModelList::TypeRole, " Mistral" },
1582
1594
{ ModelList::UrlRole, " https://api.mistral.ai/v1/chat/completions" },
1595
+ { ModelList::IsEmbeddingModelRole, QVariant () },
1583
1596
};
1584
1597
updateData (id, data);
1585
1598
}
@@ -1605,6 +1618,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
1605
1618
{ ModelList::QuantRole, " NA" },
1606
1619
{ ModelList::TypeRole, " Mistral" },
1607
1620
{ ModelList::UrlRole, " https://api.mistral.ai/v1/chat/completions" },
1621
+ { ModelList::IsEmbeddingModelRole, QVariant () },
1608
1622
};
1609
1623
updateData (id, data);
1610
1624
}
@@ -1631,6 +1645,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
1631
1645
{ ModelList::QuantRole, " NA" },
1632
1646
{ ModelList::TypeRole, " Mistral" },
1633
1647
{ ModelList::UrlRole, " https://api.mistral.ai/v1/chat/completions" },
1648
+ { ModelList::IsEmbeddingModelRole, QVariant () },
1634
1649
};
1635
1650
updateData (id, data);
1636
1651
}
@@ -1766,6 +1781,7 @@ void ModelList::updateModelsFromSettings()
1766
1781
const QString systemPrompt = settings.value (g + " /systemPrompt" ).toString ();
1767
1782
data.append ({ ModelList::SystemPromptRole, systemPrompt });
1768
1783
}
1784
+ data.append ({ ModelList::IsEmbeddingModelRole, QVariant () });
1769
1785
updateData (id, data);
1770
1786
}
1771
1787
}
0 commit comments