Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show the download button if we are not connected to an online n… #1939

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gpt4all-chat/llm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QResource>
#include <QSettings>
#include <QUrl>
#include <QNetworkInformation>
#include <fstream>

#ifndef GPT4ALL_OFFLINE_INSTALLER
Expand Down Expand Up @@ -39,6 +40,10 @@ LLM::LLM()
#endif

m_compatHardware = minimal;

QNetworkInformation::loadDefaultBackend();
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged,
this, &LLM::isNetworkOnlineChanged);
}

bool LLM::hasSettingsAccess() const
Expand Down Expand Up @@ -100,3 +105,11 @@ QString LLM::systemTotalRAMInGBString() const
{
return QString::fromStdString(getSystemTotalRAMInGBString());
}

bool LLM::isNetworkOnline() const
{
if (!QNetworkInformation::instance())
return false;

return QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online;
}
6 changes: 4 additions & 2 deletions gpt4all-chat/llm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
class LLM : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isNetworkOnline READ isNetworkOnline NOTIFY isNetworkOnlineChanged)

public:
static LLM *globalInstance();

Expand All @@ -17,10 +19,10 @@ class LLM : public QObject
Q_INVOKABLE static bool fileExists(const QString &path);
Q_INVOKABLE qint64 systemTotalRAMInGB() const;
Q_INVOKABLE QString systemTotalRAMInGBString() const;
Q_INVOKABLE bool isNetworkOnline() const;

Q_SIGNALS:
void chatListModelChanged();
void modelListChanged();
void isNetworkOnlineChanged();

private:
bool m_compatHardware;
Expand Down
1 change: 1 addition & 0 deletions gpt4all-chat/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ Window {

MyButton {
id: downloadButton
visible: LLM.isNetworkOnline
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 40
text: qsTr("Download models")
Expand Down
Loading