Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some improvements to Bible Chat #1390

Merged
merged 15 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UniqueBibleAppVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
34.98
34.99
7 changes: 7 additions & 0 deletions latest_changes.txt
Original file line number Diff line number Diff line change
@@ -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 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

Changes in 34.98:
Improved terminal mode
* added options to integrate internet searches into ChatGPT responses: "always", "auto", "none"
Expand Down
10 changes: 5 additions & 5 deletions patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
6 changes: 4 additions & 2 deletions plugins/chatGPT/000_UBA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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["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.
Expand Down
48 changes: 27 additions & 21 deletions plugins/menu/Bible Chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -836,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()
Expand Down Expand Up @@ -995,6 +999,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()))

Expand Down