OllamaInterface/OllamaWidget.py

changeset 12
cf507e6f12d7
parent 11
3641ea6b55d5
child 13
3fd49d7004b2
equal deleted inserted replaced
11:3641ea6b55d5 12:cf507e6f12d7
79 79
80 self.__chatHistoryLayout = QVBoxLayout() 80 self.__chatHistoryLayout = QVBoxLayout()
81 self.historyScrollWidget.setLayout(self.__chatHistoryLayout) 81 self.historyScrollWidget.setLayout(self.__chatHistoryLayout)
82 self.__chatHistoryLayout.addStretch(1) 82 self.__chatHistoryLayout.addStretch(1)
83 83
84 self.mainSplitter.setSizes([200, 2000]) 84 self.mainSplitter.setSizes([200, 2000, 100])
85 85
86 self.newChatButton.setEnabled(False) 86 self.newChatButton.setEnabled(False)
87 self.__handleServerStateChanged(False) 87 self.__handleServerStateChanged(False)
88 88
89 self.__pullProgressDialog = None 89 self.__pullProgressDialog = None
97 self.__connectClient() 97 self.__connectClient()
98 98
99 self.__initOllamaMenu() 99 self.__initOllamaMenu()
100 100
101 self.sendButton.clicked.connect(self.__sendMessage) 101 self.sendButton.clicked.connect(self.__sendMessage)
102 self.messageEdit.returnPressed.connect(self.__sendMessage)
103 102
104 self.__loadHistory() 103 self.__loadHistory()
105 self.__updateMessageEditState() 104 self.__updateMessageEditState()
106 105
107 def __connectClient(self): 106 def __connectClient(self):
516 """ 515 """
517 Private slot to set the enabled state of the message line edit and the send 516 Private slot to set the enabled state of the message line edit and the send
518 button. 517 button.
519 """ 518 """
520 chatActive = bool(self.chatStackWidget.count()) 519 chatActive = bool(self.chatStackWidget.count())
521 hasText = bool(self.messageEdit.text()) 520 hasText = bool(self.messageEdit.toPlainText())
522 521
523 self.messageEdit.setEnabled(chatActive) 522 self.messageEdit.setEnabled(chatActive)
524 self.sendButton.setEnabled(chatActive and hasText) 523 self.sendButton.setEnabled(chatActive and hasText)
525 524
526 @pyqtSlot(str) 525 @pyqtSlot()
527 def on_messageEdit_textChanged(self, msg): 526 def on_messageEdit_textChanged(self):
528 """ 527 """
529 Private slot to handle a change of the entered message. 528 Private slot to handle a change of the entered message.
530 529 """
531 @param msg text of the message line edit 530 self.sendButton.setEnabled(bool(self.messageEdit.toPlainText()))
532 @type str
533 """
534 self.sendButton.setEnabled(bool(msg))
535 531
536 @pyqtSlot() 532 @pyqtSlot()
537 def __sendMessage(self): 533 def __sendMessage(self):
538 """ 534 """
539 Private method to send the given message of the current chat to the 535 Private method to send the given message of the current chat to the
540 'ollama' server. 536 'ollama' server.
541 537
542 This sends the message with context (i.e. the history of the current chat). 538 This sends the message with context (i.e. the history of the current chat).
543 """ 539 """
544 msg = self.messageEdit.text() 540 msg = self.messageEdit.toPlainText()
545 if not msg: 541 if not msg:
546 # empty message => ignore 542 # empty message => ignore
547 return 543 return
548 544
549 if not bool(self.chatStackWidget.count()): 545 if not bool(self.chatStackWidget.count()):

eric ide

mercurial