import QtCore import QtQuick import QtQuick.Controls import QtQuick.Controls.Basic import QtQuick.Layouts import Qt5Compat.GraphicalEffects import llm import chatlistmodel import download import modellist import network import gpt4all import mysettings Window { id: window width: 1920 height: 1080 minimumWidth: 720 minimumHeight: 480 visible: true title: qsTr("GPT4All v") + Qt.application.version Settings { property alias x: window.x property alias y: window.y property alias width: window.width property alias height: window.height } Theme { id: theme } property var currentChat: ChatListModel.currentChat property var chatModel: currentChat.chatModel property bool hasSaved: false onClosing: function(close) { if (window.hasSaved) return; savingPopup.open(); ChatListModel.saveChats(); close.accepted = false } Connections { target: ChatListModel function onSaveChatsFinished() { window.hasSaved = true; savingPopup.close(); window.close() } } color: theme.black // Startup code Component.onCompleted: { startupDialogs(); } Connections { target: firstStartDialog function onClosed() { startupDialogs(); } } Connections { target: downloadNewModels function onClosed() { startupDialogs(); } } Connections { target: Download function onHasNewerReleaseChanged() { startupDialogs(); } } Connections { target: currentChat function onResponseInProgressChanged() { if (MySettings.networkIsActive && !currentChat.responseInProgress) Network.sendConversation(currentChat.id, getConversationJson()); } function onModelLoadingErrorChanged() { if (currentChat.modelLoadingError !== "") modelLoadingErrorPopup.open() } } property bool hasShownModelDownload: false property bool hasShownFirstStart: false property bool hasShownSettingsAccess: false function startupDialogs() { if (!LLM.compatHardware()) { Network.sendNonCompatHardware(); errorCompatHardware.open(); return; } // check if we have access to settings and if not show an error if (!hasShownSettingsAccess && !LLM.hasSettingsAccess()) { errorSettingsAccess.open(); hasShownSettingsAccess = true; return; } // check for first time start of this version if (!hasShownFirstStart && Download.isFirstStart()) { firstStartDialog.open(); hasShownFirstStart = true; return; } // check for any current models and if not, open download dialog once if (!hasShownModelDownload && ModelList.installedModels.count === 0 && !firstStartDialog.opened) { downloadNewModels.open(); hasShownModelDownload = true; return; } // check for new version if (Download.hasNewerRelease && !firstStartDialog.opened && !downloadNewModels.opened) { newVersionDialog.open(); return; } } function currentModelName() { return ModelList.modelInfo(currentChat.modelInfo.id).name; } property bool isCurrentlyLoading: false property real modelLoadingPercentage: 0.0 property bool trySwitchContextInProgress: false PopupDialog { id: errorCompatHardware anchors.centerIn: parent shouldTimeOut: false shouldShowBusy: false closePolicy: Popup.NoAutoClose modal: true text: qsTr("

Encountered an error starting up:


") + qsTr("\"Incompatible hardware detected.\"") + qsTr("

Unfortunately, your CPU does not meet the minimal requirements to run ") + qsTr("this program. In particular, it does not support AVX intrinsics which this ") + qsTr("program requires to successfully run a modern large language model. ") + qsTr("The only solution at this time is to upgrade your hardware to a more modern CPU.") + qsTr("

See here for more information: ") + qsTr("https://en.wikipedia.org/wiki/Advanced_Vector_Extensions") } PopupDialog { id: errorSettingsAccess anchors.centerIn: parent shouldTimeOut: false shouldShowBusy: false modal: true text: qsTr("

Encountered an error starting up:


") + qsTr("\"Inability to access settings file.\"") + qsTr("

Unfortunately, something is preventing the program from accessing ") + qsTr("the settings file. This could be caused by incorrect permissions in the local ") + qsTr("app config directory where the settings file is located. ") + qsTr("Check out our discord channel for help.") } StartupDialog { id: firstStartDialog anchors.centerIn: parent } NewVersionDialog { id: newVersionDialog anchors.centerIn: parent } AboutDialog { id: aboutDialog anchors.centerIn: parent width: Math.min(1024, window.width - (window.width * .2)) height: Math.min(600, window.height - (window.height * .2)) } Item { Accessible.role: Accessible.Window Accessible.name: title } PopupDialog { id: modelLoadingErrorPopup anchors.centerIn: parent shouldTimeOut: false text: qsTr("

Encountered an error loading model:


") + "\"" + currentChat.modelLoadingError + "\"" + qsTr("

Model loading failures can happen for a variety of reasons, but the most common " + "causes include a bad file format, an incomplete or corrupted download, the wrong file " + "type, not enough system RAM or an incompatible model type. Here are some suggestions for resolving the problem:" + "