Add multi-line prompt support.

This commit is contained in:
Adam Treat 2023-04-20 08:31:33 -04:00
parent 4c970fdc9c
commit cd5f525950

View File

@ -755,7 +755,7 @@ Window {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: textInput.top anchors.bottom: textInputView.top
anchors.bottomMargin: 30 anchors.bottomMargin: 30
ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.policy: ScrollBar.AlwaysOn
@ -886,8 +886,8 @@ Window {
} }
} }
} }
anchors.bottom: textInput.top anchors.bottom: textInputView.top
anchors.horizontalCenter: textInput.horizontalCenter anchors.horizontalCenter: textInputView.horizontalCenter
anchors.bottomMargin: 40 anchors.bottomMargin: 40
padding: 15 padding: 15
contentItem: Text { contentItem: Text {
@ -906,12 +906,16 @@ Window {
} }
} }
TextField { ScrollView {
id: textInput id: textInputView
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.margins: 30 anchors.margins: 30
height: Math.min(contentHeight, 200)
TextArea {
id: textInput
color: "#dadadc" color: "#dadadc"
padding: 20 padding: 20
enabled: LLM.isModelLoaded enabled: LLM.isModelLoaded
@ -925,7 +929,13 @@ Window {
Accessible.role: Accessible.EditableText Accessible.role: Accessible.EditableText
Accessible.name: placeholderText Accessible.name: placeholderText
Accessible.description: qsTr("Textfield for sending messages/prompts to the model") Accessible.description: qsTr("Textfield for sending messages/prompts to the model")
onAccepted: { Keys.onReturnPressed: {
if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier)
event.accepted = false;
else
editingFinished();
}
onEditingFinished: {
if (textInput.text === "") if (textInput.text === "")
return return
@ -945,10 +955,12 @@ Window {
settingsDialog.topP, settingsDialog.temperature, settingsDialog.promptBatchSize) settingsDialog.topP, settingsDialog.temperature, settingsDialog.promptBatchSize)
textInput.text = "" textInput.text = ""
} }
}
}
Button { Button {
anchors.right: textInput.right anchors.right: textInputView.right
anchors.verticalCenter: textInput.verticalCenter anchors.verticalCenter: textInputView.verticalCenter
anchors.rightMargin: 15 anchors.rightMargin: 15
width: 30 width: 30
height: 30 height: 30
@ -967,5 +979,4 @@ Window {
} }
} }
} }
}
} }