Skip to content

Commit

Permalink
v34.95; improved plugin Bible Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranwong committed Sep 9, 2023
1 parent bca7e49 commit 2223468
Show file tree
Hide file tree
Showing 23 changed files with 510 additions and 74 deletions.
2 changes: 1 addition & 1 deletion UniqueBibleAppVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
34.94
34.95
5 changes: 3 additions & 2 deletions gui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5722,8 +5722,9 @@ def runBibleChatPlugins(self):

pluginFolder = os.path.join(os.getcwd(), "plugins", "chatGPT")
for plugin in FileUtil.fileNamesWithoutExtension(pluginFolder, "py"):
script = os.path.join(pluginFolder, "{0}.py".format(plugin))
self.execPythonFile(script)
if not plugin in config.chatGPTPluginExcludeList:
script = os.path.join(pluginFolder, "{0}.py".format(plugin))
self.execPythonFile(script)

def bibleChatAction(self, context="", copiedText=False):
if context:
Expand Down
45 changes: 29 additions & 16 deletions gui/Worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, parent):
def getResponse(self, messages, progress_callback):
responses = ""
try:
if config.chatGPTApiNoOfChoices == 1 and config.chatGPTApiFunctionCall == "none":
if config.chatGPTApiNoOfChoices == 1 and (config.chatGPTApiFunctionCall == "none" or not config.chatGPTApiFunctionSignatures):
completion = openai.ChatCompletion.create(
model=config.chatGPTApiModel,
messages=messages,
Expand All @@ -113,15 +113,24 @@ def getResponse(self, messages, progress_callback):
# STREAM THE ANSWER
progress_callback.emit(progress)
else:
completion = openai.ChatCompletion.create(
model=config.chatGPTApiModel,
messages=messages,
max_tokens=config.chatGPTApiMaxTokens,
temperature=config.chatGPTApiTemperature,
n=config.chatGPTApiNoOfChoices,
functions=config.chatGPTApiFunctionSignatures,
function_call=config.chatGPTApiFunctionCall,
)
if config.chatGPTApiFunctionSignatures:
completion = openai.ChatCompletion.create(
model=config.chatGPTApiModel,
messages=messages,
max_tokens=config.chatGPTApiMaxTokens,
temperature=config.chatGPTApiTemperature,
n=config.chatGPTApiNoOfChoices,
functions=config.chatGPTApiFunctionSignatures,
function_call=config.chatGPTApiFunctionCall,
)
else:
completion = openai.ChatCompletion.create(
model=config.chatGPTApiModel,
messages=messages,
max_tokens=config.chatGPTApiMaxTokens,
temperature=config.chatGPTApiTemperature,
n=config.chatGPTApiNoOfChoices,
)

response_message = completion["choices"][0]["message"]
if response_message.get("function_call"):
Expand All @@ -143,15 +152,19 @@ def getResponse(self, messages, progress_callback):
"content": function_response,
}
) # extend conversation with function response
return self.getResponse(messages, progress_callback)
if config.chatAfterFunctionCalled:
return self.getResponse(messages, progress_callback)
else:
responses += f"{function_response}\n\n"

