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 Rectangle { id: window Theme { id: theme } property var currentChat: ChatListModel.currentChat property var chatModel: currentChat.chatModel signal settingsViewRequested(int page) signal downloadViewRequested(bool showEmbeddingModels) color: theme.black // Startup code Component.onCompleted: { startupDialogs(); } Connections { target: firstStartDialog 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() } function onModelLoadingWarning(warning) { modelLoadingWarningPopup.open_(warning) } } 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 view once if (!hasShownModelDownload && ModelList.installedModels.count === 0 && !firstStartDialog.opened) { downloadViewRequested(); hasShownModelDownload = true; return; } // check for new version if (Download.hasNewerRelease && !firstStartDialog.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 } 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:" + "