mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-09 11:57:23 +00:00
Fix so that models are searched in subdirectories.
This commit is contained in:
parent
64e98b8ea9
commit
5e520bb775
@ -214,11 +214,13 @@ Window {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
leftPadding: 10
|
leftPadding: 10
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
text: ModelList.installedModels.count
|
text: (ModelList.installedModels.count > 0
|
||||||
? currentChat.modelLoadingError !== "" ? qsTr("Model loading error...")
|
? currentChat.modelLoadingError !== "" ? qsTr("Model loading error...")
|
||||||
: (comboBox.textAt(comboBox.currentIndex) !== "" ? comboBox.textAt(comboBox.currentIndex)
|
: (comboBox.textAt(comboBox.currentIndex) !== ""
|
||||||
: comboBox.valueAt(comboBox.currentIndex))
|
? comboBox.textAt(comboBox.currentIndex)
|
||||||
: ""
|
: (comboBox.valueAt(comboBox.currentIndex) !== "undefined" ? ""
|
||||||
|
: comboBox.valueAt(comboBox.currentIndex)))
|
||||||
|
: "")
|
||||||
font: comboBox.font
|
font: comboBox.font
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
@ -458,51 +458,37 @@ void ModelList::updateModelsFromDirectory()
|
|||||||
{
|
{
|
||||||
const QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
const QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||||
const QString localPath = localModelsPath();
|
const QString localPath = localModelsPath();
|
||||||
{
|
|
||||||
QDir dir(exePath);
|
auto processDirectory = [&](const QString& path) {
|
||||||
QStringList allFiles = dir.entryList(QDir::Files);
|
QDirIterator it(path, QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
|
||||||
|
if (!it.fileInfo().isDir()) {
|
||||||
|
QString filename = it.fileName();
|
||||||
|
|
||||||
// All files that end with .bin and have 'ggml' somewhere in the name
|
// All files that end with .bin and have 'ggml' somewhere in the name
|
||||||
QStringList fileNames;
|
|
||||||
for(const QString& filename : allFiles) {
|
|
||||||
if (filename.endsWith(".bin") && filename.contains("ggml") && !filename.startsWith("incomplete")) {
|
|
||||||
fileNames.append(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const QString& f : fileNames) {
|
|
||||||
QString filePath = exePath + f;
|
|
||||||
QFileInfo info(filePath);
|
|
||||||
if (!info.exists())
|
|
||||||
continue;
|
|
||||||
if (!contains(f))
|
|
||||||
addModel(f);
|
|
||||||
updateData(f, DirpathRole, exePath);
|
|
||||||
updateData(f, FilesizeRole, toFileSize(info.size()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localPath != exePath) {
|
|
||||||
QDir dir(localPath);
|
|
||||||
QStringList allFiles = dir.entryList(QDir::Files);
|
|
||||||
QStringList fileNames;
|
|
||||||
for(const QString& filename : allFiles) {
|
|
||||||
if ((filename.endsWith(".bin") && filename.contains("ggml") && !filename.startsWith("incomplete"))
|
if ((filename.endsWith(".bin") && filename.contains("ggml") && !filename.startsWith("incomplete"))
|
||||||
|| (filename.endsWith(".txt") && filename.startsWith("chatgpt-"))) {
|
|| (filename.endsWith(".txt") && filename.startsWith("chatgpt-"))) {
|
||||||
fileNames.append(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const QString& f : fileNames) {
|
QString filePath = it.filePath();
|
||||||
QString filePath = localPath + f;
|
|
||||||
QFileInfo info(filePath);
|
QFileInfo info(filePath);
|
||||||
|
|
||||||
if (!info.exists())
|
if (!info.exists())
|
||||||
continue;
|
continue;
|
||||||
if (!contains(f))
|
|
||||||
addModel(f);
|
if (!contains(filename))
|
||||||
updateData(f, ChatGPTRole, f.startsWith("chatgpt-"));
|
addModel(filename);
|
||||||
updateData(f, DirpathRole, localPath);
|
|
||||||
updateData(f, FilesizeRole, toFileSize(info.size()));
|
updateData(filename, ChatGPTRole, filename.startsWith("chatgpt-"));
|
||||||
|
updateData(filename, DirpathRole, path);
|
||||||
|
updateData(filename, FilesizeRole, toFileSize(info.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
processDirectory(exePath);
|
||||||
|
if (localPath != exePath)
|
||||||
|
processDirectory(localPath);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user