for index, choice in enumerate(completion.choices):
chat_response = choice.message.content
if len(completion.choices) > 1:
if index > 0:
responses += "\n"
responses += f"~~~ Response {(index+1)}:\n"
responses += f"{chat_response}\n\n"
if chat_response:
if len(completion.choices) > 1:
if index > 0:
responses += "\n"
responses += f"~~~ Response {(index+1)}:\n"
responses += f"{chat_response}\n\n"
# error codes: https://platform.openai.com/docs/guides/error-codes/python-library-error-types
except openai.error.APIError as e:
#Handle API error here, e.g. retry or log
Expand Down
12 changes: 12 additions & 0 deletions lang/language_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Führen Sie eine semantische Suche im Bibeltext über GPT \n aus (für die Ausführung dieses Features ist der OpenAI-API-Schlüssel erforderlich.) \n z.B. langsames Sprechen \n z.B. Zitat Verse über Gott schuf die Erde \n z.B. Jesus traf Nicodemus \n z.B. ähnliche Verse zu Genesis 1: 1 in Hebräer \n z.B. schreiben eine Zusammenfassung zu Exodus 13 \n z.B. vergleichen Mark 1 und John 1",
"exportChat": "Chat exportieren",
"countPromptTokens": "Token für Zähler zählen",
"pluginDirectory": "Plugins-Verzeichnis",
"textSelection": "Textauswahl",
"webBrowser": "Webbrowser",
"runAsSystemCommand": "Als Systembefehl ausführen",
"runAsPythonCommand": "Als Python-Script ausführen",
"plugins": "Plugins",
"chatAfterFunctionCalled": "Mit Funktionsantwort chatten",
"runPythonScriptGlobally": "Python-Script Globally ausführen",
"readTextFile": "Textdatei lesen",
"customise": "Anpassen",
"donate": "Spenden",
"about": "Informationen zu",
}
12 changes: 12 additions & 0 deletions lang/language_el.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Εκτελέστε μια σημασιολογική αναζήτηση στο κείμενο bible μέσω της GPT \n (απαιτείται το κλειδί OpenAI API για την εκτέλεση αυτής της λειτουργίας.) \n π.χ. αργή ομιλία \n π.χ. στίχοι για το Θεό που δημιούργησε τη γη, π.χ. ο Ιησούς συνάντησε το Νικόδημο \n π.χ. παρόμοιους στίχους με τη Γένεση 1: 1 σε Εβραίους \n π.χ. γράψτε μια περίληψη για την Έξοδο 13 \n π.χ. συγκρίνετε Mark 1 και John 1",
"exportChat": "Εξαγωγή συνομιλίας",
"countPromptTokens": "Κόμης Prompt Tokens",
"pluginDirectory": "Κατάλογος πρόσθετων λειτουργιών",
"textSelection": "Επιλογή κειμένου",
"webBrowser": "Πρόγραμμα πλοήγησης Web",
"runAsSystemCommand": "Εκτέλεση ως εντολής συστήματος",
"runAsPythonCommand": "Εκτέλεση ως σεναρίου Python",
"plugins": "Plugins",
"chatAfterFunctionCalled": "Συνομιλία με ανταπόκριση συνάρτησης",
"runPythonScriptGlobally": "Εκτέλεση σεναρίου Python",
"readTextFile": "Αρχείο κειμένου ανάγνωσης",
"customise": "Προσαρμογή:",
"donate": "Δότη!",
"about": "-Ναι.",
}
12 changes: 12 additions & 0 deletions lang/language_en_GB.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Perform a semantic search on bible text via GPT \n (OpenAI API key is required to run this feature.) \n e.g. slow to speak \n e.g. quote verses about God created the earth \n e.g. Jesus met Nicodemus \n e.g. similar verses to Genesis 1:1 in Hebrews \n e.g. write a summary on Exodus 13 \n e.g. compare Mark 1 and John 1",
"exportChat": "Export Chat",
"countPromptTokens": "Count Prompt Tokens",
"pluginDirectory": "Plugins Directory",
"textSelection": "Text Selection",
"webBrowser": "Web Browser",
"runAsSystemCommand": "Run as System Command",
"runAsPythonCommand": "Execute as Python Script",
"plugins": "Plugins",
"chatAfterFunctionCalled": "Chat with Function Response",
"runPythonScriptGlobally": "Run Python Script Globally",
"readTextFile": "Read Text File",
"customise": "Customise",
"donate": "Donate",
"about": "About",
}
12 changes: 12 additions & 0 deletions lang/language_en_US.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Perform a semantic search on bible text via GPT \n (OpenAI API key is required to run this feature.) \n e.g. slow to speak \n e.g. quote verses about God created the earth \n e.g. Jesus met Nicodemus \n e.g. similar verses to Genesis 1:1 in Hebrews \n e.g. write a summary on Exodus 13 \n e.g. compare Mark 1 and John 1",
"exportChat": "Export Chat",
"countPromptTokens": "Count Prompt Tokens",
"pluginDirectory": "Plugins Directory",
"textSelection": "Text Selection",
"webBrowser": "Web Browser",
"runAsSystemCommand": "Run as System Command",
"runAsPythonCommand": "Execute as Python Script",
"plugins": "Plugins",
"chatAfterFunctionCalled": "Chat with Function Response",
"runPythonScriptGlobally": "Run Python Script Globally",
"readTextFile": "Read Text File",
"customise": "Customise",
"donate": "Donate",
"about": "About",
}
12 changes: 12 additions & 0 deletions lang/language_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Realizar una búsqueda semántica en texto de biblia a través de GPT \n (la clave de API de OpenAI es necesaria para ejecutar esta característica). \n e.g. slow to speak \n e.g. citar versos sobre Dios creó la tierra \n por ejemplo, Jesús conoció a Nicodemo \n por ejemplo versos similares a Génesis 1: 1 en Hebreos \n por ejemplo, escribir un resumen en Éxodo 13 \n por ejemplo, comparar marca 1 y Juan 1",
"exportChat": "Conversación de exportación",
"countPromptTokens": "Señales de solicitud de recuento",
"pluginDirectory": "Directorio de plugins",
"textSelection": "Selección de texto",
"webBrowser": "Navegador Web",
"runAsSystemCommand": "Ejecutar como mandato del sistema",
"runAsPythonCommand": "Ejecutar como script de Python",
"plugins": "Plugins",
"chatAfterFunctionCalled": "Conversación con la respuesta de función",
"runPythonScriptGlobally": "Ejecutar script Python globalmente",
"readTextFile": "Archivo de texto de lectura",
"customise": "Customise",
"donate": "Donar",
"about": "Acerca de",
}
12 changes: 12 additions & 0 deletions lang/language_fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Effectuez une recherche sémantique sur le texte bible via GPT \n (la clé d'API OpenAI est requise pour exécuter cette fonction.) \n p. Ex. Lent à parler \n p. Ex., citation de versets sur Dieu a créé la terre, p. Ex. Jésus a rencontré Nicodemus \n p. Ex. Des versets similaires à la Genèse 1: 1 dans Hebrews \n, p. Ex. écrire un résumé sur Exode 13 \n par exemple, comparer les marques 1 et Jean 1",
"exportChat": "Exporter la discussion",
"countPromptTokens": "Nombre de jetons d'invite",
"pluginDirectory": "Répertoire des plug-ins",
"textSelection": "Sélection de texte",
"webBrowser": "Navigateur Web",
"runAsSystemCommand": "Exécuter en tant que commande système",
"runAsPythonCommand": "Exécuter en tant que script Python",
"plugins": "Plug-ins",
"chatAfterFunctionCalled": "Discuter avec une réponse de fonction",
"runPythonScriptGlobally": "Exécuter le script Python globalement",
"readTextFile": "Lire le fichier texte",
"customise": "Personnaliser",
"donate": "Donate",
"about": "A propos",
}
12 changes: 12 additions & 0 deletions lang/language_hi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "जीपीटी \n के माध्यम से बाईबल पाठ पर एक semantic खोज करें (OpenI API कुंजी इस सुविधा को चलाने के लिए आवश्यक है.) \n e.g. slow to speak \n e.g. quote verses about God created the earth \n e.g. Jesus met Nicodemus \n e.g. similar verses to Genesis 1:1 in Hebrews \n e.g. write a summary on Exodus 13 \n e.g. compare Mark 1 and John 1",
"exportChat": "चैट निर्यात करें",
"countPromptTokens": "संकेत संकेत गिनती",
"pluginDirectory": "प्लगइन्स डिरेक्ट्री",
"textSelection": "पाठ चयन",
"webBrowser": "वेब ब्राउज़र",
"runAsSystemCommand": "तंत्र कमांड के रूप में चलाएँ",
"runAsPythonCommand": "पायथन स्क्रिप्ट के रूप में चलाएँ",
"plugins": "प्लगइन्स",
"chatAfterFunctionCalled": "फंक्शन प्रतिक्रिया के साथ चैट करें",
"runPythonScriptGlobally": "Python स्क्रिप्ट वैश्विक स्तर पर चलाएँ",
"readTextFile": "पाठ फ़ाइल पढ़ें",
"customise": "अनुकूलन",
"donate": "दान",
"about": "लगभग",
}
12 changes: 12 additions & 0 deletions lang/language_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Eseguire una ricerca semantica sul testo bibbia tramite GPT \n (è necessaria la chiave API OpenAI per eseguire questa funzione.) \n ad esempio lento a parlare \n ad esempio, citare versi su Dio ha creato la terra \n e.g. Gesù ha incontrato Nicodemus \n e.g. versi simili a Genesis 1: 1 in Hebrews \n e.g. scrivere un riepilogo su Exodus 13 \n ad esempio confrontare Segnala 1 e Giovanni 1",
"exportChat": "Export Chat",
"countPromptTokens": "Conteggio Prompt Token",
"pluginDirectory": "Directory dei plugin",
"textSelection": "Selezione del testo",
"webBrowser": "Browser Web",
"runAsSystemCommand": "Esegui come Comando di sistema",
"runAsPythonCommand": "Eseguire come script Python",
"plugins": "Plugin",
"chatAfterFunctionCalled": "Conversazione con la risposta della funzione",
"runPythonScriptGlobally": "Run Python Script Globalmente",
"readTextFile": "File di testo di lettura",
"customise": "Personalizzazione",
"donate": "Donato",
"about": "Informazioni su",
}
12 changes: 12 additions & 0 deletions lang/language_ja.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "GPT \n ( この機能を実行するには、 OpenAI API キーを使用して、バイブル・テキストでセマンティック検索を実行します。 ) \n 例えば、例えば、神が地球を創造した例 : 例えば、イエスがニクデムスと出会った例 : 例えば、ヘブライ語での例 : 例えば、ヘブライ語での例 : 例えば、例えばマーク 1 と John 1 と比較して、例えば Exodus 13 \n の要約を記述する。",
"exportChat": "チャットのエクスポート",
"countPromptTokens": "カウント・プロンプト・トークン",
"pluginDirectory": "プラグイン・ディレクトリー",
"textSelection": "テキスト選択",
"webBrowser": "Web ブラウザー",
"runAsSystemCommand": "システム・コマンドとして実行",
"runAsPythonCommand": "Python スクリプトとして実行",
"plugins": "プラグイン",
"chatAfterFunctionCalled": "関数応答とチャット",
"runPythonScriptGlobally": "Python スクリプトのグローバル実行",
"readTextFile": "テキストファイルの読み込み",
"customise": "カスタマイズ",
"donate": "ドナーテ",
"about": "アバウト",
}
12 changes: 12 additions & 0 deletions lang/language_ko.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "GPT \n 을 통해 성경 텍스트에 대한 시맨틱 검색을 수행한다 (이 기능을 실행하려면 OpenAI API키가 필요하다.) \n 예를 들어, 하나님에 대한 인용 구절, 예를 들어, 지구를 창조한 신에 대한 인용 구절 (cn) 예를 들어, 예수는 예를 들어, 헤브러스 (Hebrews) 에서의 제네시스 1: 1과 같은 니오데우스 (Nicodemus) 를 만났다 (예를 들어, 출두스 (Exodus) 13에 대한 요약을 기입함).",
"exportChat": "채팅 내보내기",
"countPromptTokens": "카운트 프롬프트 토큰",
"pluginDirectory": "플루긴스 디렉토리",
"textSelection": "텍스트 선택",
"webBrowser": "웹 브라우저",
"runAsSystemCommand": "시스템 명령으로 실행 명령",
"runAsPythonCommand": "Python 스크립트로 실행하기",
"plugins": "명왕성",
"chatAfterFunctionCalled": "기능 응답과 대화",
"runPythonScriptGlobally": "Python 스크립트를 글로벌로 실행",
"readTextFile": "텍스트 파일 읽기",
"customise": "사용자 정의",
"donate": "기부하다",
"about": "정보",
}
12 changes: 12 additions & 0 deletions lang/language_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "ജിപിT \n വഴി ബൈബിള് ടെക്സ്റ്റില് ഒരു സെമന്റിക് തെരച്ചില് പെര്ഫോം ചെയ്യുക (OpenAI API കീ ഈ സവിശേഷത പ്രവര്ത്തിപ്പിക്കാന് ആവശ്യമാണ്) ഉദാ: ദൈവത്തെക്കുറിച്ച് സംസാരിക്കാൻ പതുക്കെ, ദൈവത്തെപ്പറ്റി ഉദ്ധരിച്ചതിന്റെ ഉദ്ധരണം: ദൈവം സൃഷ്ടിക്കപ്പെട്ടത് ഉദാ: യേശു നിക്കോഡീമസിനെ കണ്ടുമുട്ടി ഉദാ. ഉദാ:",
"exportChat": "ചട്ടക്കൂട് പുറത്തുവയ്ക്കുക",
"countPromptTokens": "à '- à', à ', à', à ', à', à ',",
"pluginDirectory": "പ്ലഗിനുകള് ഡയറക്ടറി",
"textSelection": "പദാവലി തെരഞ്ഞെടുക്കുക",
"webBrowser": "വെബ് ബ്രൌസര്Name",
"runAsSystemCommand": "സിസ്റ്റം കമാന്ഡ് ആയി പ്രവര്ത്തിപ്പിക്കുക",
"runAsPythonCommand": "പൈത്തണ് സ്ക്രിപ്റ്റ് ആയി പ്രദര്ശിപ്പിക്കുക",
"plugins": "പ്ലഗിനുകള്",
"chatAfterFunctionCalled": "ഫംഗ്ഷന് പ്രതികരണം",
"runPythonScriptGlobally": "പൈത്തണ് സ്ക്രിപ്റ്റ് Globally പ്രവര്ത്തിപ്പിക്കുക",
"readTextFile": "പദാവലി ഫയല് വായിയ്ക്കുക",
"customise": "കസ്റ്റംസ്",
"donate": "ഡോണെറ്റ്",
"about": "ഏകദേശം",
}
12 changes: 12 additions & 0 deletions lang/language_ro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,16 @@
"searchRB7": "Efectuați o căutare semantică pe text biblic prin GPT \n (OpenAI cheie API este necesar pentru a rula această caracteristică.) De exemplu, lent pentru a vorbi \n de exemplu, citat versete despre Dumnezeu a creat pământul \n de exemplu, Isus sa întâlnit Nicodim \n de exemplu, versete similare cu Geneza 1: 1 în Evrei \n de exemplu, scrie un rezumat pe Exod 13 \n de exemplu, compara Mark 1 și Ioan 1",
"exportChat": "Export Chat",
"countPromptTokens": "Numărați jetoanele prompte",
"pluginDirectory": "Director de pluginuri",
"textSelection": "Selectare text",
"webBrowser": "Navigator web",
"runAsSystemCommand": "Rulați ca sistem de comandă",
"runAsPythonCommand": "Execută ca Python Script",
"plugins": "Pluginuri",
"chatAfterFunctionCalled": "Discutați cu funcția Răspuns",
"runPythonScriptGlobally": "Rulează Python Script la nivel global",
"readTextFile": "Citește fișier text",
"customise": "Personalizează",
"donate": "Donează",
"about": "Despre",
}
Loading

0 comments on commit 2223468

Please sign in to comment.