From a17c349d7f1987b9d6d999dbc43864d27437d7cc Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Fri, 30 Jun 2023 19:01:12 -0400 Subject: [PATCH 1/6] Update ToolsSqlite.py --- db/ToolsSqlite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/ToolsSqlite.py b/db/ToolsSqlite.py index c79a617e1..6bbbfc6cd 100644 --- a/db/ToolsSqlite.py +++ b/db/ToolsSqlite.py @@ -945,7 +945,7 @@ def getRawContent(self, entry): def getReverseContent(self, entry): search = "%{0}%".format(entry) query = TextUtil.getQueryPrefix() - query += "SELECT Topic, Definition FROM Lexicon WHERE Definition LIKE ?" + query += "SELECT Topic, Definition FROM Lexicon WHERE Definition LIKE ? ORDER BY Topic" self.cursor.execute(query, (search,)) records = self.cursor.fetchall() contentText = """

{0}

""".format(self.module) From 41f45a85c773c14001b03c857b9d2a77312f24a7 Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Fri, 30 Jun 2023 19:10:11 -0400 Subject: [PATCH 2/6] Update ToolsSqlite.py --- db/ToolsSqlite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/ToolsSqlite.py b/db/ToolsSqlite.py index e16f4a102..10705a91d 100644 --- a/db/ToolsSqlite.py +++ b/db/ToolsSqlite.py @@ -961,7 +961,7 @@ def getReverseContent(self, entry): def getRawReverseContent(self, entry): try: search = "%{0}%".format(entry) - query = "SELECT Topic, Definition FROM Lexicon WHERE Definition LIKE ?" + query = "SELECT Topic, Definition FROM Lexicon WHERE Definition LIKE ? ORDER BY Topic" self.cursor.execute(query, (search,)) return self.cursor.fetchall() except Exception as ex: From 9f322096d6c65b3ae13533fe483069858706603e Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Sat, 16 Sep 2023 23:08:41 -0400 Subject: [PATCH 3/6] Add some improvements to Bible Chat (#271) Update Bible Chat.py --- UniqueBibleAppVersion.txt | 2 +- latest_changes.txt | 7 ++++++ patches.txt | 10 ++++----- plugins/chatGPT/000_UBA.py | 2 +- plugins/menu/Bible Chat.py | 46 +++++++++++++++++++++----------------- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/UniqueBibleAppVersion.txt b/UniqueBibleAppVersion.txt index 9f9af530d..4ca8639df 100755 --- a/UniqueBibleAppVersion.txt +++ b/UniqueBibleAppVersion.txt @@ -1 +1 @@ -34.98 +34.99 diff --git a/latest_changes.txt b/latest_changes.txt index 5b32698a7..8f1635fd9 100755 --- a/latest_changes.txt +++ b/latest_changes.txt @@ -1,3 +1,10 @@ +Changes in 34.99: +Improved plugin "Bible Chat" +* Moved the predefined context selection out of settings to the main window so can quickly change the context +* Added tool tip to context selection to see what it will do +* Added the context selection to the title to see what was run +* Fixed prayer predefined context + Changes in 34.98: Improved terminal mode * added options to integrate internet searches into ChatGPT responses: "always", "auto", "none" diff --git a/patches.txt b/patches.txt index 9fdd53109..a3fe0de6b 100755 --- a/patches.txt +++ b/patches.txt @@ -1358,7 +1358,6 @@ (34.82, "file", "gui/MaterialMainWindow.py") (34.82, "file", "util/VlcUtil.py") (34.85, "file", "db/AGBTSData.py") -(34.85, "file", "plugins/chatGPT/000_UBA.py") (34.86, "file", "util/TextCommandParser.py") (34.87, "file", "util/AGBsubheadings.py") (34.87, "file", "db/BiblesSqlite.py") @@ -1387,8 +1386,9 @@ (34.97, "file", "util/ConfigUtil.py") (34.98, "file", "gui/Worker.py") (34.98, "file", "plugins/chatGPT/integrate google searches.py") -(34.98, "file", "plugins/menu/Bible Chat.py") (34.98, "file", "util/LocalCliHandler.py") -(34.98, "file", "latest_changes.txt") -(34.98, "file", "UniqueBibleAppVersion.txt") -(34.98, "file", "patches.txt") +(34.99, "file", "plugins/chatGPT/000_UBA.py") +(34.99, "file", "plugins/menu/Bible Chat.py") +(34.99, "file", "latest_changes.txt") +(34.99, "file", "UniqueBibleAppVersion.txt") +(34.99, "file", "patches.txt") diff --git a/plugins/chatGPT/000_UBA.py b/plugins/chatGPT/000_UBA.py index ab88a613b..dbf4192b4 100644 --- a/plugins/chatGPT/000_UBA.py +++ b/plugins/chatGPT/000_UBA.py @@ -6,7 +6,7 @@ config.predefinedContexts["Meaning in the Bible"] = """What is the meaning of the following content in reference to the Bible?""" config.predefinedContexts["Write a Summary"] = """Write a summary on the following content.""" config.predefinedContexts["Write a Sermon"] = """Write a sermon on the following content in reference to the Bible.""" -config.predefinedContexts["Write a Prayer"] = """Write a summary on the following content in reference to the Bible.""" +config.predefinedContexts["Write a Prayer"] = """Write a prayer on the following content in reference to the Bible.""" config.predefinedContexts["Key Words"] = """Identify key words in the following content. Elaborate on their importance in comprehending the context and the bible as a whole. I want your elaboration to be comprehensive and informative. diff --git a/plugins/menu/Bible Chat.py b/plugins/menu/Bible Chat.py index dc13857b1..657dae0f7 100644 --- a/plugins/menu/Bible Chat.py +++ b/plugins/menu/Bible Chat.py @@ -115,18 +115,6 @@ def __init__(self, parent=None): self.applyContextIn = QComboBox() self.applyContextIn.addItems([firstInputOnly, allInputs]) self.applyContextIn.setCurrentIndex(1 if config.chatGPTApiContextInAllInputs else 0) - self.predefinedContextBox = QComboBox() - initialIndex = 0 - index = 0 - for key, value in config.predefinedContexts.items(): - self.predefinedContextBox.addItem(key) - self.predefinedContextBox.setItemData(self.predefinedContextBox.count()-1, value, role=Qt.ToolTipRole) - if key == config.chatGPTApiPredefinedContext: - initialIndex = index - index += 1 - self.predefinedContextBox.currentIndexChanged.connect(self.predefinedContextBoxChanged) - self.predefinedContextBox.setCurrentIndex(initialIndex) - # set availability of self.contextEdit in case there is no index changed self.contextEdit.setDisabled(True) if not initialIndex == 1 else self.contextEdit.setEnabled(True) """self.languageBox = QComboBox() initialIndex = 0 @@ -147,7 +135,6 @@ def __init__(self, parent=None): chatAfterFunctionCalled = config.thisTranslation["chatAfterFunctionCalled"] runPythonScriptGlobally = config.thisTranslation["runPythonScriptGlobally"] autoScroll = config.thisTranslation["autoScroll"] - predefinedContext = config.thisTranslation["predefinedContext"] context = config.thisTranslation["chatContext"] applyContext = config.thisTranslation["applyContext"] latestOnlineSearchResults = config.thisTranslation["latestOnlineSearchResults"] @@ -161,7 +148,6 @@ def __init__(self, parent=None): layout.addRow(f"Max Token [{required}]:", self.maxTokenEdit) layout.addRow(f"Function Calling [{optional}]:", self.functionCallingBox) layout.addRow(f"{chatAfterFunctionCalled} [{optional}]:", self.chatAfterFunctionCalledCheckBox) - layout.addRow(f"{predefinedContext} [{optional}]:", self.predefinedContextBox) layout.addRow(f"{context} [{optional}]:", self.contextEdit) layout.addRow(f"{applyContext} [{optional}]:", self.applyContextIn) layout.addRow(f"{latestOnlineSearchResults} [{optional}]:", self.loadingInternetSearchesBox) @@ -187,13 +173,6 @@ def org(self): def contextInAllInputs(self): return True if self.applyContextIn.currentIndex() == 1 else False - def predefinedContextBoxChanged(self, index): - self.contextEdit.setDisabled(True) if not index == 1 else self.contextEdit.setEnabled(True) - - def predefinedContext(self): - return self.predefinedContextBox.currentText() - #return self.predefinedContextBox.currentData(Qt.ToolTipRole) - def apiModel(self): #return "gpt-3.5-turbo" return self.apiModelBox.currentText() @@ -485,6 +464,23 @@ def setupUI(self): promptLayout.addWidget(self.sendButton) promptLayout.addWidget(self.apiModels) layout000Rt.addLayout(promptLayout) + + self.predefinedContextBox = QComboBox() + initialIndex = 0 + index = 0 + for key, value in config.predefinedContexts.items(): + self.predefinedContextBox.addItem(key) + self.predefinedContextBox.setItemData(self.predefinedContextBox.count()-1, value, role=Qt.ToolTipRole) + if key == config.chatGPTApiPredefinedContext: + initialIndex = index + index += 1 + self.predefinedContextBox.currentIndexChanged.connect(self.predefinedContextBoxChanged) + self.predefinedContextBox.setCurrentIndex(initialIndex) + + predefinedSelectionLayout = QHBoxLayout() + predefinedSelectionLayout.addWidget(self.predefinedContextBox) + layout000Rt.addLayout(predefinedSelectionLayout) + layout000Rt.addWidget(self.contentView) layout000Rt.addWidget(self.progressBar) self.progressBar.hide() @@ -573,6 +569,12 @@ def setupUI(self): self.updateSearchToolTips() + def predefinedContextBoxChanged(self, index): + self.setUserInputFocus() + config.chatGPTApiPredefinedContext = self.predefinedContextBox.currentText() + desc = config.predefinedContexts[self.predefinedContextBox.currentText()] + self.predefinedContextBox.setToolTip(desc) + def setFontSize(self, index=None): if index is not None: config.chatGPTFontSize = index + 1 @@ -995,6 +997,8 @@ def getMessages(self, userInput): return messages def print(self, text): + if not config.chatGPTApiPredefinedContext == "[none]": + text += " (" + config.chatGPTApiPredefinedContext + ")" self.contentView.appendPlainText(f"\n{text}" if self.contentView.toPlainText() else text) self.contentView.setPlainText(re.sub("\n\n[\n]+?([^\n])", r"\n\n\1", self.contentView.toPlainText())) From a75464e63547a2df89491c75c520fe64b69a45ae Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Sat, 16 Sep 2023 23:25:21 -0400 Subject: [PATCH 4/6] Update Bible Chat.py --- plugins/menu/Bible Chat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/menu/Bible Chat.py b/plugins/menu/Bible Chat.py index 657dae0f7..a91bafd5d 100644 --- a/plugins/menu/Bible Chat.py +++ b/plugins/menu/Bible Chat.py @@ -838,6 +838,8 @@ def searchData(self): def bibleChatAction(self, context=""): if context: config.chatGPTApiPredefinedContext = context + index = list(config.predefinedContexts).index(context) + self.predefinedContextBox.setCurrentIndex(index) currentSelectedText = self.contentView.textCursor().selectedText().strip() if currentSelectedText: self.newData() From b9f5b02a31dcbb87321ebb313ba9594a16ff1cd6 Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Sat, 16 Sep 2023 23:28:59 -0400 Subject: [PATCH 5/6] Update latest_changes.txt --- latest_changes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest_changes.txt b/latest_changes.txt index 8f1635fd9..c3e29ce1b 100755 --- a/latest_changes.txt +++ b/latest_changes.txt @@ -1,6 +1,6 @@ Changes in 34.99: Improved plugin "Bible Chat" -* Moved the predefined context selection out of settings to the main window so can quickly change the context +* Moved the predefined context selection out of settings to the main window so can quickly change and view the current context * Added tool tip to context selection to see what it will do * Added the context selection to the title to see what was run * Fixed prayer predefined context From e3650477ad319370eb7a8e4ea9579ad1f2b699be Mon Sep 17 00:00:00 2001 From: Oliver Tseng Date: Sun, 17 Sep 2023 06:27:06 -0400 Subject: [PATCH 6/6] Update 000_UBA.py --- plugins/chatGPT/000_UBA.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/chatGPT/000_UBA.py b/plugins/chatGPT/000_UBA.py index dbf4192b4..c514abf77 100644 --- a/plugins/chatGPT/000_UBA.py +++ b/plugins/chatGPT/000_UBA.py @@ -4,9 +4,11 @@ config.predefinedContexts["Word Meaning"] = """What is the meaning of the following word or words?""" config.predefinedContexts["Meaning in the Bible"] = """What is the meaning of the following content in reference to the Bible?""" -config.predefinedContexts["Write a Summary"] = """Write a summary on the following content.""" +config.predefinedContexts["Write a Summary"] = """Write a summary on the following content in reference to the Bible.""" config.predefinedContexts["Write a Sermon"] = """Write a sermon on the following content in reference to the Bible.""" config.predefinedContexts["Write a Prayer"] = """Write a prayer on the following content in reference to the Bible.""" +config.predefinedContexts["Write a Short Prayer"] = """Write a prayer on the following content in reference to the Bible. +Keep the prayer short and do not make it longer than a paragraph.""" config.predefinedContexts["Key Words"] = """Identify key words in the following content. Elaborate on their importance in comprehending the context and the bible as a whole. I want your elaboration to be comprehensive and informative.