2023-06-22 15:44:49 -04:00
|
|
|
#include "chatlistmodel.h"
|
2023-04-16 19:20:43 -04:00
|
|
|
#include "config.h"
|
2024-06-04 14:47:11 -04:00
|
|
|
#include "download.h"
|
|
|
|
#include "llm.h"
|
|
|
|
#include "localdocs.h"
|
2023-06-01 10:50:42 -04:00
|
|
|
#include "logger.h"
|
2024-06-04 14:47:11 -04:00
|
|
|
#include "modellist.h"
|
|
|
|
#include "mysettings.h"
|
|
|
|
#include "network.h"
|
|
|
|
|
2024-01-11 12:02:39 -05:00
|
|
|
#include "../gpt4all-backend/llmodel.h"
|
2023-04-08 23:28:39 -04:00
|
|
|
|
2024-06-04 14:47:11 -04:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
#include <QQmlEngine>
|
2024-06-24 18:49:23 -04:00
|
|
|
#include <QSettings>
|
2024-06-04 14:47:11 -04:00
|
|
|
#include <QString>
|
|
|
|
#include <QUrl>
|
2024-06-24 18:49:23 -04:00
|
|
|
#include <Qt>
|
2024-06-04 14:47:11 -04:00
|
|
|
|
2023-04-08 23:28:39 -04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2023-04-18 21:10:06 -04:00
|
|
|
QCoreApplication::setOrganizationName("nomic.ai");
|
|
|
|
QCoreApplication::setOrganizationDomain("gpt4all.io");
|
|
|
|
QCoreApplication::setApplicationName("GPT4All");
|
2023-04-16 19:20:43 -04:00
|
|
|
QCoreApplication::setApplicationVersion(APP_VERSION);
|
2024-06-24 18:49:23 -04:00
|
|
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
2023-04-16 19:20:43 -04:00
|
|
|
|
2023-06-01 10:50:42 -04:00
|
|
|
Logger::globalInstance();
|
|
|
|
|
2023-04-08 23:28:39 -04:00
|
|
|
QGuiApplication app(argc, argv);
|
|
|
|
QQmlApplicationEngine engine;
|
2024-01-11 12:02:39 -05:00
|
|
|
|
|
|
|
QString llmodelSearchPaths = QCoreApplication::applicationDirPath();
|
|
|
|
const QString libDir = QCoreApplication::applicationDirPath() + "/../lib/";
|
|
|
|
if (LLM::directoryExists(libDir))
|
|
|
|
llmodelSearchPaths += ";" + libDir;
|
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
const QString binDir = QCoreApplication::applicationDirPath() + "/../../../";
|
|
|
|
if (LLM::directoryExists(binDir))
|
|
|
|
llmodelSearchPaths += ";" + binDir;
|
|
|
|
const QString frameworksDir = QCoreApplication::applicationDirPath() + "/../Frameworks/";
|
|
|
|
if (LLM::directoryExists(frameworksDir))
|
|
|
|
llmodelSearchPaths += ";" + frameworksDir;
|
|
|
|
#endif
|
|
|
|
LLModel::Implementation::setImplementationsSearchPath(llmodelSearchPaths.toStdString());
|
|
|
|
|
2023-06-27 11:54:34 -04:00
|
|
|
qmlRegisterSingletonInstance("mysettings", 1, 0, "MySettings", MySettings::globalInstance());
|
2023-06-22 15:44:49 -04:00
|
|
|
qmlRegisterSingletonInstance("modellist", 1, 0, "ModelList", ModelList::globalInstance());
|
|
|
|
qmlRegisterSingletonInstance("chatlistmodel", 1, 0, "ChatListModel", ChatListModel::globalInstance());
|
2023-04-08 23:28:39 -04:00
|
|
|
qmlRegisterSingletonInstance("llm", 1, 0, "LLM", LLM::globalInstance());
|
2023-04-18 21:10:06 -04:00
|
|
|
qmlRegisterSingletonInstance("download", 1, 0, "Download", Download::globalInstance());
|
2023-04-14 14:44:28 -04:00
|
|
|
qmlRegisterSingletonInstance("network", 1, 0, "Network", Network::globalInstance());
|
2023-05-18 18:59:10 -04:00
|
|
|
qmlRegisterSingletonInstance("localdocs", 1, 0, "LocalDocs", LocalDocs::globalInstance());
|
2023-04-23 09:42:35 -04:00
|
|
|
const QUrl url(u"qrc:/gpt4all/main.qml"_qs);
|
2023-04-08 23:28:39 -04:00
|
|
|
|
|
|
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
|
|
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
|
|
|
if (!obj && url == objUrl)
|
|
|
|
QCoreApplication::exit(-1);
|
|
|
|
}, Qt::QueuedConnection);
|
|
|
|
engine.load(url);
|
|
|
|
|
2023-04-18 21:10:06 -04:00
|
|
|
#if 0
|
2023-04-08 23:28:39 -04:00
|
|
|
QDirIterator it("qrc:", QDirIterator::Subdirectories);
|
|
|
|
while (it.hasNext()) {
|
|
|
|
qDebug() << it.next();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-01-31 16:32:32 -05:00
|
|
|
int res = app.exec();
|
|
|
|
|
2024-01-31 14:17:44 -05:00
|
|
|
// Make sure ChatLLM threads are joined before global destructors run.
|
|
|
|
// Otherwise, we can get a heap-use-after-free inside of llama.cpp.
|
2024-03-06 16:42:59 -05:00
|
|
|
ChatListModel::globalInstance()->destroyChats();
|
2024-01-31 14:17:44 -05:00
|
|
|
|
2024-01-31 16:32:32 -05:00
|
|
|
return res;
|
2023-04-08 23:28:39 -04:00
|
|
|
}
|