mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-08 07:10:32 +00:00
Add multi-line prompt support.
This commit is contained in:
parent
963ef4b617
commit
9c85a2ceb2
115
main.qml
115
main.qml
@ -755,7 +755,7 @@ Window {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: textInput.top
|
||||
anchors.bottom: textInputView.top
|
||||
anchors.bottomMargin: 30
|
||||
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
||||
|
||||
@ -886,8 +886,8 @@ Window {
|
||||
}
|
||||
}
|
||||
}
|
||||
anchors.bottom: textInput.top
|
||||
anchors.horizontalCenter: textInput.horizontalCenter
|
||||
anchors.bottom: textInputView.top
|
||||
anchors.horizontalCenter: textInputView.horizontalCenter
|
||||
anchors.bottomMargin: 40
|
||||
padding: 15
|
||||
contentItem: Text {
|
||||
@ -906,65 +906,76 @@ Window {
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: textInput
|
||||
ScrollView {
|
||||
id: textInputView
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 30
|
||||
color: "#dadadc"
|
||||
padding: 20
|
||||
enabled: LLM.isModelLoaded
|
||||
font.pixelSize: 24
|
||||
placeholderText: qsTr("Send a message...")
|
||||
placeholderTextColor: "#7d7d8e"
|
||||
background: Rectangle {
|
||||
color: "#40414f"
|
||||
radius: 10
|
||||
}
|
||||
Accessible.role: Accessible.EditableText
|
||||
Accessible.name: placeholderText
|
||||
Accessible.description: qsTr("Textfield for sending messages/prompts to the model")
|
||||
onAccepted: {
|
||||
if (textInput.text === "")
|
||||
return
|
||||
height: Math.min(contentHeight, 200)
|
||||
|
||||
LLM.stopGenerating()
|
||||
|
||||
if (chatModel.count) {
|
||||
var listElement = chatModel.get(chatModel.count - 1)
|
||||
listElement.currentResponse = false
|
||||
listElement.value = LLM.response
|
||||
TextArea {
|
||||
id: textInput
|
||||
color: "#dadadc"
|
||||
padding: 20
|
||||
enabled: LLM.isModelLoaded
|
||||
font.pixelSize: 24
|
||||
placeholderText: qsTr("Send a message...")
|
||||
placeholderTextColor: "#7d7d8e"
|
||||
background: Rectangle {
|
||||
color: "#40414f"
|
||||
radius: 10
|
||||
}
|
||||
Accessible.role: Accessible.EditableText
|
||||
Accessible.name: placeholderText
|
||||
Accessible.description: qsTr("Textfield for sending messages/prompts to the model")
|
||||
Keys.onReturnPressed: {
|
||||
if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier)
|
||||
event.accepted = false;
|
||||
else
|
||||
editingFinished();
|
||||
}
|
||||
onEditingFinished: {
|
||||
if (textInput.text === "")
|
||||
return
|
||||
|
||||
var prompt = textInput.text + "\n"
|
||||
chatModel.append({"name": qsTr("Prompt: "), "currentResponse": false, "value": textInput.text})
|
||||
chatModel.append({"name": qsTr("Response: "), "currentResponse": true, "value": "", "prompt": prompt})
|
||||
LLM.resetResponse()
|
||||
LLM.prompt(prompt, settingsDialog.promptTemplate, settingsDialog.maxLength, settingsDialog.topK,
|
||||
settingsDialog.topP, settingsDialog.temperature, settingsDialog.promptBatchSize)
|
||||
textInput.text = ""
|
||||
LLM.stopGenerating()
|
||||
|
||||
if (chatModel.count) {
|
||||
var listElement = chatModel.get(chatModel.count - 1)
|
||||
listElement.currentResponse = false
|
||||
listElement.value = LLM.response
|
||||
}
|
||||
|
||||
var prompt = textInput.text + "\n"
|
||||
chatModel.append({"name": qsTr("Prompt: "), "currentResponse": false, "value": textInput.text})
|
||||
chatModel.append({"name": qsTr("Response: "), "currentResponse": true, "value": "", "prompt": prompt})
|
||||
LLM.resetResponse()
|
||||
LLM.prompt(prompt, settingsDialog.promptTemplate, settingsDialog.maxLength, settingsDialog.topK,
|
||||
settingsDialog.topP, settingsDialog.temperature, settingsDialog.promptBatchSize)
|
||||
textInput.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.right: textInputView.right
|
||||
anchors.verticalCenter: textInputView.verticalCenter
|
||||
anchors.rightMargin: 15
|
||||
width: 30
|
||||
height: 30
|
||||
|
||||
background: Image {
|
||||
anchors.centerIn: parent
|
||||
source: "qrc:/gpt4all-chat/icons/send_message.svg"
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.right: textInput.right
|
||||
anchors.verticalCenter: textInput.verticalCenter
|
||||
anchors.rightMargin: 15
|
||||
width: 30
|
||||
height: 30
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.name: qsTr("Send the message button")
|
||||
Accessible.description: qsTr("Sends the message/prompt contained in textfield to the model")
|
||||
|
||||
background: Image {
|
||||
anchors.centerIn: parent
|
||||
source: "qrc:/gpt4all-chat/icons/send_message.svg"
|
||||
}
|
||||
|
||||
Accessible.role: Accessible.Button
|
||||
Accessible.name: qsTr("Send the message button")
|
||||
Accessible.description: qsTr("Sends the message/prompt contained in textfield to the model")
|
||||
|
||||
onClicked: {
|
||||
textInput.accepted()
|
||||
}
|
||||
onClicked: {
|
||||
textInput.accepted()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user