mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-16 08:26:04 +00:00
chat: set search path early
This fixes the issues with installed versions of v2.6.0.
This commit is contained in:
parent
f7aeeca884
commit
7e9786fccf
@ -192,7 +192,7 @@ LLModel *LLModel::Implementation::construct(const std::string &modelPath, std::s
|
|||||||
return fres;
|
return fres;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLModel *LLModel::Implementation::constructCpuLlama() {
|
LLModel *LLModel::Implementation::constructDefaultLlama() {
|
||||||
const LLModel::Implementation *impl = nullptr;
|
const LLModel::Implementation *impl = nullptr;
|
||||||
for (const auto &i : implementationList()) {
|
for (const auto &i : implementationList()) {
|
||||||
if (i.m_buildVariant == "metal" || i.m_modelType != "LLaMA") continue;
|
if (i.m_buildVariant == "metal" || i.m_modelType != "LLaMA") continue;
|
||||||
@ -208,8 +208,8 @@ LLModel *LLModel::Implementation::constructCpuLlama() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LLModel::GPUDevice> LLModel::Implementation::availableGPUDevices() {
|
std::vector<LLModel::GPUDevice> LLModel::Implementation::availableGPUDevices() {
|
||||||
static LLModel *cpuLlama = LLModel::Implementation::constructCpuLlama(); // (memory leak)
|
static LLModel *llama = LLModel::Implementation::constructDefaultLlama(); // (memory leak)
|
||||||
if (cpuLlama) { return cpuLlama->availableGPUDevices(0); }
|
if (llama) { return llama->availableGPUDevices(0); }
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
static const std::string& implementationsSearchPath();
|
static const std::string& implementationsSearchPath();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LLModel *constructCpuLlama();
|
static LLModel *constructDefaultLlama();
|
||||||
|
|
||||||
bool (*m_magicMatch)(const char *fname);
|
bool (*m_magicMatch)(const char *fname);
|
||||||
LLModel *(*m_construct)();
|
LLModel *(*m_construct)();
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
#include "llm.h"
|
#include "llm.h"
|
||||||
#include "../gpt4all-backend/sysinfo.h"
|
#include "../gpt4all-backend/sysinfo.h"
|
||||||
#include "../gpt4all-backend/llmodel.h"
|
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QResource>
|
#include <QResource>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDesktopServices>
|
#include <QUrl>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
class MyLLM: public LLM { };
|
class MyLLM: public LLM { };
|
||||||
@ -23,20 +22,6 @@ LLM::LLM()
|
|||||||
: QObject{nullptr}
|
: QObject{nullptr}
|
||||||
, m_compatHardware(true)
|
, m_compatHardware(true)
|
||||||
{
|
{
|
||||||
QString llmodelSearchPaths = QCoreApplication::applicationDirPath();
|
|
||||||
const QString libDir = QCoreApplication::applicationDirPath() + "/../lib/";
|
|
||||||
if (directoryExists(libDir))
|
|
||||||
llmodelSearchPaths += ";" + libDir;
|
|
||||||
#if defined(Q_OS_MAC)
|
|
||||||
const QString binDir = QCoreApplication::applicationDirPath() + "/../../../";
|
|
||||||
if (directoryExists(binDir))
|
|
||||||
llmodelSearchPaths += ";" + binDir;
|
|
||||||
const QString frameworksDir = QCoreApplication::applicationDirPath() + "/../Frameworks/";
|
|
||||||
if (directoryExists(frameworksDir))
|
|
||||||
llmodelSearchPaths += ";" + frameworksDir;
|
|
||||||
#endif
|
|
||||||
LLModel::Implementation::setImplementationsSearchPath(llmodelSearchPaths.toStdString());
|
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
const bool minimal(__builtin_cpu_supports("avx"));
|
const bool minimal(__builtin_cpu_supports("avx"));
|
||||||
@ -86,7 +71,7 @@ bool LLM::checkForUpdates() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LLM::directoryExists(const QString &path) const
|
bool LLM::directoryExists(const QString &path)
|
||||||
{
|
{
|
||||||
const QUrl url(path);
|
const QUrl url(path);
|
||||||
const QString localFilePath = url.isLocalFile() ? url.toLocalFile() : path;
|
const QString localFilePath = url.isLocalFile() ? url.toLocalFile() : path;
|
||||||
@ -94,7 +79,7 @@ bool LLM::directoryExists(const QString &path) const
|
|||||||
return info.exists() && info.isDir();
|
return info.exists() && info.isDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LLM::fileExists(const QString &path) const
|
bool LLM::fileExists(const QString &path)
|
||||||
{
|
{
|
||||||
const QUrl url(path);
|
const QUrl url(path);
|
||||||
const QString localFilePath = url.isLocalFile() ? url.toLocalFile() : path;
|
const QString localFilePath = url.isLocalFile() ? url.toLocalFile() : path;
|
||||||
|
@ -13,8 +13,8 @@ public:
|
|||||||
Q_INVOKABLE bool compatHardware() const { return m_compatHardware; }
|
Q_INVOKABLE bool compatHardware() const { return m_compatHardware; }
|
||||||
|
|
||||||
Q_INVOKABLE bool checkForUpdates() const;
|
Q_INVOKABLE bool checkForUpdates() const;
|
||||||
Q_INVOKABLE bool directoryExists(const QString &path) const;
|
Q_INVOKABLE static bool directoryExists(const QString &path);
|
||||||
Q_INVOKABLE bool fileExists(const QString &path) const;
|
Q_INVOKABLE static bool fileExists(const QString &path);
|
||||||
Q_INVOKABLE qint64 systemTotalRAMInGB() const;
|
Q_INVOKABLE qint64 systemTotalRAMInGB() const;
|
||||||
Q_INVOKABLE QString systemTotalRAMInGBString() const;
|
Q_INVOKABLE QString systemTotalRAMInGBString() const;
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
#include <QDirIterator>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
#include <QDirIterator>
|
|
||||||
|
|
||||||
#include "llm.h"
|
#include "llm.h"
|
||||||
#include "modellist.h"
|
#include "modellist.h"
|
||||||
#include "chatlistmodel.h"
|
#include "chatlistmodel.h"
|
||||||
@ -13,6 +12,7 @@
|
|||||||
#include "mysettings.h"
|
#include "mysettings.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "../gpt4all-backend/llmodel.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -25,6 +25,21 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
qmlRegisterSingletonInstance("mysettings", 1, 0, "MySettings", MySettings::globalInstance());
|
qmlRegisterSingletonInstance("mysettings", 1, 0, "MySettings", MySettings::globalInstance());
|
||||||
qmlRegisterSingletonInstance("modellist", 1, 0, "ModelList", ModelList::globalInstance());
|
qmlRegisterSingletonInstance("modellist", 1, 0, "ModelList", ModelList::globalInstance());
|
||||||
qmlRegisterSingletonInstance("chatlistmodel", 1, 0, "ChatListModel", ChatListModel::globalInstance());
|
qmlRegisterSingletonInstance("chatlistmodel", 1, 0, "ChatListModel", ChatListModel::globalInstance());
|
||||||
|
Loading…
Reference in New Issue
Block a user