2023-04-21 12:23:39 +00:00
import QtCore
2023-04-09 03:28:39 +00:00
import QtQuick
import QtQuick . Controls
2023-04-10 19:03:00 +00:00
import QtQuick . Controls . Basic
2023-04-16 05:14:42 +00:00
import QtQuick . Layouts
2023-05-31 01:03:40 +00:00
import Qt5Compat . GraphicalEffects
2023-04-09 03:28:39 +00:00
import llm
2023-06-22 19:44:49 +00:00
import chatlistmodel
2023-04-28 14:54:05 +00:00
import download
2023-06-22 19:44:49 +00:00
import modellist
2023-04-14 18:44:28 +00:00
import network
2023-06-10 14:15:38 +00:00
import gpt4all
2023-06-28 19:47:15 +00:00
import mysettings
2023-04-09 03:28:39 +00:00
Window {
id: window
width: 1280
height: 720
2023-06-02 23:59:53 +00:00
minimumWidth: 720
minimumHeight: 480
2023-04-09 03:28:39 +00:00
visible: true
2023-04-17 11:50:39 +00:00
title: qsTr ( "GPT4All v" ) + Qt . application . version
2023-04-23 13:42:35 +00:00
Theme {
id: theme
}
2023-06-22 19:44:49 +00:00
property var currentChat: ChatListModel . currentChat
2023-05-01 21:13:20 +00:00
property var chatModel: currentChat . chatModel
2023-06-20 21:14:11 +00:00
property bool hasSaved: false
onClosing: function ( close ) {
if ( window . hasSaved )
return ;
savingPopup . open ( ) ;
2023-06-22 19:44:49 +00:00
ChatListModel . saveChats ( ) ;
2023-06-20 21:14:11 +00:00
close . accepted = false
}
Connections {
2023-06-22 19:44:49 +00:00
target: ChatListModel
2023-06-20 21:14:11 +00:00
function onSaveChatsFinished ( ) {
window . hasSaved = true ;
savingPopup . close ( ) ;
window . close ( )
}
}
2023-04-24 01:05:38 +00:00
2023-06-03 00:19:50 +00:00
color: theme . backgroundDarkest
2023-04-28 14:54:05 +00:00
// Startup code
Component.onCompleted: {
2023-06-26 13:35:29 +00:00
startupDialogs ( ) ;
2023-04-28 14:54:05 +00:00
}
Connections {
target: firstStartDialog
function onClosed ( ) {
startupDialogs ( ) ;
}
}
Connections {
target: downloadNewModels
function onClosed ( ) {
startupDialogs ( ) ;
}
}
Connections {
target: Download
function onHasNewerReleaseChanged ( ) {
startupDialogs ( ) ;
}
}
2023-05-03 11:54:45 +00:00
Connections {
target: currentChat
function onResponseInProgressChanged ( ) {
2023-06-29 00:42:40 +00:00
if ( MySettings . networkIsActive && ! currentChat . responseInProgress )
2023-05-03 11:54:45 +00:00
Network . sendConversation ( currentChat . id , getConversationJson ( ) ) ;
}
2023-06-04 18:55:05 +00:00
function onModelLoadingErrorChanged ( ) {
if ( currentChat . modelLoadingError !== "" )
modelLoadingErrorPopup . open ( )
}
2023-05-03 11:54:45 +00:00
}
2023-07-09 19:08:14 +00:00
property bool hasShownModelDownload: false
2023-07-11 22:54:26 +00:00
property bool hasShownFirstStart: false
2023-07-12 12:50:21 +00:00
property bool hasShownSettingsAccess: false
2023-07-09 19:08:14 +00:00
2023-04-28 14:54:05 +00:00
function startupDialogs ( ) {
2023-07-12 12:50:21 +00:00
if ( ! LLM . compatHardware ( ) ) {
2023-06-26 13:35:29 +00:00
Network . sendNonCompatHardware ( ) ;
errorCompatHardware . open ( ) ;
return ;
}
2023-07-12 12:50:21 +00:00
// check if we have access to settings and if not show an error
if ( ! hasShownSettingsAccess && ! LLM . hasSettingsAccess ( ) ) {
errorSettingsAccess . open ( ) ;
hasShownSettingsAccess = true ;
return ;
}
2023-04-28 14:54:05 +00:00
// check for first time start of this version
2023-07-11 22:54:26 +00:00
if ( ! hasShownFirstStart && Download . isFirstStart ( ) ) {
2023-04-28 14:54:05 +00:00
firstStartDialog . open ( ) ;
2023-07-11 22:54:26 +00:00
hasShownFirstStart = true ;
2023-04-28 14:54:05 +00:00
return ;
}
2023-07-09 19:08:14 +00:00
// check for any current models and if not, open download dialog once
if ( ! hasShownModelDownload && ModelList . installedModels . count === 0 && ! firstStartDialog . opened ) {
2023-04-28 14:54:05 +00:00
downloadNewModels . open ( ) ;
2023-07-09 19:08:14 +00:00
hasShownModelDownload = true ;
2023-04-28 14:54:05 +00:00
return ;
}
// check for new version
2023-04-28 18:11:18 +00:00
if ( Download . hasNewerRelease && ! firstStartDialog . opened && ! downloadNewModels . opened ) {
2023-04-28 14:54:05 +00:00
newVersionDialog . open ( ) ;
return ;
}
}
2023-05-08 12:23:00 +00:00
PopupDialog {
id: errorCompatHardware
anchors.centerIn: parent
shouldTimeOut: false
shouldShowBusy: false
closePolicy: Popup . NoAutoClose
modal: true
2023-06-26 13:35:29 +00:00
text: qsTr ( "<h3>Encountered an error starting up:</h3><br>" )
+ qsTr ( "<i>\"Incompatible hardware detected.\"</i>" )
+ qsTr ( "<br><br>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." )
2023-06-26 17:37:18 +00:00
+ qsTr ( "<br><br>See here for more information: <a href=\"https://en.wikipedia.org/wiki/Advanced_Vector_Extensions\">" )
+ qsTr ( "https://en.wikipedia.org/wiki/Advanced_Vector_Extensions</a>" )
2023-05-08 12:23:00 +00:00
}
2023-07-12 12:50:21 +00:00
PopupDialog {
id: errorSettingsAccess
anchors.centerIn: parent
shouldTimeOut: false
shouldShowBusy: false
modal: true
text: qsTr ( "<h3>Encountered an error starting up:</h3><br>" )
+ qsTr ( "<i>\"Inability to access settings file.\"</i>" )
+ qsTr ( "<br><br>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 <a href=\"https://discord.gg/4M2QFmTt2k\">discord channel</a> for help." )
}
2023-04-28 14:54:05 +00:00
StartupDialog {
id: firstStartDialog
anchors.centerIn: parent
}
NewVersionDialog {
id: newVersionDialog
anchors.centerIn: parent
}
2023-05-05 14:47:05 +00:00
AboutDialog {
id: aboutDialog
anchors.centerIn: parent
2023-06-03 00:05:47 +00:00
width: Math . min ( 1024 , window . width - ( window . width * . 2 ) )
height: Math . min ( 600 , window . height - ( window . height * . 2 ) )
2023-05-05 14:47:05 +00:00
}
2023-04-18 12:39:48 +00:00
Item {
Accessible.role: Accessible . Window
Accessible.name: title
}
2023-06-04 18:55:05 +00:00
PopupDialog {
id: modelLoadingErrorPopup
anchors.centerIn: parent
shouldTimeOut: false
2023-06-22 19:44:49 +00:00
text: qsTr ( "<h3>Encountered an error loading model:</h3><br>" )
+ "<i>\"" + currentChat . modelLoadingError + "\"</i>"
+ qsTr ( "<br><br>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 "
2023-07-11 16:09:33 +00:00
+ "type, not enough system RAM or an incompatible model type. Here are some suggestions for resolving the problem:"
2023-06-22 19:44:49 +00:00
+ "<br><ul>"
2023-09-21 16:41:48 +00:00
+ "<li>Ensure the model file has a compatible format and type"
2023-06-22 19:44:49 +00:00
+ "<li>Check the model file is complete in the download folder"
+ "<li>You can find the download folder in the settings dialog"
+ "<li>If you've sideloaded the model ensure the file is not corrupt by checking md5sum"
2023-06-26 17:37:18 +00:00
+ "<li>Read more about what models are supported in our <a href=\"https://docs.gpt4all.io/gpt4all_chat.html\">documentation</a> for the gui"
2023-06-22 19:44:49 +00:00
+ "<li>Check out our <a href=\"https://discord.gg/4M2QFmTt2k\">discord channel</a> for help" )
2023-06-04 18:55:05 +00:00
}
2023-04-11 12:29:55 +00:00
Rectangle {
2023-04-11 03:34:34 +00:00
id: header
anchors.left: parent . left
anchors.right: parent . right
anchors.top: parent . top
height: 100
2023-04-23 13:42:35 +00:00
color: theme . backgroundDarkest
2023-04-11 12:29:55 +00:00
Item {
anchors.centerIn: parent
height: childrenRect . height
2023-06-04 18:55:05 +00:00
visible: currentChat . isModelLoaded || currentChat . modelLoadingError !== "" || currentChat . isServer
2023-04-11 12:29:55 +00:00
2023-04-14 00:06:46 +00:00
Label {
2023-04-18 15:42:16 +00:00
id: modelLabel
2023-04-23 13:42:35 +00:00
color: theme . textColor
2023-04-11 12:29:55 +00:00
padding: 20
2023-05-01 21:13:20 +00:00
font.pixelSize: theme . fontSizeLarger
2023-04-18 15:42:16 +00:00
text: ""
2023-04-11 12:29:55 +00:00
background: Rectangle {
2023-04-23 13:42:35 +00:00
color: theme . backgroundDarkest
2023-04-11 12:29:55 +00:00
}
2023-04-18 15:42:16 +00:00
horizontalAlignment: TextInput . AlignRight
}
2023-05-22 13:01:46 +00:00
MyComboBox {
2023-04-18 15:42:16 +00:00
id: comboBox
2023-06-02 23:59:53 +00:00
implicitWidth: 375
width: window . width >= 750 ? implicitWidth : implicitWidth - ( ( 750 - window . width ) )
2023-04-18 15:42:16 +00:00
anchors.top: modelLabel . top
anchors.bottom: modelLabel . bottom
anchors.horizontalCenter: parent . horizontalCenter
2023-06-02 23:59:53 +00:00
anchors.horizontalCenterOffset: window . width >= 950 ? 0 : Math . max ( - ( ( 950 - window . width ) / 2 ) , - 99.5 )
2023-05-11 20:46:25 +00:00
enabled: ! currentChat . isServer
2023-06-22 19:44:49 +00:00
model: ModelList . installedModels
2023-07-01 15:34:21 +00:00
valueRole: "id"
2023-06-22 19:44:49 +00:00
textRole: "name"
2023-06-27 00:59:46 +00:00
property string currentModelName: ""
function updateCurrentModelName ( ) {
2023-07-01 15:34:21 +00:00
var info = ModelList . modelInfo ( currentChat . modelInfo . id ) ;
comboBox . currentModelName = info . name ;
2023-06-27 00:59:46 +00:00
}
2023-06-22 19:44:49 +00:00
Connections {
target: currentChat
function onModelInfoChanged ( ) {
2023-06-27 00:59:46 +00:00
comboBox . updateCurrentModelName ( ) ;
2023-06-22 19:44:49 +00:00
}
}
2023-07-01 15:34:21 +00:00
Connections {
target: window
function onCurrentChatChanged ( ) {
comboBox . updateCurrentModelName ( ) ;
}
}
background: Rectangle {
color: theme . backgroundDark
radius: 10
}
2023-06-04 18:55:05 +00:00
contentItem: Text {
anchors.horizontalCenter: parent . horizontalCenter
leftPadding: 10
rightPadding: 20
2023-06-27 00:59:46 +00:00
text: currentChat . modelLoadingError !== ""
? qsTr ( "Model loading error..." )
: comboBox . currentModelName
2023-06-04 18:55:05 +00:00
font: comboBox . font
color: theme . textColor
verticalAlignment: Text . AlignVCenter
horizontalAlignment: Text . AlignHCenter
elide: Text . ElideRight
}
delegate: ItemDelegate {
width: comboBox . width
contentItem: Text {
2023-07-01 15:34:21 +00:00
text: name
2023-06-04 18:55:05 +00:00
color: theme . textColor
font: comboBox . font
elide: Text . ElideRight
verticalAlignment: Text . AlignVCenter
}
background: Rectangle {
color: highlighted ? theme.backgroundLight : theme . backgroundDark
}
highlighted: comboBox . highlightedIndex === index
}
2023-04-18 15:42:16 +00:00
Accessible.role: Accessible . ComboBox
2023-10-22 00:15:50 +00:00
Accessible.name: qsTr ( "List of available models" )
Accessible.description: qsTr ( "The top item is the current model" )
2023-06-27 00:59:46 +00:00
onActivated: function ( index ) {
2023-05-01 21:13:20 +00:00
currentChat . stopGenerating ( )
currentChat . reset ( ) ;
2023-06-27 00:59:46 +00:00
currentChat . modelInfo = ModelList . modelInfo ( comboBox . valueAt ( index ) )
2023-04-18 15:42:16 +00:00
}
2023-04-11 12:29:55 +00:00
}
2023-04-11 03:34:34 +00:00
}
2023-04-09 03:28:39 +00:00
2023-05-30 22:24:26 +00:00
Item {
2023-04-11 12:29:55 +00:00
anchors.centerIn: parent
2023-06-26 13:35:29 +00:00
visible: ModelList . installedModels . count
&& ! currentChat . isModelLoaded
&& currentChat . modelLoadingError === ""
&& ! currentChat . isServer
2023-05-30 22:24:26 +00:00
width: childrenRect . width
height: childrenRect . height
Row {
spacing: 5
2023-05-31 23:28:09 +00:00
MyBusyIndicator {
2023-05-30 22:24:26 +00:00
anchors.verticalCenter: parent . verticalCenter
running: parent . visible
Accessible.role: Accessible . Animation
Accessible.name: qsTr ( "Busy indicator" )
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "loading model..." )
2023-05-30 22:24:26 +00:00
}
Label {
anchors.verticalCenter: parent . verticalCenter
text: qsTr ( "Loading model..." )
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-05-31 23:28:09 +00:00
color: theme . textAccent
2023-05-30 22:24:26 +00:00
}
}
2023-04-11 12:29:55 +00:00
}
2023-04-11 03:34:34 +00:00
}
2023-04-23 10:58:07 +00:00
SettingsDialog {
2023-04-16 05:14:42 +00:00
id: settingsDialog
anchors.centerIn: parent
2023-06-26 16:58:33 +00:00
width: Math . min ( 1280 , window . width - ( window . width * . 1 ) )
height: window . height - ( window . height * . 1 )
2023-10-24 16:13:32 +00:00
onDownloadClicked: {
downloadNewModels . showEmbeddingModels = true
downloadNewModels . open ( )
}
2023-04-16 05:14:42 +00:00
}
2023-04-11 03:34:34 +00:00
Button {
id: drawerButton
2023-04-10 00:23:52 +00:00
anchors.left: parent . left
2023-04-11 03:34:34 +00:00
anchors.top: parent . top
anchors.topMargin: 30
anchors.leftMargin: 30
2023-04-24 15:30:20 +00:00
width: 40
2023-04-11 03:34:34 +00:00
height: 40
z: 200
padding: 15
2023-04-18 12:39:48 +00:00
Accessible.role: Accessible . ButtonMenu
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Main menu" )
Accessible.description: qsTr ( "Navigation drawer with options" )
2023-04-18 12:39:48 +00:00
2023-04-11 03:34:34 +00:00
background: Item {
2023-04-24 15:30:20 +00:00
anchors.centerIn: parent
width: 30
height: 30
2023-04-11 03:34:34 +00:00
Rectangle {
id: bar1
2023-06-01 01:07:14 +00:00
color: drawerButton . hovered ? theme.textColor : theme . backgroundLightest
2023-04-11 03:34:34 +00:00
width: parent . width
2023-04-24 15:30:20 +00:00
height: 6
2023-04-11 03:34:34 +00:00
radius: 2
antialiasing: true
}
Rectangle {
id: bar2
anchors.centerIn: parent
2023-06-01 01:07:14 +00:00
color: drawerButton . hovered ? theme.textColor : theme . backgroundLightest
2023-04-11 03:34:34 +00:00
width: parent . width
2023-04-24 15:30:20 +00:00
height: 6
2023-04-11 03:34:34 +00:00
radius: 2
antialiasing: true
}
Rectangle {
id: bar3
anchors.bottom: parent . bottom
2023-06-01 01:07:14 +00:00
color: drawerButton . hovered ? theme.textColor : theme . backgroundLightest
2023-04-11 03:34:34 +00:00
width: parent . width
2023-04-24 15:30:20 +00:00
height: 6
2023-04-11 03:34:34 +00:00
radius: 2
antialiasing: true
}
}
onClicked: {
drawer . visible = ! drawer . visible
}
}
2023-04-14 18:44:28 +00:00
NetworkDialog {
id: networkDialog
anchors.centerIn: parent
2023-05-03 12:37:45 +00:00
width: Math . min ( 1024 , window . width - ( window . width * . 2 ) )
height: Math . min ( 600 , window . height - ( window . height * . 2 ) )
2023-04-14 18:44:28 +00:00
Item {
Accessible.role: Accessible . Dialog
Accessible.name: qsTr ( "Network dialog" )
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "opt-in to share feedback/conversations" )
2023-04-14 18:44:28 +00:00
}
}
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-04-14 18:44:28 +00:00
id: networkButton
2023-04-09 03:28:39 +00:00
anchors.right: parent . right
anchors.top: parent . top
2023-04-24 04:31:39 +00:00
anchors.topMargin: 30
2023-04-14 18:44:28 +00:00
anchors.rightMargin: 30
2023-04-24 04:25:57 +00:00
width: 40
2023-04-24 04:31:39 +00:00
height: 40
2023-04-14 18:44:28 +00:00
z: 200
padding: 15
2023-06-29 00:42:40 +00:00
toggled: MySettings . networkIsActive
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/network.svg"
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Network" )
2023-04-14 18:44:28 +00:00
Accessible.description: qsTr ( "Reveals a dialogue where you can opt-in for sharing data over network" )
onClicked: {
2023-06-29 00:42:40 +00:00
if ( MySettings . networkIsActive ) {
MySettings . networkIsActive = false
2023-05-03 00:31:17 +00:00
Network . sendNetworkToggled ( false ) ;
} else
2023-04-23 11:35:38 +00:00
networkDialog . open ( )
}
}
Connections {
target: Network
function onHealthCheckFailed ( code ) {
healthCheckFailed . open ( ) ;
2023-04-14 18:44:28 +00:00
}
}
2023-05-23 18:51:14 +00:00
CollectionsDialog {
id: collectionsDialog
anchors.centerIn: parent
2023-11-22 14:10:44 +00:00
onAddRemoveClicked: {
settingsDialog . pageToDisplay = 2 ;
settingsDialog . open ( ) ;
}
2023-05-23 18:51:14 +00:00
}
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-05-23 18:51:14 +00:00
id: collectionsButton
2023-04-14 18:44:28 +00:00
anchors.right: networkButton . left
anchors.top: parent . top
2023-04-11 03:34:34 +00:00
anchors.topMargin: 30
2023-06-02 23:59:53 +00:00
anchors.rightMargin: 10
2023-04-24 04:25:57 +00:00
width: 40
2023-04-11 03:34:34 +00:00
height: 40
z: 200
padding: 15
2023-06-14 00:08:27 +00:00
toggled: currentChat . collectionList . length
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/db.svg"
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Add documents" )
Accessible.description: qsTr ( "add collections of documents to the chat" )
2023-05-23 18:51:14 +00:00
onClicked: {
collectionsDialog . open ( )
}
}
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-05-23 18:51:14 +00:00
id: settingsButton
anchors.right: collectionsButton . left
anchors.top: parent . top
anchors.topMargin: 30
2023-06-02 23:59:53 +00:00
anchors.rightMargin: 10
2023-05-23 18:51:14 +00:00
width: 40
height: 40
z: 200
padding: 15
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/settings.svg"
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Settings" )
Accessible.description: qsTr ( "Reveals a dialogue with settings" )
2023-04-18 12:39:48 +00:00
2023-04-16 15:44:55 +00:00
onClicked: {
settingsDialog . open ( )
}
}
2023-04-23 11:05:43 +00:00
PopupDialog {
2023-04-16 15:44:55 +00:00
id: copyMessage
anchors.centerIn: parent
2023-04-23 11:05:43 +00:00
text: qsTr ( "Conversation copied to clipboard." )
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-04-23 11:05:43 +00:00
}
2023-04-16 15:44:55 +00:00
2023-06-10 16:34:43 +00:00
PopupDialog {
id: copyCodeMessage
anchors.centerIn: parent
text: qsTr ( "Code copied to clipboard." )
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-06-10 16:34:43 +00:00
}
2023-04-23 11:05:43 +00:00
PopupDialog {
2023-04-23 11:35:38 +00:00
id: healthCheckFailed
2023-04-23 11:05:43 +00:00
anchors.centerIn: parent
2023-04-23 11:35:38 +00:00
text: qsTr ( "Connection to datalake failed." )
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-04-16 15:44:55 +00:00
}
2023-04-25 15:20:51 +00:00
PopupDialog {
id: recalcPopup
anchors.centerIn: parent
shouldTimeOut: false
shouldShowBusy: true
text: qsTr ( "Recalculating context." )
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-04-25 15:20:51 +00:00
Connections {
2023-05-04 19:31:41 +00:00
target: currentChat
2023-04-25 15:20:51 +00:00
function onRecalcChanged ( ) {
2023-05-04 19:31:41 +00:00
if ( currentChat . isRecalc )
2023-04-25 15:20:51 +00:00
recalcPopup . open ( )
else
recalcPopup . close ( )
}
}
}
2023-06-20 21:14:11 +00:00
PopupDialog {
id: savingPopup
anchors.centerIn: parent
shouldTimeOut: false
shouldShowBusy: true
text: qsTr ( "Saving chats." )
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-06-20 21:14:11 +00:00
}
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-04-16 15:44:55 +00:00
id: copyButton
anchors.right: settingsButton . left
anchors.top: parent . top
anchors.topMargin: 30
2023-06-02 23:59:53 +00:00
anchors.rightMargin: 10
2023-04-24 04:25:57 +00:00
width: 40
2023-04-16 15:44:55 +00:00
height: 40
z: 200
padding: 15
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/copy.svg"
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Copy" )
2023-04-18 12:39:48 +00:00
Accessible.description: qsTr ( "Copy the conversation to the clipboard" )
2023-04-11 12:54:57 +00:00
TextEdit {
id: copyEdit
visible: false
}
onClicked: {
2023-04-14 18:44:28 +00:00
var conversation = getConversation ( )
2023-04-11 12:54:57 +00:00
copyEdit . text = conversation
copyEdit . selectAll ( )
copyEdit . copy ( )
2023-04-16 15:44:55 +00:00
copyMessage . open ( )
2023-04-11 12:54:57 +00:00
}
}
2023-04-14 18:44:28 +00:00
function getConversation ( ) {
var conversation = "" ;
for ( var i = 0 ; i < chatModel . count ; i ++ ) {
var item = chatModel . get ( i )
var string = item . name ;
var isResponse = item . name === qsTr ( "Response: " )
2023-05-04 19:31:41 +00:00
string += chatModel . get ( i ) . value
2023-04-14 18:44:28 +00:00
if ( isResponse && item . stopped )
string += " <stopped>"
string += "\n"
conversation += string
}
return conversation
}
function getConversationJson ( ) {
var str = "{\"conversation\": [" ;
for ( var i = 0 ; i < chatModel . count ; i ++ ) {
var item = chatModel . get ( i )
var isResponse = item . name === qsTr ( "Response: " )
2023-04-26 02:17:22 +00:00
str += "{\"content\": " ;
2023-05-04 19:31:41 +00:00
str += JSON . stringify ( item . value )
2023-04-14 18:44:28 +00:00
str += ", \"role\": \"" + ( isResponse ? "assistant" : "user" ) + "\"" ;
if ( isResponse && item . thumbsUpState !== item . thumbsDownState )
str += ", \"rating\": \"" + ( item . thumbsUpState ? "positive" : "negative" ) + "\"" ;
if ( isResponse && item . newResponse !== "" )
2023-04-26 02:49:23 +00:00
str += ", \"edited_content\": " + JSON . stringify ( item . newResponse ) ;
2023-04-14 18:44:28 +00:00
if ( isResponse && item . stopped )
str += ", \"stopped\": \"true\""
if ( ! isResponse )
str += "},"
else
str += ( ( i < chatModel . count - 1 ) ? "}," : "}" )
}
return str + "]}"
}
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-04-11 12:54:57 +00:00
id: resetContextButton
anchors.right: copyButton . left
anchors.top: parent . top
anchors.topMargin: 30
2023-06-02 23:59:53 +00:00
anchors.rightMargin: 10
2023-04-24 04:25:57 +00:00
width: 40
2023-04-11 12:54:57 +00:00
height: 40
z: 200
padding: 15
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/regenerate.svg"
2023-04-11 12:54:57 +00:00
2023-04-18 12:39:48 +00:00
Accessible.name: text
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "Reset the context and erase current conversation" )
2023-04-18 12:39:48 +00:00
2023-04-11 03:34:34 +00:00
onClicked: {
2023-05-03 00:31:17 +00:00
Network . sendResetContext ( chatModel . count )
2023-05-01 21:13:20 +00:00
currentChat . reset ( ) ;
2023-07-01 15:34:21 +00:00
currentChat . processSystemPrompt ( ) ;
2023-04-11 03:34:34 +00:00
}
}
Dialog {
id: checkForUpdatesError
anchors.centerIn: parent
modal: false
opacity: 0.9
2023-04-14 18:44:28 +00:00
padding: 20
2023-04-11 03:34:34 +00:00
Text {
horizontalAlignment: Text . AlignJustify
text: qsTr ( " ERROR: Update system could not find the MaintenanceTool used < br >
to check for updates ! < br > < br >
Did you install this application using the online installer ? If so , < br >
the MaintenanceTool executable should be located one directory < br >
above where this application resides on your filesystem . < br > < br >
If you can 't start it manually, then I' m afraid you ' ll have to < br >
reinstall . " )
2023-04-23 13:42:35 +00:00
color: theme . textColor
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-04-18 12:39:48 +00:00
Accessible.role: Accessible . Dialog
Accessible.name: text
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "Error dialog" )
2023-04-11 03:34:34 +00:00
}
background: Rectangle {
anchors.fill: parent
2023-04-23 13:42:35 +00:00
color: theme . backgroundDarkest
2023-04-11 03:34:34 +00:00
border.width: 1
2023-04-23 13:42:35 +00:00
border.color: theme . dialogBorder
2023-04-11 03:34:34 +00:00
radius: 10
}
}
2023-04-19 01:10:06 +00:00
ModelDownloaderDialog {
id: downloadNewModels
anchors.centerIn: parent
2023-06-26 16:58:33 +00:00
width: Math . min ( 1280 , window . width - ( window . width * . 1 ) )
height: window . height - ( window . height * . 1 )
2023-04-19 01:10:06 +00:00
Item {
Accessible.role: Accessible . Dialog
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Download new models" )
2023-04-19 01:10:06 +00:00
Accessible.description: qsTr ( "Dialog for downloading new models" )
}
}
2023-05-01 17:51:46 +00:00
ChatDrawer {
2023-04-11 03:34:34 +00:00
id: drawer
y: header . height
2023-06-26 16:58:33 +00:00
width: Math . min ( 600 , 0.3 * window . width )
2023-04-11 03:34:34 +00:00
height: window . height - y
2023-05-01 17:51:46 +00:00
onDownloadClicked: {
2023-10-24 16:13:32 +00:00
downloadNewModels . showEmbeddingModels = false
2023-05-01 17:51:46 +00:00
downloadNewModels . open ( )
2023-04-10 21:31:40 +00:00
}
2023-05-05 14:47:05 +00:00
onAboutClicked: {
aboutDialog . open ( )
}
2023-04-11 03:34:34 +00:00
}
2023-05-25 14:40:10 +00:00
PopupDialog {
id: referenceContextDialog
anchors.centerIn: parent
shouldTimeOut: false
shouldShowBusy: false
modal: true
}
2023-04-11 03:34:34 +00:00
Rectangle {
id: conversation
2023-04-23 13:42:35 +00:00
color: theme . backgroundLight
2023-04-11 03:34:34 +00:00
anchors.left: parent . left
anchors.right: parent . right
anchors.bottom: parent . bottom
anchors.top: header . bottom
2023-04-10 21:31:40 +00:00
2023-04-09 03:28:39 +00:00
ScrollView {
id: scrollView
anchors.left: parent . left
anchors.right: parent . right
anchors.top: parent . top
2023-05-11 20:46:25 +00:00
anchors.bottom: ! currentChat . isServer ? textInputView.top : parent . bottom
anchors.bottomMargin: ! currentChat . isServer ? 30 : 0
2023-07-31 16:18:38 +00:00
ScrollBar.vertical.policy: ScrollBar . AlwaysOff
2023-04-09 03:28:39 +00:00
Rectangle {
anchors.fill: parent
2023-05-31 01:03:40 +00:00
color: currentChat . isServer ? theme.backgroundDark : theme . backgroundLight
2023-05-15 18:08:08 +00:00
2023-07-09 19:08:14 +00:00
Text {
2023-07-09 19:51:59 +00:00
id: warningLabel
text: qsTr ( "You must install a model to continue. Models are available via the download dialog or you can install them manually by downloading from <a href=\"https://gpt4all.io\">the GPT4All website</a> (look for the Models Explorer) and placing them in the model folder. The model folder can be found in the settings dialog under the application tab." )
2023-07-09 19:08:14 +00:00
color: theme . textColor
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-07-09 19:51:59 +00:00
width: 600
linkColor: theme . linkColor
2023-07-09 19:08:14 +00:00
wrapMode: Text . WordWrap
anchors.centerIn: parent
visible: ModelList . installedModels . count === 0
2023-07-09 19:51:59 +00:00
onLinkActivated: function ( link ) {
Qt . openUrlExternally ( link )
}
}
MyButton {
id: downloadButton
text: qsTr ( "Download models" )
visible: ModelList . installedModels . count === 0
anchors.top: warningLabel . bottom
anchors.topMargin: 20
anchors.horizontalCenter: warningLabel . horizontalCenter
padding: 15
leftPadding: 50
Image {
anchors.verticalCenter: parent . verticalCenter
anchors.left: parent . left
anchors.leftMargin: 15
width: 24
height: 24
mipmap: true
source: "qrc:/gpt4all/icons/download.svg"
}
background: Rectangle {
border.color: downloadButton . down ? theme.backgroundLightest : theme . buttonBorder
border.width: 2
radius: 10
color: downloadButton . hovered ? theme.backgroundLighter : theme . backgroundLight
}
onClicked: {
downloadNewModels . open ( ) ;
}
2023-07-09 19:08:14 +00:00
}
2023-04-09 03:28:39 +00:00
ListView {
id: listView
2023-07-09 19:08:14 +00:00
visible: ModelList . installedModels . count !== 0
2023-04-09 03:28:39 +00:00
anchors.fill: parent
model: chatModel
2023-07-31 16:18:38 +00:00
ScrollBar.vertical: ScrollBar { policy: ScrollBar . AlwaysOn }
2023-04-18 12:39:48 +00:00
Accessible.role: Accessible . List
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Conversation with the model" )
Accessible.description: qsTr ( "prompt / response pairs from the conversation" )
2023-04-18 12:39:48 +00:00
2023-04-09 03:28:39 +00:00
delegate: TextArea {
2023-06-10 14:15:38 +00:00
id: myTextArea
2023-05-24 20:13:35 +00:00
text: value + references
2023-04-09 05:11:52 +00:00
width: listView . width
2023-04-23 13:42:35 +00:00
color: theme . textColor
2023-04-09 03:28:39 +00:00
wrapMode: Text . WordWrap
2023-06-10 14:15:38 +00:00
textFormat: TextEdit . PlainText
2023-04-09 03:28:39 +00:00
focus: false
2023-04-14 00:06:46 +00:00
readOnly: true
2023-04-23 15:23:02 +00:00
font.pixelSize: theme . fontSizeLarge
2023-05-04 19:31:41 +00:00
cursorVisible: currentResponse ? currentChat.responseInProgress : false
2023-04-09 03:28:39 +00:00
cursorPosition: text . length
background: Rectangle {
2023-05-31 01:03:40 +00:00
opacity: 1.0
2023-05-11 20:46:25 +00:00
color: name === qsTr ( "Response: " )
? ( currentChat . isServer ? theme.backgroundDarkest : theme . backgroundLighter )
: ( currentChat . isServer ? theme.backgroundDark : theme . backgroundLight )
2023-04-09 03:28:39 +00:00
}
2023-06-11 17:24:56 +00:00
TapHandler {
id: tapHandler
onTapped: function ( eventPoint , button ) {
var clickedPos = myTextArea . positionAt ( eventPoint . position . x , eventPoint . position . y ) ;
2023-06-10 14:15:38 +00:00
var link = responseText . getLinkAtPosition ( clickedPos ) ;
2023-06-11 17:24:56 +00:00
if ( link . startsWith ( "context://" ) ) {
var integer = parseInt ( link . split ( "://" ) [ 1 ] ) ;
referenceContextDialog . text = referencesContext [ integer - 1 ] ;
referenceContextDialog . open ( ) ;
2023-06-10 16:34:43 +00:00
} else {
var success = responseText . tryCopyAtPosition ( clickedPos ) ;
if ( success )
copyCodeMessage . open ( ) ;
2023-06-11 17:24:56 +00:00
}
2023-06-10 14:15:38 +00:00
}
}
ResponseText {
id: responseText
}
Component.onCompleted: {
responseText . setLinkColor ( theme . linkColor ) ;
2023-06-12 12:34:59 +00:00
responseText . setHeaderColor ( name === qsTr ( "Response: " ) ? theme.backgroundLight : theme . backgroundLighter ) ;
responseText . textDocument = textDocument
2023-06-10 14:15:38 +00:00
}
2023-04-18 12:39:48 +00:00
Accessible.role: Accessible . Paragraph
Accessible.name: name
Accessible.description: name === qsTr ( "Response: " ) ? "The response by the model" : "The prompt by the user"
2023-04-14 18:44:28 +00:00
topPadding: 20
bottomPadding: 20
2023-05-31 18:26:59 +00:00
leftPadding: 70
2023-04-14 18:44:28 +00:00
rightPadding: 100
2023-04-09 03:28:39 +00:00
2023-05-21 00:04:36 +00:00
Item {
2023-04-12 15:39:43 +00:00
anchors.left: parent . left
2023-05-31 18:26:59 +00:00
anchors.leftMargin: 60
y: parent . topPadding + ( parent . positionToRectangle ( 0 ) . height / 2 ) - ( height / 2 )
2023-05-04 19:31:41 +00:00
visible: ( currentResponse ? true : false ) && value === "" && currentChat . responseInProgress
2023-05-21 00:04:36 +00:00
width: childrenRect . width
height: childrenRect . height
Row {
spacing: 5
2023-05-31 23:28:09 +00:00
MyBusyIndicator {
2023-05-21 00:04:36 +00:00
anchors.verticalCenter: parent . verticalCenter
running: ( currentResponse ? true : false ) && value === "" && currentChat . responseInProgress
Accessible.role: Accessible . Animation
Accessible.name: qsTr ( "Busy indicator" )
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "The model is thinking" )
2023-05-21 00:04:36 +00:00
}
Label {
anchors.verticalCenter: parent . verticalCenter
2023-05-31 23:28:09 +00:00
color: theme . textAccent
2023-10-29 22:34:42 +00:00
text: {
switch ( currentChat . responseState ) {
2023-10-24 16:13:32 +00:00
case Chat.ResponseStopped: return qsTr ( "response stopped ..." ) ;
case Chat.LocalDocsRetrieval: return qsTr ( "retrieving localdocs: " ) + currentChat . collectionList . join ( ", " ) + " ..." ;
case Chat.LocalDocsProcessing: return qsTr ( "searching localdocs: " ) + currentChat . collectionList . join ( ", " ) + " ..." ;
case Chat.PromptProcessing: return qsTr ( "processing ..." )
case Chat.ResponseGeneration: return qsTr ( "generating response ..." ) ;
2023-10-29 22:34:42 +00:00
default: return "" ; // handle unexpected values
}
}
2023-05-21 00:04:36 +00:00
}
}
2023-04-12 15:39:43 +00:00
}
2023-04-09 03:28:39 +00:00
Rectangle {
anchors.left: parent . left
anchors.leftMargin: 20
2023-05-31 18:26:59 +00:00
y: parent . topPadding + ( parent . positionToRectangle ( 0 ) . height / 2 ) - ( height / 2 )
2023-04-09 03:28:39 +00:00
width: 30
height: 30
radius: 5
2023-04-23 13:42:35 +00:00
color: name === qsTr ( "Response: " ) ? theme.assistantColor : theme . userColor
2023-04-09 03:28:39 +00:00
Text {
anchors.centerIn: parent
text: name === qsTr ( "Response: " ) ? "R" : "P"
color: "white"
}
}
2023-04-14 18:44:28 +00:00
ThumbsDownDialog {
id: thumbsDownDialog
property point globalPoint: mapFromItem ( window ,
window . width / 2 - width / 2 ,
window . height / 2 - height / 2 )
x: globalPoint . x
y: globalPoint . y
2023-05-04 19:31:41 +00:00
property string text: value
2023-04-27 15:44:41 +00:00
response: newResponse === undefined || newResponse === "" ? text : newResponse
2023-04-14 18:44:28 +00:00
onAccepted: {
var responseHasChanged = response !== text && response !== newResponse
if ( thumbsDownState && ! thumbsUpState && ! responseHasChanged )
return
2023-05-01 00:28:07 +00:00
chatModel . updateNewResponse ( index , response )
chatModel . updateThumbsUpState ( index , false )
chatModel . updateThumbsDownState ( index , true )
2023-05-01 21:13:20 +00:00
Network . sendConversation ( currentChat . id , getConversationJson ( ) ) ;
2023-04-14 18:44:28 +00:00
}
}
Column {
visible: name === qsTr ( "Response: " ) &&
2023-06-29 00:42:40 +00:00
( ! currentResponse || ! currentChat . responseInProgress ) && MySettings . networkIsActive
2023-04-14 18:44:28 +00:00
anchors.right: parent . right
anchors.rightMargin: 20
2023-05-31 18:26:59 +00:00
y: parent . topPadding + ( parent . positionToRectangle ( 0 ) . height / 2 ) - ( height / 2 )
2023-04-14 18:44:28 +00:00
spacing: 10
Item {
width: childrenRect . width
height: childrenRect . height
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-04-14 18:44:28 +00:00
id: thumbsUp
width: 30
height: 30
opacity: thumbsUpState || thumbsUpState == thumbsDownState ? 1.0 : 0.2
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/thumbs_up.svg"
2023-05-23 22:19:36 +00:00
Accessible.name: qsTr ( "Thumbs up" )
Accessible.description: qsTr ( "Gives a thumbs up to the response" )
2023-04-14 18:44:28 +00:00
onClicked: {
if ( thumbsUpState && ! thumbsDownState )
return
2023-05-01 00:28:07 +00:00
chatModel . updateNewResponse ( index , "" )
chatModel . updateThumbsUpState ( index , true )
chatModel . updateThumbsDownState ( index , false )
2023-05-01 21:13:20 +00:00
Network . sendConversation ( currentChat . id , getConversationJson ( ) ) ;
2023-04-14 18:44:28 +00:00
}
}
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-04-14 18:44:28 +00:00
id: thumbsDown
anchors.top: thumbsUp . top
anchors.topMargin: 10
anchors.left: thumbsUp . right
anchors.leftMargin: 2
width: 30
height: 30
checked: thumbsDownState
opacity: thumbsDownState || thumbsUpState == thumbsDownState ? 1.0 : 0.2
transform: [
Matrix4x4 {
matrix: Qt . matrix4x4 ( - 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 )
} ,
Translate {
x: thumbsDown . width
}
]
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/thumbs_down.svg"
2023-05-23 22:19:36 +00:00
Accessible.name: qsTr ( "Thumbs down" )
Accessible.description: qsTr ( "Opens thumbs down dialog" )
2023-04-14 18:44:28 +00:00
onClicked: {
thumbsDownDialog . open ( )
}
}
}
}
2023-04-09 03:28:39 +00:00
}
property bool shouldAutoScroll: true
property bool isAutoScrolling: false
Connections {
2023-05-04 19:31:41 +00:00
target: currentChat
2023-04-09 03:28:39 +00:00
function onResponseChanged ( ) {
if ( listView . shouldAutoScroll ) {
listView . isAutoScrolling = true
listView . positionViewAtEnd ( )
listView . isAutoScrolling = false
}
}
}
onContentYChanged: {
if ( ! isAutoScrolling )
shouldAutoScroll = atYEnd
}
Component.onCompleted: {
shouldAutoScroll = true
positionViewAtEnd ( )
}
footer: Item {
id: bottomPadding
width: parent . width
height: 60
}
}
2023-05-31 01:03:40 +00:00
Image {
2023-06-22 19:44:49 +00:00
visible: currentChat . isServer || currentChat . modelInfo . isChatGPT
2023-05-31 01:03:40 +00:00
anchors.fill: parent
sourceSize.width: 1024
sourceSize.height: 1024
fillMode: Image . PreserveAspectFit
opacity: 0.15
source: "qrc:/gpt4all/icons/network.svg"
}
2023-04-09 03:28:39 +00:00
}
}
2023-05-30 23:10:38 +00:00
MyButton {
2023-07-01 15:34:21 +00:00
id: myButton
2023-05-11 20:46:25 +00:00
visible: chatModel . count && ! currentChat . isServer
2023-04-09 03:28:39 +00:00
Image {
anchors.verticalCenter: parent . verticalCenter
anchors.left: parent . left
anchors.leftMargin: 15
2023-05-01 21:13:20 +00:00
source: currentChat . responseInProgress ? "qrc:/gpt4all/icons/stop_generating.svg" : "qrc:/gpt4all/icons/regenerate.svg"
2023-04-09 03:28:39 +00:00
}
2023-04-09 11:38:25 +00:00
leftPadding: 50
2023-04-09 03:28:39 +00:00
onClicked: {
2023-05-01 00:28:07 +00:00
var index = Math . max ( 0 , chatModel . count - 1 ) ;
var listElement = chatModel . get ( index ) ;
2023-04-14 18:44:28 +00:00
2023-05-01 21:13:20 +00:00
if ( currentChat . responseInProgress ) {
2023-04-14 18:44:28 +00:00
listElement . stopped = true
2023-05-01 21:13:20 +00:00
currentChat . stopGenerating ( )
2023-04-14 18:44:28 +00:00
} else {
2023-05-01 21:13:20 +00:00
currentChat . regenerateResponse ( )
2023-04-09 03:28:39 +00:00
if ( chatModel . count ) {
if ( listElement . name === qsTr ( "Response: " ) ) {
2023-05-01 00:28:07 +00:00
chatModel . updateCurrentResponse ( index , true ) ;
chatModel . updateStopped ( index , false ) ;
chatModel . updateThumbsUpState ( index , false ) ;
chatModel . updateThumbsDownState ( index , false ) ;
chatModel . updateNewResponse ( index , "" ) ;
2023-07-01 15:34:21 +00:00
currentChat . prompt ( listElement . prompt )
2023-04-09 03:28:39 +00:00
}
}
}
}
2023-07-01 15:34:21 +00:00
background: Rectangle {
border.color: myButton . down ? theme.backgroundLightest : theme . buttonBorder
border.width: 2
radius: 10
color: myButton . hovered ? theme.backgroundLighter : theme . backgroundLight
}
2023-04-20 12:31:33 +00:00
anchors.bottom: textInputView . top
anchors.horizontalCenter: textInputView . horizontalCenter
2023-05-31 01:03:40 +00:00
anchors.bottomMargin: 20
2023-04-09 03:28:39 +00:00
padding: 15
2023-05-30 23:10:38 +00:00
text: currentChat . responseInProgress ? qsTr ( "Stop generating" ) : qsTr ( "Regenerate response" )
Accessible.description: qsTr ( "Controls generation of the response" )
2023-04-09 03:28:39 +00:00
}
2023-06-19 18:34:53 +00:00
Text {
2023-09-13 19:24:33 +00:00
id: device
2023-06-19 18:34:53 +00:00
anchors.bottom: textInputView . top
anchors.bottomMargin: 20
anchors.right: parent . right
anchors.rightMargin: 30
color: theme . mutedTextColor
2023-09-13 19:48:55 +00:00
visible: currentChat . tokenSpeed !== ""
2023-09-29 18:25:37 +00:00
text: qsTr ( "Speed: " ) + currentChat . tokenSpeed + "<br>" + qsTr ( "Device: " ) + currentChat . device + currentChat . fallbackReason
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-06-19 18:34:53 +00:00
}
2023-05-31 01:03:40 +00:00
RectangularGlow {
id: effect
anchors.fill: textInputView
glowRadius: 50
spread: 0
color: theme . backgroundDark
cornerRadius: 10
opacity: 0.2
}
2023-04-20 12:31:33 +00:00
ScrollView {
id: textInputView
2023-04-09 03:28:39 +00:00
anchors.left: parent . left
2023-04-10 21:31:40 +00:00
anchors.right: parent . right
2023-04-09 03:28:39 +00:00
anchors.bottom: parent . bottom
anchors.margins: 30
2023-04-20 12:31:33 +00:00
height: Math . min ( contentHeight , 200 )
2023-05-11 20:46:25 +00:00
visible: ! currentChat . isServer
2023-04-20 12:31:33 +00:00
TextArea {
id: textInput
2023-06-01 00:31:59 +00:00
color: theme . textColor
2023-05-31 01:03:40 +00:00
topPadding: 30
bottomPadding: 30
leftPadding: 20
2023-04-27 15:54:53 +00:00
rightPadding: 40
2023-05-11 20:46:25 +00:00
enabled: currentChat . isModelLoaded && ! currentChat . isServer
2023-04-27 15:54:53 +00:00
wrapMode: Text . WordWrap
2023-05-31 01:03:40 +00:00
font.pixelSize: theme . fontSizeLarger
2023-04-20 12:31:33 +00:00
placeholderText: qsTr ( "Send a message..." )
2023-05-21 00:02:38 +00:00
placeholderTextColor: theme . mutedTextColor
2023-04-20 12:31:33 +00:00
background: Rectangle {
2023-05-31 01:03:40 +00:00
color: theme . backgroundAccent
2023-04-20 12:31:33 +00:00
radius: 10
}
Accessible.role: Accessible . EditableText
Accessible.name: placeholderText
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "Send messages/prompts to the model" )
2023-04-20 17:27:11 +00:00
Keys.onReturnPressed: ( event ) = > {
2023-04-20 12:31:33 +00:00
if ( event . modifiers & Qt . ControlModifier || event . modifiers & Qt . ShiftModifier )
event . accepted = false ;
2023-04-25 16:13:17 +00:00
else {
2023-04-20 12:31:33 +00:00
editingFinished ( ) ;
2023-04-25 16:13:17 +00:00
sendMessage ( )
}
2023-04-09 03:28:39 +00:00
}
2023-04-25 16:13:17 +00:00
function sendMessage ( ) {
2023-04-20 12:31:33 +00:00
if ( textInput . text === "" )
return
2023-04-09 16:59:58 +00:00
2023-05-01 21:13:20 +00:00
currentChat . stopGenerating ( )
currentChat . newPromptResponsePair ( textInput . text ) ;
2023-06-28 19:47:15 +00:00
currentChat . prompt ( textInput . text ,
MySettings . promptTemplate ,
MySettings . maxLength ,
MySettings . topK ,
MySettings . topP ,
MySettings . temperature ,
MySettings . promptBatchSize ,
MySettings . repeatPenalty ,
MySettings . repeatPenaltyTokens )
2023-04-20 12:31:33 +00:00
textInput . text = ""
2023-04-09 03:28:39 +00:00
}
2023-04-20 12:31:33 +00:00
}
}
2023-04-09 03:28:39 +00:00
2023-06-01 01:07:14 +00:00
MyToolButton {
2023-04-20 12:31:33 +00:00
anchors.right: textInputView . right
anchors.verticalCenter: textInputView . verticalCenter
anchors.rightMargin: 15
width: 30
height: 30
2023-05-11 20:46:25 +00:00
visible: ! currentChat . isServer
2023-06-01 01:07:14 +00:00
source: "qrc:/gpt4all/icons/send_message.svg"
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Send message" )
2023-04-20 12:31:33 +00:00
Accessible.description: qsTr ( "Sends the message/prompt contained in textfield to the model" )
onClicked: {
2023-04-25 16:13:17 +00:00
textInput . sendMessage ( )
2023-04-09 03:28:39 +00:00
}
}
}
}