commit
34eeeaddc4
61 changed files with 2886 additions and 1391 deletions
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
|
@ -56,7 +56,7 @@ body:
|
|||
- ChatGPT Web Interface
|
||||
- OpenAI ChatGPT API
|
||||
- Google Gemini API
|
||||
- Anthropic API
|
||||
- Claude API
|
||||
- Ollama API
|
||||
- OpenAI Compatible API
|
||||
- type: markdown
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ name: pre-release comment issues
|
|||
on:
|
||||
release:
|
||||
types: [published, edited]
|
||||
# opzionale: test manuale
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
|
@ -50,8 +48,7 @@ jobs:
|
|||
|
||||
const milestoneTitle = parsed.milestoneTitle; // es. "3.7.0"
|
||||
const prereleaseTagDisplay = tagName.startsWith("v") ? tagName : `v${tagName}`;
|
||||
const commentBody = `This feature could be tested in pre-release ${prereleaseTagDisplay}.`;
|
||||
|
||||
const commentBody = `This feature is available for testing in the pre-release version [${prereleaseTagDisplay}](https://github.com/micz/ThunderAI/releases).`;
|
||||
core.info(`(MAIN) Looking for milestone '${milestoneTitle}' in ${owner}/${repo}`);
|
||||
|
||||
// Find milestone (open or closed)
|
||||
|
|
|
|||
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -4,6 +4,18 @@
|
|||
|
||||
|
||||
|
||||
<h2>Version 3.7.0 - ??/??/2025</h2>
|
||||
<ul>
|
||||
<li><i>[All APIs]</i> It's now possibile to define a list of tags to be used when autotagging received emails [<a href="https://github.com/micz/ThunderAI/issues/436">#436</a>]. The tags are are now shown in the information header in the AI API chat [<a href="https://github.com/micz/ThunderAI/issues/289">#289</a>].</li>
|
||||
<li><i>[All APIs]</i> The prompt id and name are now shown in the information header in the AI API chat [<a href="https://github.com/micz/ThunderAI/issues/436">#436</a>].</li>
|
||||
<li>Added the <i>{%mail_attachments_info%}</i> placeholder to retrieve the name, type and file size of the mail attachments [<a href="https://github.com/micz/ThunderAI/issues/446">#446</a>].</li>
|
||||
<li><i>[Google Gemini API]</i>Support for the thinkingBudget parameter has been added [<a href="https://github.com/micz/ThunderAI/issues/494">#494</a>].</li>
|
||||
<li><i>[OpenAI Comp API]</i> Added DeepSeek configuration [<a href="https://github.com/micz/ThunderAI/issues/486">#486</a>].</li>
|
||||
<li><i>[ChatGPT Web]</i> Added a message to explain to click on "Force completion" if the ChatGPT job is not done after 7 seconds [<a href="https://github.com/micz/ThunderAI/issues/419">#419</a>].</li>
|
||||
<li>Anthropic API renamed to Claude API [<a href="https://github.com/micz/ThunderAI/issues/510">#510</a>].</li>
|
||||
<li>Various code improvements and minor bugs fixed.</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
<h2>Version 3.6.1 - 23/08/2025</h2>
|
||||
<ul>
|
||||
<li><i>[OpenAI Comp API]</i> Perplexity configuration fixed [<a href="https://github.com/micz/ThunderAI/issues/461">#461</a>].</li>
|
||||
|
|
|
|||
16
README.md
16
README.md
|
|
@ -31,8 +31,15 @@ Using an API integration, you can activate some automatic features:
|
|||
> <br>
|
||||
>
|
||||
> - **Google Gemini**
|
||||
> - You can use also the _System Instructions_ option if needed.
|
||||
> - You can use also the _System Instructions_ and _thinkingBudget_ options if needed.
|
||||
>
|
||||
>
|
||||
> <br>
|
||||
>
|
||||
> - **Claude API**
|
||||
> - You need to grant the permission "_Access your data for sites in the https://anthropic.com domain_" to use the Claude API.
|
||||
>
|
||||
>
|
||||
> <br>
|
||||
>
|
||||
> - **Using Ollama**
|
||||
|
|
@ -44,11 +51,6 @@ Using an API integration, you can activate some automatic features:
|
|||
> - **OpenAI Compatible API**
|
||||
> - You can also use a local OpenAI Compatible API server, like LM Studio or Mistral AI!
|
||||
> - There is also an option to remove the "v1" segment from the API url, if needed, and to manually set the model name if the server doesn't have a models list endpoint.
|
||||
>
|
||||
> <br>
|
||||
>
|
||||
> - **Anthropic API**
|
||||
> - Use Claude directly!
|
||||
|
||||
|
||||
|
||||
|
|
@ -102,6 +104,8 @@ _The language status represents the percentage of translated strings in the late
|
|||
- <a href="https://loading.io">loading.io</a> for the loading SVGs
|
||||
- [Fluent Design System](https://www.iconfinder.com/fluent-designsystem) for the Custom Prompts table sorting icons
|
||||
- [JessiGue](https://www.flaticon.com/authors/jessigue) for the show/hide icon for api key fields
|
||||
- [Iconka.com](https://www.iconarchive.com/artist/iconka.html) for the autotag context menu icon
|
||||
- [Icojam](https://www.iconarchive.com/artist/icojam.html) for the spam filter context menu icon
|
||||
|
||||
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Използвайте ChatGPT, Google Gemini, Anthropic или Ollama, за да подобрите вашите имейли!"
|
||||
"message": "Използвайте ChatGPT, Google Gemini, Claude или Ollama, за да подобрите вашите имейли!"
|
||||
},
|
||||
"menu_title": {
|
||||
"message": "ИИ"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
"message": "Přidat do nabídky"
|
||||
},
|
||||
"extensionDescription": {
|
||||
"message": "Použijte ChatGPT, Google Gemini, Anthropic nebo Ollama pro vylepšení vašich e-mailů!"
|
||||
"message": "Použijte ChatGPT, Google Gemini, Claude nebo Ollama pro vylepšení vašich e-mailů!"
|
||||
},
|
||||
"menu_title": {
|
||||
"message": "AI"
|
||||
|
|
@ -960,10 +960,10 @@
|
|||
"message": "Přidat novou úlohu"
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Klíč API Anthropic"
|
||||
"message": "Klíč API Claude"
|
||||
},
|
||||
"Anthropic_Version": {
|
||||
"message": "Verze API Anthropic"
|
||||
"message": "Verze API Claude"
|
||||
},
|
||||
"Anthropic_Version_Info": {
|
||||
"message": "POVINNÉ. Neměňte tuto hodnotu, pokud nevíte, co děláte. Více informací zde:"
|
||||
|
|
@ -1001,7 +1001,7 @@
|
|||
"message": "Tento zástupný symbol nepřidává žádný text, ale zabraňuje automatickému přidání těla emailu na konec výzvy."
|
||||
},
|
||||
"ask_anthropic_api_permission_1": {
|
||||
"message": "Pro používání integrace API Anthropic musíte udělit požadované oprávnění."
|
||||
"message": "Pro používání integrace API Claude musíte udělit požadované oprávnění."
|
||||
},
|
||||
"ask_integration_permission_2_popup": {
|
||||
"message": "Klikněte zde pro otevření nové karty a postupujte podle instrukcí."
|
||||
|
|
@ -1034,34 +1034,34 @@
|
|||
"message": "Pokud je v možnostech nebo v dotazu specifikován projekt, přepíše nastavení Vlastního GPT."
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "API Anthropic"
|
||||
"message": "API Claude"
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Modely Anthropic"
|
||||
"message": "Modely Claude"
|
||||
},
|
||||
"Anthropic_Models_Fetch": {
|
||||
"message": "Aktualizovat seznam modelů Anthropic"
|
||||
"message": "Aktualizovat seznam modelů Claude"
|
||||
},
|
||||
"Anthropic_Models_Error_fetching": {
|
||||
"message": "Chyba při pokusu o načtení modelů Anthropic"
|
||||
"message": "Chyba při pokusu o načtení modelů Claude"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Maximální počet tokenů Anthropic"
|
||||
"message": "Maximální počet tokenů Claude"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||
"message": "Maximální počet tokenů, které se mají vygenerovat v dokončení. Počet tokenů vaší výzvy plus max_tokens nesmí překročit délku kontextu modelu."
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "Nepřidali jste klíč API pro API Anthropic. Vložte jej prosím na stránce s možnostmi."
|
||||
"message": "Nepřidali jste klíč API pro API Claude. Vložte jej prosím na stránce s možnostmi."
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "Nevybírali jste model pro API Anthropic. Vyberte jej prosím na stránce s možnostmi."
|
||||
"message": "Nevybírali jste model pro API Claude. Vyberte jej prosím na stránce s možnostmi."
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "Nepřidali jste řetězec verze pro API Anthropic. Vložte jej prosím na stránce s možnostmi."
|
||||
"message": "Nepřidali jste řetězec verze pro API Claude. Vložte jej prosím na stránce s možnostmi."
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Selhal požadavek API Anthropic"
|
||||
"message": "Selhal požadavek API Claude"
|
||||
},
|
||||
"_api_connecting": {
|
||||
"message": "Pokus o připojení k $api_string$ s následující konfigurací...",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Verwenden Sie ChatGPT, Google Gemini, Anthropic oder Ollama, um Ihre E-Mails zu verbessern!",
|
||||
"message": "Verwenden Sie ChatGPT, Google Gemini, Claude oder Ollama, um Ihre E-Mails zu verbessern!",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
@ -760,7 +760,7 @@
|
|||
"message": "Wenn ausgewählt, wird die KI automatisch Tags zu neu empfangenen E-Mails hinzufügen."
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_only_inbox": {
|
||||
"message": "Tags nur zu E-Mails im Posteingang hinzufügen"
|
||||
"message": "Fügen Sie nur Tags zu E-Mails im Posteingang hinzu"
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_only_inbox_Info": {
|
||||
"message": "Wenn ausgewählt, wird die KI nur Tags zu E-Mails hinzufügen, die im Posteingangsordner empfangen wurden."
|
||||
|
|
@ -1072,22 +1072,22 @@
|
|||
"message": "Bitte korrigieren Sie die folgende E-Mail und beheben Sie alle Rechtschreib- oder Grammatikfehler. Antworten Sie nur mit dem korrigierten Text, ohne zusätzliche Kommentare oder sonstigen Text.\n\n„{%mail_typed_text%}“"
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "Anthropic API"
|
||||
"message": "Claude API"
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "Sie haben keinen Versionsstring für die Anthropic-API hinzugefügt. Bitte fügen Sie einen auf der Optionsseite ein."
|
||||
"message": "Sie haben keinen Versionsstring für die Claude-API hinzugefügt. Bitte fügen Sie einen auf der Optionsseite ein."
|
||||
},
|
||||
"Anthropic_Models_Error_fetching": {
|
||||
"message": "Fehler beim Abrufen der Anthropic-Modelle"
|
||||
"message": "Fehler beim Abrufen der Claude-Modelle"
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Anthropic API-Schlüssel"
|
||||
"message": "Claude API-Schlüssel"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||
"message": "Die maximale Anzahl von Tokens, die in der Vervollständigung generiert werden soll. Die Anzahl der Tokens Ihres Prompts plus max_tokens darf die Kontextlänge des Modells nicht überschreiten."
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Anfrage an die Anthropic-API fehlgeschlagen"
|
||||
"message": "Anfrage an die Claude-API fehlgeschlagen"
|
||||
},
|
||||
"_api_connecting": {
|
||||
"message": "Verbindungsversuch zu $api_string$ mit der folgenden Konfiguration...",
|
||||
|
|
@ -1098,28 +1098,28 @@
|
|||
}
|
||||
},
|
||||
"Anthropic_Models_Fetch": {
|
||||
"message": "Anthropic-Modellliste aktualisieren"
|
||||
"message": "Claude-Modellliste aktualisieren"
|
||||
},
|
||||
"Custom": {
|
||||
"message": "Benutzerdefiniert"
|
||||
},
|
||||
"Anthropic_Version": {
|
||||
"message": "Anthropic-API-Version"
|
||||
"message": "Claude-API-Version"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Maximale Anzahl an Tokens für Anthropic"
|
||||
"message": "Maximale Anzahl an Tokens für Claude"
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "Sie haben keinen API-Schlüssel für die Anthropic-API hinzugefügt. Bitte fügen Sie einen auf der Optionsseite ein."
|
||||
"message": "Sie haben keinen API-Schlüssel für die Claude-API hinzugefügt. Bitte fügen Sie einen auf der Optionsseite ein."
|
||||
},
|
||||
"ask_anthropic_api_permission_1": {
|
||||
"message": "Um die Anthropic-API-Integration zu verwenden, müssen Sie die erforderliche Berechtigung erteilen."
|
||||
"message": "Um die Claude-API-Integration zu verwenden, müssen Sie die erforderliche Berechtigung erteilen."
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Anthropic Modelle"
|
||||
"message": "Claude Modelle"
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "Sie haben kein Modell für die Anthropic-API ausgewählt. Bitte wählen Sie eines auf der Optionsseite aus."
|
||||
"message": "Sie haben kein Modell für die Claude-API ausgewählt. Bitte wählen Sie eines auf der Optionsseite aus."
|
||||
},
|
||||
"_api_connecting_model": {
|
||||
"message": "Modell",
|
||||
|
|
@ -1257,5 +1257,47 @@
|
|||
},
|
||||
"prefs_OpenAIComp_ClearModelsList": {
|
||||
"message": "Modellliste löschen"
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist": {
|
||||
"message": "Verwenden Sie nur diese Tags"
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_Info": {
|
||||
"message": "Wenn diese Option aktiviert ist, fügt die KI nur Tags aus der folgenden Liste hinzu."
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_list_Info": {
|
||||
"message": "Die Liste muss mindestens einen Tag enthalten. Fügen Sie pro Zeile einen Tag hinzu oder trennen Sie sie durch ein Komma."
|
||||
},
|
||||
"prompt_add_tags_use_list": {
|
||||
"message": "Verwenden Sie nur die Tags in dieser durch Kommas getrennten Liste"
|
||||
},
|
||||
"prefs_OptionText_add_tags_use_specific_integration_Info": {
|
||||
"message": "Wenn diese Option aktiviert ist, werden das unten angegebene Modell und die API zum Hinzufügen von Tags zu E-Mails verwendet, unabhängig von der in der ThunderAI-Optionsseite gewählten Einstellung."
|
||||
},
|
||||
"placeholder_mail_attachments_info": {
|
||||
"message": "Informationen zu den Anhängen in der E-Mail"
|
||||
},
|
||||
"prefs_OptionText_use_specific_integration": {
|
||||
"message": "Spezifisches Modell und API verwenden"
|
||||
},
|
||||
"prefs_OptionText_spamfilter_use_specific_integration_Info": {
|
||||
"message": "Wenn diese Option aktiviert ist, werden das unten angegebene Modell und die API für den Spamfilter verwendet, unabhängig von der in der ThunderAI-Optionsseite gewählten Einstellung."
|
||||
},
|
||||
"chatgpt_click_force_completion": {
|
||||
"message": "Es scheint nicht möglich zu sein festzustellen, ob ChatGPT fertig ist. Klicken Sie hier, um den Abschluss des Auftrags zu erzwingen."
|
||||
},
|
||||
"warn_API_needed": {
|
||||
"message": "Um diese Funktion zu nutzen, benötigen Sie eine API-Integration anstelle der ChatGPT-Webintegration. Sie können eine spezifische API auf der Einstellungsseite der Funktion definieren, indem Sie zuerst das obige Kontrollkästchen aktivieren und dann auf die Schaltfläche links klicken."
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget": {
|
||||
"message": "Thinking Budget"
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget_Info": {
|
||||
"message": "Legen Sie die Anzahl der Token fest, die für das Denken verwendet werden sollen. Lassen Sie dieses Feld leer, wenn das ausgewählte Modell Denken nicht unterstützt oder wenn Sie die Standardmethode verwenden möchten. Geben Sie 0 ein, um das Denken zu deaktivieren, oder -1, um dynamisches Denken zu aktivieren."
|
||||
},
|
||||
"SelectAll": {
|
||||
"message": "Alles auswählen"
|
||||
},
|
||||
"DeselectAll": {
|
||||
"message": "Alles abwählen"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Use ChatGPT, Google Gemini, Anthropic or Ollama to enhance your emails!",
|
||||
"message": "Use ChatGPT, Google Gemini, Claude or Ollama to enhance your emails!",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
@ -1127,14 +1127,34 @@
|
|||
"message": "If checked, the AI will add only existing tags and won't create new tags.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist": {
|
||||
"message": "Use only these tags",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_Info": {
|
||||
"message": "If checked, the AI will add only tags from the list below.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_list_Info": {
|
||||
"message": "The list must contain at least one tag. Add a tag per line, or separated by a comma.",
|
||||
"description": ""
|
||||
},
|
||||
"prompt_add_tags_use_list": {
|
||||
"message": "Use only the tags in this comma separated list",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_only_inbox": {
|
||||
"message": "Only add tags to inbox emails",
|
||||
"message": "Only add tags to emails in the inbox",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_only_inbox_Info": {
|
||||
"message": "If checked, the AI will only add tags to emails received in the inbox folder.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_add_tags_use_specific_integration_Info": {
|
||||
"message": "If checked, the Model and API specified below will be used for adding tags to emails, regardless the one choosen in the ThunderAI options page.",
|
||||
"description": ""
|
||||
},
|
||||
"placeholder_thunderai_def_sign": {
|
||||
"message": "Default signature as defined in ThunderAI options.",
|
||||
"description": ""
|
||||
|
|
@ -1143,6 +1163,10 @@
|
|||
"message": "Default language as defined in ThunderAI options.",
|
||||
"description": ""
|
||||
},
|
||||
"placeholder_mail_attachments_info": {
|
||||
"message": "Information about the attachments in the email",
|
||||
"description": ""
|
||||
},
|
||||
"empty": {
|
||||
"message": "This placeholder doesn't add any text, but it prevents the email body from being automatically appended at the end of the prompt.",
|
||||
"description": ""
|
||||
|
|
@ -1183,6 +1207,14 @@
|
|||
"message": "Spam Filter Options",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_use_specific_integration": {
|
||||
"message": "Use specific Model and API",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_spamfilter_use_specific_integration_Info": {
|
||||
"message": "If checked, the Model and API specified below will be used for the spam filter, regardless the one chosen in the ThunderAI options page.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_spamfilter_threshold": {
|
||||
"message": "Spam threshold",
|
||||
"description": ""
|
||||
|
|
@ -1352,7 +1384,7 @@
|
|||
"description": ""
|
||||
},
|
||||
"ask_anthropic_api_permission_1": {
|
||||
"message": "To use the Anthropic API integration, you need to grant the required permission.",
|
||||
"message": "To use the Claude API integration, you need to grant the required permission.",
|
||||
"description": ""
|
||||
},
|
||||
"ask_integration_permission_2_popup": {
|
||||
|
|
@ -1428,27 +1460,27 @@
|
|||
"description": ""
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Anthropic API Key",
|
||||
"message": "Claude API Key",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "Anthropic API",
|
||||
"message": "Claude API",
|
||||
"description": ""
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Anthropic Models",
|
||||
"message": "Claude Models",
|
||||
"description": ""
|
||||
},
|
||||
"Anthropic_Models_Fetch": {
|
||||
"message": "Update Anthropic Models list",
|
||||
"message": "Update Claude Models list",
|
||||
"description": ""
|
||||
},
|
||||
"Anthropic_Models_Error_fetching": {
|
||||
"message": "Error trying to fetch Anthropic models",
|
||||
"message": "Error trying to fetch Claude models",
|
||||
"description": ""
|
||||
},
|
||||
"Anthropic_Version": {
|
||||
"message": "Anthropic API Version",
|
||||
"message": "Claude API Version",
|
||||
"description": ""
|
||||
},
|
||||
"Anthropic_Version_Info": {
|
||||
|
|
@ -1456,7 +1488,7 @@
|
|||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Anthropic Max Tokens",
|
||||
"message": "Claude Max Tokens",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||
|
|
@ -1464,19 +1496,19 @@
|
|||
"description": ""
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "You've not added an API Key for the Anthropic API. Please insert one in the options page.",
|
||||
"message": "You've not added an API Key for the Claude API. Please insert one in the options page.",
|
||||
"description": ""
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "You've not chosen a model for the Anthropic API. Please choose one in the options page.",
|
||||
"message": "You've not chosen a model for the Claude API. Please choose one in the options page.",
|
||||
"description": ""
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "You've not added a version string for the Anthropic API. Please insert one in the options page.",
|
||||
"message": "You've not added a version string for the Claude API. Please insert one in the options page.",
|
||||
"description": ""
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Anthropic API request failed",
|
||||
"message": "Claude API request failed",
|
||||
"description": ""
|
||||
},
|
||||
"_api_connecting": {
|
||||
|
|
@ -1628,5 +1660,29 @@
|
|||
"OpenAIComp_ClearModelsList_Confirm": {
|
||||
"message": "Are you sure you want to clear the Models List? This action cannot be undone.",
|
||||
"description": ""
|
||||
},
|
||||
"chatgpt_click_force_completion": {
|
||||
"message": "It seems that it's not possible to get if ChatGPT has finished. Click here to force the completion of the job.",
|
||||
"description": ""
|
||||
},
|
||||
"warn_API_needed": {
|
||||
"message": "To use this feature, you need an API integration rather than the ChatGPT Web Integration. You can define a specific API in the feature settings page by first checking the checkbox above and then clicking the button on the left.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget": {
|
||||
"message": "Thinking Budget",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget_Info": {
|
||||
"message": "Define the number of tokens to be used for thinking. Leave this field blank if the selected model does not support thinking or if you want to use the default method. Enter 0 to disable thinking, or -1 to enable dynamic thinking.",
|
||||
"description": ""
|
||||
},
|
||||
"SelectAll": {
|
||||
"message": "Select All",
|
||||
"description": ""
|
||||
},
|
||||
"DeselectAll": {
|
||||
"message": "Deselect All",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
"message": "Respondi per"
|
||||
},
|
||||
"extensionDescription": {
|
||||
"message": "Uzu ChatGPT, Google Gemini, Anthropic aŭ Ollama por poluri viajn retpoŝtajn mesaĝojn!"
|
||||
"message": "Uzu ChatGPT, Google Gemini, Claude aŭ Ollama por poluri viajn retpoŝtajn mesaĝojn!"
|
||||
},
|
||||
"prompt_rewrite_formal": {
|
||||
"message": "Reverki formale"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "¡Usa ChatGPT, Google Gemini, Anthropic u Ollama para mejorar tus emails!"
|
||||
"message": "¡Usa ChatGPT, Google Gemini, Claude u Ollama para mejorar tus emails!"
|
||||
},
|
||||
"menu_title": {
|
||||
"message": "IA"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Utilise ChatGPT, Goolge Gemini, Anthropic ou Ollama pour améliorer tes e-mails !",
|
||||
"message": "Utilise ChatGPT, Goolge Gemini, Claude ou Ollama pour améliorer tes e-mails !",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
@ -778,7 +778,7 @@
|
|||
"message": "Ajouter des tags automatiquement"
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_only_inbox": {
|
||||
"message": "Ajouter des tags uniquement aux e-mails de la boîte de réception"
|
||||
"message": "Ajoutez des balises uniquement aux e-mails de la boîte de réception"
|
||||
},
|
||||
"prefs_OptionText_spamfilter_threshold": {
|
||||
"message": "Seuil de spam"
|
||||
|
|
@ -1080,34 +1080,34 @@
|
|||
}
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "Vous n'avez pas choisi de modèle pour l'API Anthropic. Veuillez en sélectionner un dans la page des options."
|
||||
"message": "Vous n'avez pas choisi de modèle pour l'API Claude. Veuillez en sélectionner un dans la page des options."
|
||||
},
|
||||
"Anthropic_Version_Info": {
|
||||
"message": "OBLIGATOIRE. Ne modifiez pas cette valeur sauf si vous savez ce que vous faites. Plus d'informations sur :"
|
||||
},
|
||||
"ask_anthropic_api_permission_1": {
|
||||
"message": "Pour utiliser l'intégration de l'API Anthropic, vous devez accorder l'autorisation requise."
|
||||
"message": "Pour utiliser l'intégration de l'API Claude, vous devez accorder l'autorisation requise."
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||
"message": "Le nombre maximum de jetons à générer dans la complétion. Le total des jetons de votre invite plus max_tokens ne peut pas dépasser la longueur du contexte du modèle."
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "Vous n'avez pas ajouté de clé API pour l'API Anthropic. Veuillez en insérer une dans la page des options."
|
||||
"message": "Vous n'avez pas ajouté de clé API pour l'API Claude. Veuillez en insérer une dans la page des options."
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "Vous n'avez pas ajouté de chaîne de version pour l'API Anthropic. Veuillez en insérer une dans la page des options."
|
||||
"message": "Vous n'avez pas ajouté de chaîne de version pour l'API Claude. Veuillez en insérer une dans la page des options."
|
||||
},
|
||||
"apiwebchat_selection_info": {
|
||||
"message": "Si vous sélectionnez du texte, seule cette portion sera prise en compte."
|
||||
},
|
||||
"Anthropic_Version": {
|
||||
"message": "Version de l’API Anthropic"
|
||||
"message": "Version de l’API Claude"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Nombre maximum de jetons Anthropic"
|
||||
"message": "Nombre maximum de jetons Claude"
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Échec de la requête à l'API Anthropic"
|
||||
"message": "Échec de la requête à l'API Claude"
|
||||
},
|
||||
"prefs_OpenAIComp_AvailableServices": {
|
||||
"message": "Services Disponibles"
|
||||
|
|
@ -1124,19 +1124,19 @@
|
|||
}
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Clé API Anthropic"
|
||||
"message": "Clé API Claude"
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "API Anthropic"
|
||||
"message": "API Claude"
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Modèles Anthropic"
|
||||
"message": "Modèles Claude"
|
||||
},
|
||||
"Anthropic_Models_Fetch": {
|
||||
"message": "Mettre à jour la liste des modèles Anthropic"
|
||||
"message": "Mettre à jour la liste des modèles Claude"
|
||||
},
|
||||
"Anthropic_Models_Error_fetching": {
|
||||
"message": "Erreur lors de la tentative de récupération des modèles Anthropic"
|
||||
"message": "Erreur lors de la tentative de récupération des modèles Claude"
|
||||
},
|
||||
"_api_connecting_model": {
|
||||
"message": "Modèle",
|
||||
|
|
@ -1257,5 +1257,47 @@
|
|||
},
|
||||
"OpenAIComp_ClearModelsList_Confirm": {
|
||||
"message": "Êtes-vous sûr de vouloir effacer la liste des modèles ? Cette action est irréversible."
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist": {
|
||||
"message": "Utilisez uniquement ces balises"
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_Info": {
|
||||
"message": "Si cette option est cochée, l’IA ajoutera uniquement des balises de la liste ci-dessous."
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_list_Info": {
|
||||
"message": "La liste doit contenir au moins une balise. Ajoutez une balise par ligne ou séparée par une virgule."
|
||||
},
|
||||
"prompt_add_tags_use_list": {
|
||||
"message": "Utilisez uniquement les balises de cette liste séparée par des virgules"
|
||||
},
|
||||
"prefs_OptionText_add_tags_use_specific_integration_Info": {
|
||||
"message": "Si cette option est cochée, le Modèle et l’API spécifiés ci-dessous seront utilisés pour ajouter des balises aux e-mails, quel que soit celui choisi dans la page des options de ThunderAI."
|
||||
},
|
||||
"placeholder_mail_attachments_info": {
|
||||
"message": "Informations sur les pièces jointes dans l’e-mail"
|
||||
},
|
||||
"prefs_OptionText_use_specific_integration": {
|
||||
"message": "Utiliser un Modèle et une API spécifiques"
|
||||
},
|
||||
"prefs_OptionText_spamfilter_use_specific_integration_Info": {
|
||||
"message": "Si cette option est cochée, le Modèle et l’API spécifiés ci-dessous seront utilisés pour le filtre anti-spam, quel que soit celui choisi dans la page des options de ThunderAI."
|
||||
},
|
||||
"chatgpt_click_force_completion": {
|
||||
"message": "Il semble qu’il ne soit pas possible de savoir si ChatGPT a terminé. Cliquez ici pour forcer l’achèvement du travail."
|
||||
},
|
||||
"warn_API_needed": {
|
||||
"message": "Pour utiliser cette fonctionnalité, vous avez besoin d’une intégration API plutôt que de l’intégration Web de ChatGPT. Vous pouvez définir une API spécifique dans la page des paramètres de la fonctionnalité en cochant d’abord la case ci-dessus, puis en cliquant sur le bouton à gauche."
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget_Info": {
|
||||
"message": "Définissez le nombre de jetons à utiliser pour le raisonnement. Laissez ce champ vide si le modèle sélectionné ne prend pas en charge le raisonnement ou si vous souhaitez utiliser la méthode par défaut. Entrez 0 pour désactiver le raisonnement, ou -1 pour l’activer de manière dynamique."
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget": {
|
||||
"message": "Thinking Budget"
|
||||
},
|
||||
"SelectAll": {
|
||||
"message": "Tout sélectionner"
|
||||
},
|
||||
"DeselectAll": {
|
||||
"message": "Tout désélectionner"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Koristite ChatGPT, Google Gemini, Anthropic ili Ollama kako bi poboljšali vaše e-poruke!",
|
||||
"message": "Koristite ChatGPT, Google Gemini, Claude ili Ollama kako bi poboljšali vaše e-poruke!",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Használja a ChatGPT, Google Gemini, Anthropic vagy Ollama modelleket, hogy még jobbá tegye emailjeit!"
|
||||
"message": "Használja a ChatGPT, Google Gemini, Claude vagy Ollama modelleket, hogy még jobbá tegye emailjeit!"
|
||||
},
|
||||
"menu_title": {
|
||||
"message": "MI"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Usa ChatGPT, Google Gemini, Anthropic oppure Ollama per migliorare le tue email!",
|
||||
"message": "Usa ChatGPT, Google Gemini, Claude oppure Ollama per migliorare le tue email!",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
@ -1078,46 +1078,46 @@
|
|||
"message": "HTML selezionato"
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "API Anthropic"
|
||||
"message": "API Claude"
|
||||
},
|
||||
"ask_anthropic_api_permission_1": {
|
||||
"message": "Per utilizzare l'integrazione con l'API di Anthropic, è necessario concedere l'autorizzazione richiesta."
|
||||
"message": "Per utilizzare l'integrazione con l'API di Claude, è necessario concedere l'autorizzazione richiesta."
|
||||
},
|
||||
"Anthropic_Version_Info": {
|
||||
"message": "OBBLIGATORIO. Non modificare questo valore a meno che tu non sappia esattamente cosa stai facendo. Maggiori informazioni su:"
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Modelli di Anthropic"
|
||||
"message": "Modelli di Claude"
|
||||
},
|
||||
"Anthropic_Models_Fetch": {
|
||||
"message": "Aggiorna l'elenco dei modelli di Anthropic"
|
||||
"message": "Aggiorna l'elenco dei modelli di Claude"
|
||||
},
|
||||
"Anthropic_Models_Error_fetching": {
|
||||
"message": "Errore durante il tentativo di recupero dei modelli di Anthropic"
|
||||
"message": "Errore durante il tentativo di recupero dei modelli di Claude"
|
||||
},
|
||||
"Anthropic_Version": {
|
||||
"message": "Versione API di Anthropic"
|
||||
"message": "Versione API di Claude"
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Chiave API di Anthropic"
|
||||
"message": "Chiave API di Claude"
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "Non hai selezionato un modello per l'API di Anthropic. Scegline uno nella pagina delle opzioni."
|
||||
"message": "Non hai selezionato un modello per l'API di Claude. Scegline uno nella pagina delle opzioni."
|
||||
},
|
||||
"prefs_OpenAIComp_AvailableServices_Info": {
|
||||
"message": "Scegli uno dei servizi disponibili per l'API compatibile con OpenAI oppure inseriscine uno manualmente."
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Numero massimo di token di Anthropic"
|
||||
"message": "Numero massimo di token di Claude"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||
"message": "Il numero massimo di token da generare nell'elaborazione. Il conteggio dei token del tuo prompt, sommato a max_tokens, non può superare la lunghezza di contesto del modello."
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "Non hai aggiunto una chiave per l'API di Anthropic. Inseriscila nella pagina delle opzioni."
|
||||
"message": "Non hai aggiunto una chiave per l'API di Claude. Inseriscila nella pagina delle opzioni."
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "Non hai aggiunto la versione per l'API di Anthropic. Inseriscila nella pagina delle opzioni."
|
||||
"message": "Non hai aggiunto la versione per l'API di Claude. Inseriscila nella pagina delle opzioni."
|
||||
},
|
||||
"_api_connecting": {
|
||||
"message": "Tentativo di connessione a $api_string$ utilizzando la seguente configurazione...",
|
||||
|
|
@ -1169,7 +1169,7 @@
|
|||
}
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Richiesta all'API di Anthropic non riuscita"
|
||||
"message": "Richiesta all'API di Claude non riuscita"
|
||||
},
|
||||
"prefs_OptionText_reply_type_Info": {
|
||||
"message": "Questa è la modalità di risposta predefinita che verrà utilizzata quando rispondi a un'email. Puoi scegliere l'altra modalità nella finestra di risposta."
|
||||
|
|
@ -1260,5 +1260,47 @@
|
|||
},
|
||||
"OpenAIComp_ClearModelsList_Confirm": {
|
||||
"message": "Sei sicuro di voler cancellare l’elenco dei modelli? Questa azione non può essere annullata."
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist": {
|
||||
"message": "Usa solo questi tag"
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_Info": {
|
||||
"message": "Se selezionato, l'IA aggiungerà solo i tag dall'elenco qui sotto."
|
||||
},
|
||||
"prefs_OptionText_add_tags_auto_uselist_list_Info": {
|
||||
"message": "L’elenco deve contenere almeno un tag. Aggiungi un tag per riga o separato da una virgola."
|
||||
},
|
||||
"prompt_add_tags_use_list": {
|
||||
"message": "Usa solo i tag in questo elenco separato da virgole"
|
||||
},
|
||||
"prefs_OptionText_add_tags_use_specific_integration_Info": {
|
||||
"message": "Se selezionato, il Modello e l’API specificati qui sotto verranno utilizzati per aggiungere tag alle email, indipendentemente da quello scelto nella pagina delle opzioni di ThunderAI."
|
||||
},
|
||||
"placeholder_mail_attachments_info": {
|
||||
"message": "Informazioni sugli allegati nell’email"
|
||||
},
|
||||
"prefs_OptionText_use_specific_integration": {
|
||||
"message": "Usa Modello e API specifici"
|
||||
},
|
||||
"prefs_OptionText_spamfilter_use_specific_integration_Info": {
|
||||
"message": "Se selezionato, il Modello e l’API specificati qui sotto verranno utilizzati per il filtro antispam, indipendentemente da quello scelto nella pagina delle opzioni di ThunderAI."
|
||||
},
|
||||
"chatgpt_click_force_completion": {
|
||||
"message": "Sembra che non sia possibile verificare se ChatGPT ha terminato. Clicca qui per forzare il completamento del lavoro."
|
||||
},
|
||||
"warn_API_needed": {
|
||||
"message": "Per utilizzare questa funzionalità, è necessaria un’integrazione API invece dell’integrazione Web di ChatGPT. Puoi definire una specifica API nella pagina delle impostazioni della funzionalità selezionando prima la casella di controllo qui sopra e poi cliccando il pulsante a sinistra."
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget": {
|
||||
"message": "Thinking Budget"
|
||||
},
|
||||
"prefs_google_gemini_thinking_budget_Info": {
|
||||
"message": "Definisci il numero di token da utilizzare per il ragionamento. Lascia questo campo vuoto se il modello selezionato non supporta il ragionamento o se desideri utilizzare il metodo predefinito. Inserisci 0 per disabilitare il ragionamento oppure -1 per abilitarlo in modo dinamico."
|
||||
},
|
||||
"SelectAll": {
|
||||
"message": "Seleziona tutto"
|
||||
},
|
||||
"DeselectAll": {
|
||||
"message": "Deseleziona tutto"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Używaj ChatGPT, Goolge Gemini, Anthropic lub Ollama do ulepszania swoich e-maili!",
|
||||
"message": "Używaj ChatGPT, Goolge Gemini, Claude lub Ollama do ulepszania swoich e-maili!",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Use o ChatGPT, Goolge Gemini, Anthropic ou o Ollama para aprimorar seus e-mails!",
|
||||
"message": "Use o ChatGPT, Goolge Gemini, Claude ou o Ollama para aprimorar seus e-mails!",
|
||||
"description": "Description of the extension."
|
||||
},
|
||||
"menu_title": {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@
|
|||
"message": "Se estiver tudo certo, depois de importar carrega no botão \"Guardar Tudo\"."
|
||||
},
|
||||
"extensionDescription": {
|
||||
"message": "Usa o ChatGPT, Google Gemini, Anthropic ou Ollama para melhorar os teus emails!"
|
||||
"message": "Usa o ChatGPT, Google Gemini, Claude ou Ollama para melhorar os teus emails!"
|
||||
},
|
||||
"customPrompts_form_label_Name": {
|
||||
"message": "Nome"
|
||||
|
|
|
|||
|
|
@ -1065,10 +1065,10 @@
|
|||
"message": "Если в опциях или в подсказке указан Проект, временный чат не будет использоваться."
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Ключ API Anthropic"
|
||||
"message": "Ключ API Claude"
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "Антропный(Anthropic) API"
|
||||
"message": "Антропный(Claude) API"
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Антропологические модели"
|
||||
|
|
@ -1086,22 +1086,22 @@
|
|||
"message": "ОБЯЗАТЕЛЬНО. Не изменяйте это значение, если не знаете, что делаете. Доп. информация на сайте:"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Anthropic максимум токенов"
|
||||
"message": "Claude максимум токенов"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens_Info": {
|
||||
"message": "Максимальное кол-во токенов, генерируемых в процессе завершения. Кол-во токенов в подсказке плюс max_tokens не может превышать длину контекста модели."
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "Вы не добавили ключ API для API Anthropic. Пожалуйста, введите его на странице параметров."
|
||||
"message": "Вы не добавили ключ API для API Claude. Пожалуйста, введите его на странице параметров."
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "Вы не выбрали модель для Anthropic API. Пожалуйста, выберите ее на странице параметров."
|
||||
"message": "Вы не выбрали модель для Claude API. Пожалуйста, выберите ее на странице параметров."
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "Вы не добавили строку версии для API Anthropic. Пожалуйста, вставьте ее на странице параметров."
|
||||
"message": "Вы не добавили строку версии для API Claude. Пожалуйста, вставьте ее на странице параметров."
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Anthropic API-запрос не удался"
|
||||
"message": "Claude API-запрос не удался"
|
||||
},
|
||||
"_api_connecting": {
|
||||
"message": "Попытка подключения к $api_string$ с использованием следующей конфигурации...",
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
"message": "保存所有变动"
|
||||
},
|
||||
"extensionDescription": {
|
||||
"message": "使用 ChatGPT、Google Gemini、Anthropic 或 Ollama 来提升你的电子邮件!"
|
||||
"message": "使用 ChatGPT、Google Gemini、Claude 或 Ollama 来提升你的电子邮件!"
|
||||
},
|
||||
"menu_title": {
|
||||
"message": "AI"
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@
|
|||
"message": "額外屬性"
|
||||
},
|
||||
"Anthropic_Models": {
|
||||
"message": "Anthropic 模型"
|
||||
"message": "Claude 模型"
|
||||
},
|
||||
"_api_connecting_model": {
|
||||
"message": "模型",
|
||||
|
|
@ -317,7 +317,7 @@
|
|||
"message": "啟用思考"
|
||||
},
|
||||
"extensionDescription": {
|
||||
"message": "使用 ChatGPT、Google Gemini、Anthropic 或 Ollama 來幫你寫好你的郵件吧!"
|
||||
"message": "使用 ChatGPT、Google Gemini、Claude 或 Ollama 來幫你寫好你的郵件吧!"
|
||||
},
|
||||
"customPrompts_form_label_Name": {
|
||||
"message": "名稱"
|
||||
|
|
@ -394,7 +394,7 @@
|
|||
"message": "自訂"
|
||||
},
|
||||
"prefs_Connection_type_Anthropic_API": {
|
||||
"message": "Anthropic API"
|
||||
"message": "Claude API"
|
||||
},
|
||||
"save": {
|
||||
"message": "儲存"
|
||||
|
|
@ -645,13 +645,13 @@
|
|||
"message": "這是將針對 ChatGPT 網頁介面強制執行的專案。"
|
||||
},
|
||||
"Anthropic_Models_Fetch": {
|
||||
"message": "更新 Anthropic 模型列表"
|
||||
"message": "更新 Claude 模型列表"
|
||||
},
|
||||
"prefs_Anthropic_API_Key": {
|
||||
"message": "Anthropic API 金鑰"
|
||||
"message": "Claude API 金鑰"
|
||||
},
|
||||
"anthropic_api_request_failed": {
|
||||
"message": "Anthropic API 請求失敗"
|
||||
"message": "Claude API 請求失敗"
|
||||
},
|
||||
"OpenAIComp_Configs_ConfirmApply": {
|
||||
"message": "您確定要套用設定「$config_name$」嗎?",
|
||||
|
|
@ -815,7 +815,7 @@
|
|||
"message": "點擊此處開啟新分頁並按照說明進行操作。"
|
||||
},
|
||||
"ask_anthropic_api_permission_1": {
|
||||
"message": "要使用 Anthropic API 整合,您需要授予所需的權限。"
|
||||
"message": "要使用 Claude API 整合,您需要授予所需的權限。"
|
||||
},
|
||||
"ask_integration_permission_ok": {
|
||||
"message": "已授予權限。您可以按一下此處關閉此分頁並返回主視窗。"
|
||||
|
|
@ -845,7 +845,7 @@
|
|||
"message": "如果在選項或提示中指定了專案,則不會使用臨時聊天。"
|
||||
},
|
||||
"Anthropic_Models_Error_fetching": {
|
||||
"message": "嘗試取得 Anthropic 模型時出錯"
|
||||
"message": "嘗試取得 Claude 模型時出錯"
|
||||
},
|
||||
"_api_connecting": {
|
||||
"message": "嘗試使用以下配置連接到 $api_string$...",
|
||||
|
|
@ -856,10 +856,10 @@
|
|||
}
|
||||
},
|
||||
"anthropic_empty_model": {
|
||||
"message": "您尚未選擇 Anthropic API 的模型。請在選項頁面中選擇一個。"
|
||||
"message": "您尚未選擇 Claude API 的模型。請在選項頁面中選擇一個。"
|
||||
},
|
||||
"anthropic_empty_version": {
|
||||
"message": "您尚未新增 Anthropic API 的版本字串。請在選項頁面中輸入一個。"
|
||||
"message": "您尚未新增 Claude API 的版本字串。請在選項頁面中輸入一個。"
|
||||
},
|
||||
"ChatGPT_chatgpt_api_store_info": {
|
||||
"message": "如果勾選,您的聊天記錄將由 OpenAI 儲存。"
|
||||
|
|
@ -916,7 +916,7 @@
|
|||
"message": "自動新增標籤"
|
||||
},
|
||||
"anthropic_empty_apikey": {
|
||||
"message": "您尚未新增 Anthropic API 的 API 金鑰。請在選項頁面中輸入一個。"
|
||||
"message": "您尚未新增 Claude API 的 API 金鑰。請在選項頁面中輸入一個。"
|
||||
},
|
||||
"prefs_OpenAIComp_ForceModel": {
|
||||
"message": "手動輸入模型"
|
||||
|
|
@ -928,7 +928,7 @@
|
|||
"message": "管理任務設定"
|
||||
},
|
||||
"Anthropic_Version": {
|
||||
"message": "Anthropic API 版本"
|
||||
"message": "Claude API 版本"
|
||||
},
|
||||
"prefs_OptionText_spamfilter": {
|
||||
"message": "自動垃圾郵件過濾器"
|
||||
|
|
@ -937,7 +937,7 @@
|
|||
"message": "已移到垃圾郵件"
|
||||
},
|
||||
"prefs_OptionText_anthropic_max_tokens": {
|
||||
"message": "Anthropic 最大 Token 數"
|
||||
"message": "Claude 最大 Token 數"
|
||||
},
|
||||
"prefs_OpenAIComp_API_Key": {
|
||||
"message": "OpenAI 相容 API 金鑰"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
* The original code has been released under the Apache License, Version 2.0.
|
||||
*/
|
||||
|
||||
import { prefs_default } from '../options/mzta-options-default.js';
|
||||
import { placeholdersUtils } from '../js/mzta-placeholders.js';
|
||||
import { getAPIsInitMessageString, convertNewlinesToBr } from '../js/mzta-utils.js';
|
||||
|
||||
|
|
@ -28,6 +29,8 @@ const urlParams = new URLSearchParams(window.location.search);
|
|||
const llm = urlParams.get('llm');
|
||||
const call_id = urlParams.get('call_id');
|
||||
const ph_def_val = urlParams.get('ph_def_val');
|
||||
const prompt_id = urlParams.get('prompt_id');
|
||||
const prompt_name = urlParams.get('prompt_name');
|
||||
|
||||
// Data received from the user
|
||||
let promptData = null;
|
||||
|
|
@ -73,24 +76,52 @@ messageInput.setMessagesArea(messagesArea);
|
|||
|
||||
switch (llm) {
|
||||
case "chatgpt_api": {
|
||||
let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', chatgpt_developer_messages:'', chatgpt_api_store: false, do_debug: false});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
chatgpt_api_key: prefs_default.chatgpt_api_key,
|
||||
chatgpt_model: prefs_default.chatgpt_model,
|
||||
chatgpt_developer_messages: prefs_default.chatgpt_developer_messages,
|
||||
chatgpt_api_store: prefs_default.chatgpt_api_store,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["chatgpt_api_request_failed"] = browser.i18n.getMessage('chatgpt_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
messageInput.setModel(prefs_api.chatgpt_model);
|
||||
messagesArea.setLLMName("ChatGPT");
|
||||
worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model, chatgpt_developer_messages: prefs_api.chatgpt_developer_messages, chatgpt_api_store: prefs_api.chatgpt_api_store, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
worker.postMessage({
|
||||
type: 'init',
|
||||
chatgpt_api_key: prefs_api.chatgpt_api_key,
|
||||
chatgpt_model: prefs_api.chatgpt_model,
|
||||
chatgpt_developer_messages: prefs_api.chatgpt_developer_messages,
|
||||
chatgpt_api_store: prefs_api.chatgpt_api_store,
|
||||
do_debug: prefs_api.do_debug,
|
||||
i18nStrings: i18nStrings,
|
||||
});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: 'OpenAI Store', value: (prefs_api.chatgpt_api_store ? 'Yes' : 'No')});
|
||||
if(prefs_api.chatgpt_developer_messages && prefs_api.chatgpt_developer_messages.length > 0) {
|
||||
additional_text_elements.push({label: browser.i18n.getMessage("ChatGPT_Developer_Messages"), value: prefs_api.chatgpt_developer_messages});
|
||||
}
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString("ChatGPT API", prefs_api.chatgpt_model, '', '', additional_text_elements), "info");
|
||||
browser.runtime.sendMessage({command: "openai_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "ChatGPT API",
|
||||
model_string: prefs_api.chatgpt_model,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
browser.runtime.sendMessage({
|
||||
command: "openai_api_ready_" + call_id,
|
||||
window_id: (await browser.windows.getCurrent()).id
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "google_gemini_api": {
|
||||
let prefs_api = await browser.storage.sync.get({google_gemini_api_key: '', google_gemini_model: '', google_gemini_system_instruction: '', do_debug: false});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
google_gemini_api_key: prefs_default.google_gemini_api_key,
|
||||
google_gemini_model: prefs_default.google_gemini_model,
|
||||
google_gemini_system_instruction: prefs_default.google_gemini_system_instruction,
|
||||
google_gemini_thinking_budget: prefs_default.google_gemini_thinking_budget,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["google_gemini_api_request_failed"] = browser.i18n.getMessage('google_gemini_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
|
|
@ -100,45 +131,135 @@ switch (llm) {
|
|||
if(prefs_api.google_gemini_system_instruction && prefs_api.google_gemini_system_instruction.length > 0) {
|
||||
additional_text_elements.push({label: browser.i18n.getMessage("GoogleGemini_SystemInstruction"), value: prefs_api.google_gemini_system_instruction});
|
||||
}
|
||||
worker.postMessage({ type: 'init', google_gemini_api_key: prefs_api.google_gemini_api_key, google_gemini_model: prefs_api.google_gemini_model, google_gemini_system_instruction: prefs_api.google_gemini_system_instruction, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString("Google Gemini API", prefs_api.google_gemini_model, '', '', additional_text_elements), "info");
|
||||
browser.runtime.sendMessage({command: "google_gemini_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
additional_text_elements.push({label: 'Thinking Budget', value: prefs_api.google_gemini_thinking_budget});
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
worker.postMessage({
|
||||
type: 'init',
|
||||
google_gemini_api_key: prefs_api.google_gemini_api_key,
|
||||
google_gemini_model: prefs_api.google_gemini_model,
|
||||
google_gemini_system_instruction: prefs_api.google_gemini_system_instruction,
|
||||
google_gemini_thinking_budget: prefs_api.google_gemini_thinking_budget,
|
||||
do_debug: prefs_api.do_debug,
|
||||
i18nStrings: i18nStrings,
|
||||
});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "Google Gemini API",
|
||||
model_string: prefs_api.google_gemini_model,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
browser.runtime.sendMessage({
|
||||
command: "google_gemini_api_ready_" + call_id,
|
||||
window_id: (await browser.windows.getCurrent()).id
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "ollama_api": {
|
||||
let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: '', ollama_num_ctx: 0, ollama_think: false, do_debug: false});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
ollama_host: prefs_default.ollama_host,
|
||||
ollama_model: prefs_default.ollama_model,
|
||||
ollama_num_ctx: prefs_default.ollama_num_ctx,
|
||||
ollama_think: prefs_default.ollama_think,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["ollama_api_request_failed"] = browser.i18n.getMessage('ollama_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
messageInput.setModel(prefs_api.ollama_model);
|
||||
messagesArea.setLLMName("Ollama Local");
|
||||
worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, ollama_num_ctx: prefs_api.ollama_num_ctx, ollama_think: prefs_api.ollama_think, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
browser.runtime.sendMessage({command: "ollama_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString("Ollama API", prefs_api.ollama_model, prefs_api.ollama_host), "info");
|
||||
worker.postMessage({
|
||||
type: 'init',
|
||||
ollama_host: prefs_api.ollama_host,
|
||||
ollama_model: prefs_api.ollama_model,
|
||||
ollama_num_ctx: prefs_api.ollama_num_ctx,
|
||||
ollama_think: prefs_api.ollama_think,
|
||||
do_debug: prefs_api.do_debug,
|
||||
i18nStrings: i18nStrings
|
||||
});
|
||||
browser.runtime.sendMessage({
|
||||
command: "ollama_api_ready_" + call_id,
|
||||
window_id: (await browser.windows.getCurrent()).id
|
||||
});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "Ollama API",
|
||||
model_string: prefs_api.ollama_model,
|
||||
host_string: prefs_api.ollama_host,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
break;
|
||||
}
|
||||
case "openai_comp_api": {
|
||||
let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_comp_api_key: '', openai_comp_use_v1: true, openai_comp_chat_name: '', do_debug: false});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
openai_comp_host: prefs_default.openai_comp_host,
|
||||
openai_comp_model: prefs_default.openai_comp_model,
|
||||
openai_comp_api_key: prefs_default.openai_comp_api_key,
|
||||
openai_comp_use_v1: prefs_default.openai_comp_use_v1,
|
||||
openai_comp_chat_name: prefs_default.openai_comp_chat_name,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["OpenAIComp_api_request_failed"] = browser.i18n.getMessage('OpenAIComp_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
messageInput.setModel(prefs_api.openai_comp_model);
|
||||
messagesArea.setLLMName(prefs_api.openai_comp_chat_name);
|
||||
worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, openai_comp_use_v1: prefs_api.openai_comp_use_v1, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString("OpenAI Compatible API", prefs_api.openai_comp_model, prefs_api.openai_comp_host), "info");
|
||||
browser.runtime.sendMessage({command: "openai_comp_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
worker.postMessage({
|
||||
type: 'init',
|
||||
openai_comp_host: prefs_api.openai_comp_host,
|
||||
openai_comp_model: prefs_api.openai_comp_model,
|
||||
openai_comp_api_key: prefs_api.openai_comp_api_key,
|
||||
openai_comp_use_v1: prefs_api.openai_comp_use_v1,
|
||||
do_debug: prefs_api.do_debug,
|
||||
i18nStrings: i18nStrings,
|
||||
});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "OpenAI Compatible API",
|
||||
model_string: prefs_api.openai_comp_model,
|
||||
host_string: prefs_api.openai_comp_host,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
browser.runtime.sendMessage({
|
||||
command: "openai_comp_api_ready_" + call_id,
|
||||
window_id: (await browser.windows.getCurrent()).id
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "anthropic_api": {
|
||||
let prefs_api = await browser.storage.sync.get({anthropic_api_key: '', anthropic_model: '', anthropic_version: '2023-06-01', anthropic_max_tokens: 4096, do_debug: false});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
anthropic_api_key: prefs_default.anthropic_api_key,
|
||||
anthropic_model: prefs_default.anthropic_model,
|
||||
anthropic_version: prefs_default.anthropic_version,
|
||||
anthropic_max_tokens: prefs_default.anthropic_max_tokens,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["anthropic_api_request_failed"] = browser.i18n.getMessage('anthropic_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
messageInput.setModel(prefs_api.anthropic_model);
|
||||
messagesArea.setLLMName("Anthropic");
|
||||
worker.postMessage({ type: 'init', anthropic_api_key: prefs_api.anthropic_api_key, anthropic_model: prefs_api.anthropic_model, anthropic_version: prefs_api.anthropic_version, anthropic_max_tokens: prefs_api.anthropic_max_tokens, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString("Anthropic API", prefs_api.anthropic_model, '', prefs_api.anthropic_version), "info");
|
||||
browser.runtime.sendMessage({command: "anthropic_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
worker.postMessage({
|
||||
type: 'init',
|
||||
anthropic_api_key: prefs_api.anthropic_api_key,
|
||||
anthropic_model: prefs_api.anthropic_model,
|
||||
anthropic_version: prefs_api.anthropic_version,
|
||||
anthropic_max_tokens: prefs_api.anthropic_max_tokens,
|
||||
do_debug: prefs_api.do_debug,
|
||||
i18nStrings: i18nStrings,
|
||||
});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "Claude API",
|
||||
model_string: prefs_api.anthropic_model,
|
||||
version_string: prefs_api.anthropic_version,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
browser.runtime.sendMessage({
|
||||
command: "anthropic_api_ready_" + call_id,
|
||||
window_id: (await browser.windows.getCurrent()).id
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -191,7 +312,11 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
// we have the additional_text placeholder, do the magic!
|
||||
let finalSubs = {};
|
||||
finalSubs["additional_text"] = userInput;
|
||||
promptData.prompt = placeholdersUtils.replacePlaceholders(promptData.prompt, finalSubs, ph_def_val==='1')
|
||||
promptData.prompt = placeholdersUtils.replacePlaceholders({
|
||||
text: promptData.prompt,
|
||||
replacements: finalSubs,
|
||||
use_default_value: ph_def_val==='1'
|
||||
})
|
||||
}
|
||||
sendPrompt(promptData);
|
||||
}
|
||||
|
|
@ -206,4 +331,4 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
function sendPrompt(message){
|
||||
messageInput._setMessageInputValue(convertNewlinesToBr(message.prompt));
|
||||
messageInput._handleNewChatMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
* The original code has been released under the Apache License, Version 2.0.
|
||||
*/
|
||||
|
||||
import { prefs_default } from '../options/mzta-options-default.js';
|
||||
const messagesAreaTemplate = document.createElement('template');
|
||||
|
||||
const messagesAreaStyle = document.createElement('style');
|
||||
|
|
@ -383,7 +384,7 @@ class MessagesArea extends HTMLElement {
|
|||
splitButton.appendChild(actionButton);
|
||||
const fullTextHTMLAtAssignment = this.fullTextHTML.trim().replace(/^"|"$/g, '').replace(/^<p>"/, '<p>').replace(/"<\/p>$/, '</p>'); // strip quotation marks
|
||||
//console.log(">>>>>>>>>>>> fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment);
|
||||
let reply_type_pref = await browser.storage.sync.get({reply_type: 'reply_all'});
|
||||
let reply_type_pref = await browser.storage.sync.get({ reply_type: prefs_default.reply_type });
|
||||
if((promptData.action == "1") && (promptData.mailMessageId != -1)) {
|
||||
const actionButton_line2 = document.createElement('span');
|
||||
actionButton_line2.classList.add('action_btn_info');
|
||||
|
|
@ -613,4 +614,4 @@ function removeAloneBRs(htmlString) {
|
|||
});
|
||||
|
||||
return doc.body.innerHTML;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
images/autotags.png
Normal file
BIN
images/autotags.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
images/spamfilter.png
Normal file
BIN
images/spamfilter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
|
|
@ -27,7 +27,13 @@ export class Anthropic {
|
|||
max_tokens = 4096;
|
||||
stream = false;
|
||||
|
||||
constructor(apiKey, version, model, max_tokens = 4096, stream = false) {
|
||||
constructor({
|
||||
apiKey = '',
|
||||
version = '',
|
||||
model = '',
|
||||
max_tokens = 4096,
|
||||
stream = false,
|
||||
} = {}) {
|
||||
this.apiKey = apiKey;
|
||||
this.version = version;
|
||||
this.model = model;
|
||||
|
|
@ -49,7 +55,7 @@ export class Anthropic {
|
|||
|
||||
if (!response.ok) {
|
||||
const errorDetail = await response.text();
|
||||
let err_msg = "[ThunderAI] Anthropic API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail;
|
||||
let err_msg = "[ThunderAI] Claude API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail;
|
||||
console.error(err_msg);
|
||||
let output = {};
|
||||
output.ok = false;
|
||||
|
|
@ -64,11 +70,11 @@ export class Anthropic {
|
|||
|
||||
return output;
|
||||
}catch (error) {
|
||||
console.error("[ThunderAI] Anthropic API request failed: " + error);
|
||||
console.error("[ThunderAI] Claude API request failed: " + error);
|
||||
let output = {};
|
||||
output.is_exception = true;
|
||||
output.ok = false;
|
||||
output.error = "Anthropic API request failed: " + error;
|
||||
output.error = "Claude API request failed: " + error;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
|
@ -95,13 +101,13 @@ export class Anthropic {
|
|||
});
|
||||
return response;
|
||||
}catch (error) {
|
||||
console.error("[ThunderAI] Anthropic API request failed: " + error);
|
||||
console.error("[ThunderAI] Claude API request failed: " + error);
|
||||
let output = {};
|
||||
output.is_exception = true;
|
||||
output.ok = false;
|
||||
output.error = "Anthropic API request failed: " + error;
|
||||
output.error = "Claude API request failed: " + error;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,26 @@ export class GoogleGemini {
|
|||
model = '';
|
||||
system_instruction = '';
|
||||
stream = false;
|
||||
thinking_budget = ''; // Model default
|
||||
|
||||
constructor(apiKey, model, system_instruction, stream) {
|
||||
constructor({
|
||||
apiKey = '',
|
||||
model = '',
|
||||
system_instruction = '',
|
||||
stream = false,
|
||||
thinking_budget = '',
|
||||
} = {}) {
|
||||
this.apiKey = apiKey;
|
||||
this.model = model;
|
||||
this.system_instruction = system_instruction;
|
||||
this.stream = stream;
|
||||
this.thinking_budget = String(thinking_budget ?? '').trim();
|
||||
/* Info from: https://ai.google.dev/gemini-api/docs/thinking?#set-budget
|
||||
# Turn on thinking with a specific token limit: "thinking_budget": 1024
|
||||
# Thinking off: "thinking_budget": 0
|
||||
# Turn on dynamic thinking: "thinking_budget": -1
|
||||
# Keep model default thinking: "thinking_budget": ""
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -83,7 +97,15 @@ export class GoogleGemini {
|
|||
parts:{
|
||||
text: this.system_instruction
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if(this.thinking_budget !== '') {
|
||||
google_gemini_body.generationConfig = {
|
||||
thinkingConfig: {
|
||||
thinking_budget: this.thinking_budget,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// console.log("[ThunderAI] Google Gemini API request: " + JSON.stringify(google_gemini_body));
|
||||
|
|
|
|||
|
|
@ -24,8 +24,14 @@ export class Ollama {
|
|||
num_ctx = 0;
|
||||
think = false;
|
||||
|
||||
constructor(host, model, stream = false, num_ctx = 0, think = false) {
|
||||
this.host = host.trim().replace(/\/+$/, "");
|
||||
constructor({
|
||||
host = '',
|
||||
model = '',
|
||||
stream = false,
|
||||
num_ctx = 0,
|
||||
think = false,
|
||||
} = {}) {
|
||||
this.host = (host || '').trim().replace(/\/+$/, "");
|
||||
this.model = model;
|
||||
this.stream = stream;
|
||||
this.num_ctx = num_ctx;
|
||||
|
|
@ -123,4 +129,4 @@ export class Ollama {
|
|||
// return output;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,13 @@ export class OpenAI {
|
|||
stream = false;
|
||||
store = false;
|
||||
|
||||
constructor(apiKey, model, developer_messages, stream, store) {
|
||||
constructor({
|
||||
apiKey = '',
|
||||
model = '',
|
||||
developer_messages = '',
|
||||
stream = false,
|
||||
store = false
|
||||
} = {}) {
|
||||
this.apiKey = apiKey;
|
||||
this.model = model;
|
||||
this.developer_messages = developer_messages;
|
||||
|
|
@ -120,4 +126,4 @@ export class OpenAI {
|
|||
return data.token_count;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,14 @@ export class OpenAIComp {
|
|||
use_v1 = true;
|
||||
stream = false;
|
||||
|
||||
constructor(host, model, apiKey = '', stream = false, use_v1 = true) {
|
||||
this.host = host.trim().replace(/\/+$/, "");
|
||||
constructor({
|
||||
host = '',
|
||||
model = '',
|
||||
apiKey = '',
|
||||
stream = false,
|
||||
use_v1 = true,
|
||||
} = {}) {
|
||||
this.host = (host || '').trim().replace(/\/+$/, "");
|
||||
this.model = model;
|
||||
this.stream = stream;
|
||||
this.apiKey = apiKey;
|
||||
|
|
@ -107,4 +113,4 @@ export class OpenAIComp {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@ export const openAICompConfigs = [
|
|||
host: '',
|
||||
use_v1: true,
|
||||
},
|
||||
{
|
||||
id: 'deepseek',
|
||||
name: 'DeepSeek API',
|
||||
chat_name: 'DeepSeek',
|
||||
host: 'https://api.deepseek.com',
|
||||
use_v1: false,
|
||||
},
|
||||
{
|
||||
id: 'grok',
|
||||
name: 'Grok API',
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ let current_tabId = null;
|
|||
let current_mailMessageId = null;
|
||||
let selectionChangeTimeout = null;
|
||||
let isDragging = false;
|
||||
let delay_wait_completion = 7000; // milliseconds
|
||||
|
||||
async function chatgpt_sendMsg(msg, method ='') { // return -1 send button not found, -2 textarea not found
|
||||
let textArea = document.getElementById('prompt-textarea')
|
||||
|
|
@ -77,9 +78,10 @@ async function chatgpt_sendMsg(msg, method ='') { // return -1 send button
|
|||
async function chatgpt_isIdle() {
|
||||
return new Promise(resolve => {
|
||||
const intervalId = setInterval(() => {
|
||||
if (chatgpt_getRegenerateButton() || do_force_completion) {
|
||||
clearInterval(intervalId); resolve(true);
|
||||
}}, 100);});}
|
||||
if (chatgpt_getRegenerateButton() || do_force_completion) {
|
||||
clearInterval(intervalId); resolve(true);
|
||||
}
|
||||
}, 100);});}
|
||||
|
||||
function chatgpt_getRegenerateButton() {
|
||||
for (const mainSVG of document.querySelectorAll('main svg.icon')) {
|
||||
|
|
@ -132,6 +134,9 @@ function addCustomDiv(prompt_action,tabId,mailMessageId) {
|
|||
style.textContent += "#mzta-btn_close_diff{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);}";
|
||||
style.textContent += "#mzta-btn_change_reply_type{padding-left:4px;padding-right:10px;margin-left:0px;border-bottom-left-radius:0px;border-top-left-radius:0px;height:2.7em;}";
|
||||
style.textContent += ".mzta-btn_reply{padding-right:4px;margin-right:0px;border-bottom-right-radius:0px;border-top-right-radius:0px;}";
|
||||
style.textContent += "#mzta-forcecomp-hint{display:none;position:fixed;bottom:30px;right:90px;width:20em;background: #c3cefeff;color: #111827;padding:10px 14px;border-radius:12px;box-shadow:0 4px 10px rgba(0,0,0,.2);font-size:14px;font-weight:bold;z-index:2000;pointer:default;}";
|
||||
style.textContent += "#mzta-forcecomp-hint .label{display:block;line-height:1.3;}";
|
||||
style.textContent += "#mzta-forcecomp-hint svg{position:absolute;bottom:-10px;right:-20px;width:40px;height:40px;}";
|
||||
|
||||
// Add <style> to the page's <head>
|
||||
document.head.appendChild(style);
|
||||
|
|
@ -371,6 +376,39 @@ function addCustomDiv(prompt_action,tabId,mailMessageId) {
|
|||
customDiv.appendChild(customBtn);
|
||||
fixedDiv.appendChild(customDiv);
|
||||
|
||||
// light background hint with diagonal thick arrow
|
||||
let forcecompletionHint_div = document.createElement('div');
|
||||
forcecompletionHint_div.id = 'mzta-forcecomp-hint';
|
||||
forcecompletionHint_div.addEventListener("click", () => {
|
||||
do_force_completion = true;
|
||||
});
|
||||
|
||||
let arrowLabel = document.createElement('span');
|
||||
arrowLabel.className = 'label';
|
||||
forcecompletionHint_div.style.cursor = 'default';
|
||||
arrowLabel.textContent = browser.i18n.getMessage("chatgpt_click_force_completion");
|
||||
forcecompletionHint_div.appendChild(arrowLabel);
|
||||
arrowLabel.addEventListener("click", () => {
|
||||
do_force_completion = true;
|
||||
});
|
||||
|
||||
// SVG solid arrow (triangle)
|
||||
const svgNS = 'http://www.w3.org/2000/svg';
|
||||
let hintArrow = document.createElementNS(svgNS, 'svg');
|
||||
hintArrow.setAttribute('viewBox', '0 0 40 40');
|
||||
hintArrow.addEventListener("click", () => {
|
||||
do_force_completion = true;
|
||||
});
|
||||
|
||||
let arrowPolygon = document.createElementNS(svgNS, 'polygon');
|
||||
arrowPolygon.setAttribute('points', '0,0 40,40 0,28');
|
||||
arrowPolygon.setAttribute('fill', '#c3cefeff');
|
||||
|
||||
hintArrow.appendChild(arrowPolygon);
|
||||
forcecompletionHint_div.appendChild(hintArrow);
|
||||
|
||||
fixedDiv.appendChild(forcecompletionHint_div);
|
||||
|
||||
document.body.insertBefore(fixedDiv, document.body.firstChild);
|
||||
}
|
||||
|
||||
|
|
@ -484,6 +522,7 @@ function operation_done(){
|
|||
}
|
||||
document.getElementById('mzta-loading').style.display = 'none';
|
||||
document.getElementById('mzta-force-completion').style.display = 'none';
|
||||
document.getElementById('mzta-forcecomp-hint').style.display = 'none';
|
||||
chatpgt_scrollToBottom();
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +582,11 @@ async function doProceed(message, customText = ''){
|
|||
curr_model_warn.insertAdjacentElement('afterend', btn_retry);
|
||||
break;
|
||||
}
|
||||
const forcecompletionHintTimeout = setTimeout(() => {
|
||||
document.getElementById('mzta-forcecomp-hint').style.display = 'block';
|
||||
}, delay_wait_completion);
|
||||
await chatgpt_isIdle();
|
||||
clearTimeout(forcecompletionHintTimeout);
|
||||
operation_done();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,20 @@
|
|||
// Some original methods are derived from https://github.com/ali-raheem/Aify/blob/cfadf52f576b7be3720b5b73af7c8d3129c054da/plugin/html/actions.js
|
||||
|
||||
import { getPrompts } from './mzta-prompts.js';
|
||||
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet, getMailSubject, getTagsList, extractJsonObject, convertNewlinesToBr, cleanupNewlines, checkIfTagLabelExists } from './mzta-utils.js'
|
||||
import { prefs_default } from '../options/mzta-options-default.js';
|
||||
import {
|
||||
getLanguageDisplayName,
|
||||
getMenuContextCompose,
|
||||
getMenuContextDisplay,
|
||||
i18nConditionalGet,
|
||||
getMailSubject,
|
||||
getTagsList,
|
||||
extractJsonObject,
|
||||
convertNewlinesToBr,
|
||||
cleanupNewlines,
|
||||
checkIfTagLabelExists,
|
||||
getConnectionType,
|
||||
} from './mzta-utils.js'
|
||||
import { taPromptUtils } from './mzta-utils-prompt.js';
|
||||
import { taLogger } from './mzta-logger.js';
|
||||
import { placeholdersUtils } from './mzta-placeholders.js';
|
||||
|
|
@ -144,7 +157,19 @@ export class mzta_Menus {
|
|||
break;
|
||||
}
|
||||
|
||||
fullPrompt = await taPromptUtils.preparePrompt(curr_prompt, curr_message, chatgpt_lang, selection_text, selection_html, body_text, await getMailSubject(tabs[0]), msg_text, only_typed_text, only_quoted_text, tags_full_list);
|
||||
fullPrompt = await taPromptUtils.preparePrompt({
|
||||
curr_prompt: curr_prompt,
|
||||
curr_message: curr_message,
|
||||
chatgpt_lang: chatgpt_lang,
|
||||
selection_text: selection_text,
|
||||
selection_html: selection_html,
|
||||
body_text: body_text,
|
||||
subject_text: await getMailSubject(tabs[0]),
|
||||
msg_text: msg_text,
|
||||
only_typed_text: only_typed_text,
|
||||
only_quoted_text: only_quoted_text,
|
||||
tags_full_list: tags_full_list
|
||||
});
|
||||
|
||||
switch(curr_prompt.id){
|
||||
case 'prompt_translate_this':
|
||||
|
|
@ -170,9 +195,17 @@ export class mzta_Menus {
|
|||
case 'prompt_add_tags': { // Add tags to the email
|
||||
let tags_current_email = [];
|
||||
let tags_current_email_final = [];
|
||||
let prefs_at = await browser.storage.sync.get({add_tags_maxnum: 3, connection_type: '', add_tags_force_lang: true, add_tags_auto_force_existing: false, default_chatgpt_lang: '', do_debug: false});
|
||||
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
||||
console.error("[ThunderAI | AddTags] Invalid connection type: " + prefs_at.connection_type);
|
||||
let prefs_at = await browser.storage.sync.get({
|
||||
add_tags_maxnum: prefs_default.add_tags_maxnum,
|
||||
connection_type: prefs_default.connection_type,
|
||||
add_tags_force_lang: prefs_default.add_tags_force_lang,
|
||||
add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing,
|
||||
default_chatgpt_lang: prefs_default.default_chatgpt_lang,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
let def_conntype = getConnectionType(prefs_at.connection_type, curr_prompt);
|
||||
if((def_conntype === '')||(def_conntype === null)||(def_conntype === undefined)||(def_conntype === 'chatgpt_web')){
|
||||
console.error("[ThunderAI | AddTags] Invalid connection type: " + def_conntype);
|
||||
taWorkingStatus.stopWorking();
|
||||
return {ok:'0'};
|
||||
}
|
||||
|
|
@ -180,10 +213,17 @@ export class mzta_Menus {
|
|||
this.logger.log("fullPrompt: " + fullPrompt);
|
||||
let create_new_tags = !prefs_at.add_tags_auto_force_existing;
|
||||
let all_tags_list = tags_full_list[1];
|
||||
// TODO: use the current API, abort if using chatgpt web
|
||||
// COMMENTED TO DO TESTS
|
||||
// tags_current_email = "recipients, TEST, home, work, CAR, light";
|
||||
let cmd_addTags = new mzta_specialCommand(fullPrompt,prefs_at.connection_type,prefs_at.do_debug);
|
||||
console.log(">>>>>>>>>>>>> curr_prompt: " + JSON.stringify(curr_prompt));
|
||||
console.log(">>>>>>>>>>>>>> prefs_at.connection_type: " + JSON.stringify(prefs_at.connection_type));
|
||||
console.log(">>>>>>>>>>>>>> def_conntype: " + JSON.stringify(def_conntype));
|
||||
let cmd_addTags = new mzta_specialCommand({
|
||||
prompt: fullPrompt,
|
||||
llm: def_conntype,
|
||||
custom_model: curr_prompt.model ? curr_prompt.model : '',
|
||||
do_debug: prefs_at.do_debug
|
||||
});
|
||||
await cmd_addTags.initWorker();
|
||||
try{
|
||||
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt());
|
||||
|
|
@ -214,7 +254,11 @@ export class mzta_Menus {
|
|||
}
|
||||
case 'prompt_get_calendar_event': { // Get a calendar event info
|
||||
let calendar_event_data = '';
|
||||
let prefs_at = await browser.storage.sync.get({connection_type: '', calendar_enforce_timezone: false, calendar_timezone: '',});
|
||||
let prefs_at = await browser.storage.sync.get({
|
||||
connection_type: prefs_default.connection_type,
|
||||
calendar_enforce_timezone: prefs_default.calendar_enforce_timezone,
|
||||
calendar_timezone: prefs_default.calendar_timezone,
|
||||
});
|
||||
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
||||
console.error("[ThunderAI | GetCalendarEvent] Invalid connection type: " + prefs_at.connection_type);
|
||||
taWorkingStatus.stopWorking();
|
||||
|
|
@ -231,7 +275,11 @@ export class mzta_Menus {
|
|||
*/
|
||||
fullPrompt = taPromptUtils.finalizePrompt_get_calendar_event(fullPrompt);
|
||||
this.logger.log("fullPrompt: " + fullPrompt);
|
||||
let cmd_GetCalendarEvent = new mzta_specialCommand(fullPrompt,prefs_at.connection_type,true);
|
||||
let cmd_GetCalendarEvent = new mzta_specialCommand({
|
||||
prompt: fullPrompt,
|
||||
llm: prefs_at.connection_type,
|
||||
do_debug: true
|
||||
});
|
||||
await cmd_GetCalendarEvent.initWorker();
|
||||
try{
|
||||
calendar_event_data = await cmd_GetCalendarEvent.sendPrompt();
|
||||
|
|
@ -299,7 +347,11 @@ export class mzta_Menus {
|
|||
* }
|
||||
*/
|
||||
this.logger.log("fullPrompt: " + fullPrompt);
|
||||
let cmd_GetTask = new mzta_specialCommand(fullPrompt,prefs_at.connection_type,true);
|
||||
let cmd_GetTask = new mzta_specialCommand({
|
||||
prompt: fullPrompt,
|
||||
llm: prefs_at.connection_type,
|
||||
do_debug: true
|
||||
});
|
||||
await cmd_GetTask.initWorker();
|
||||
try{
|
||||
task_data = await cmd_GetTask.sendPrompt();
|
||||
|
|
@ -365,6 +417,7 @@ export class mzta_Menus {
|
|||
}
|
||||
}else{ // Classic prompts for the API webchat
|
||||
this.logger.log("fullPrompt: " + fullPrompt);
|
||||
this.logger.log("curr_prompt: " + JSON.stringify(curr_prompt));
|
||||
this.openChatGPT(fullPrompt, curr_prompt.action, tabs[0].id, curr_prompt.name, curr_prompt.need_custom_text, curr_prompt);
|
||||
taWorkingStatus.stopWorking();
|
||||
return {ok:'1'};
|
||||
|
|
@ -488,4 +541,4 @@ export class mzta_Menus {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { prefs_default } from '../options/mzta-options-default.js';
|
||||
|
||||
/* ================= PLACEHOLDERS PROPERTIES ========================================
|
||||
|
||||
================ BASE PROPERTIES
|
||||
|
|
@ -221,6 +223,14 @@ const defaultPlaceholders = [
|
|||
is_default: "1",
|
||||
enabled: 1,
|
||||
},
|
||||
{
|
||||
id: 'mail_attachments_info',
|
||||
name: "__MSG_placeholder_mail_attachments_info__",
|
||||
default_value: "",
|
||||
type: 1,
|
||||
is_default: "1",
|
||||
enabled: 1,
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -329,19 +339,25 @@ export const placeholdersUtils = {
|
|||
return matches;
|
||||
},
|
||||
|
||||
replacePlaceholders(text, replacements, use_default_value = false, skip_additional_text = false) {
|
||||
replacePlaceholders(args) {
|
||||
const {
|
||||
text = "",
|
||||
replacements = {},
|
||||
use_default_value = false,
|
||||
skip_additional_text = false
|
||||
} = args || {};
|
||||
// Regular expression to match patterns like {%...%}
|
||||
return text.replace(/{%\s*(.*?)\s*%}/g, function(match, p1) {
|
||||
// p1 contains the key inside {% %}
|
||||
if (skip_additional_text && (p1 === 'additional_text')) {
|
||||
return match;
|
||||
}
|
||||
const currPlaceholder = defaultPlaceholders.find(ph => ph.id === p1);
|
||||
if (!currPlaceholder) {
|
||||
return match;
|
||||
}
|
||||
// Replace if found, otherwise keep the original or substitute with default value
|
||||
return replacements[p1] || (use_default_value ? currPlaceholder.default_value : match);
|
||||
// p1 contains the key inside {% %}
|
||||
if (skip_additional_text && (p1 === 'additional_text')) {
|
||||
return match;
|
||||
}
|
||||
const currPlaceholder = defaultPlaceholders.find(ph => ph.id === p1);
|
||||
if (!currPlaceholder) {
|
||||
return match;
|
||||
}
|
||||
// Replace if found, otherwise keep the original or substitute with default value
|
||||
return replacements[p1] || (use_default_value ? currPlaceholder.default_value : match);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -390,9 +406,22 @@ export const placeholdersUtils = {
|
|||
return regex.test(text);
|
||||
},
|
||||
|
||||
async getPlaceholdersValues(prompt_text, curr_message, mail_subject, body_text, msg_text, only_typed_text, only_quoted_text, selection_text, selection_html, tags_full_list) {
|
||||
async getPlaceholdersValues(args) {
|
||||
const {
|
||||
prompt_text = "",
|
||||
curr_message = {},
|
||||
mail_subject = "",
|
||||
body_text = "",
|
||||
msg_text = {},
|
||||
only_typed_text = "",
|
||||
only_quoted_text = "",
|
||||
selection_text = "",
|
||||
selection_html = "",
|
||||
tags_full_list = ["", []]
|
||||
} = args || {};
|
||||
let currPHs = await placeholdersUtils.extractPlaceholders(prompt_text);
|
||||
// console.log(">>>>>>>>>> currPHs: " + JSON.stringify(currPHs));
|
||||
// console.log(">>>>>>>>>> curr_message: " + JSON.stringify(curr_message));
|
||||
let finalSubs = {};
|
||||
for(let currPH of currPHs){
|
||||
switch(currPH.id){
|
||||
|
|
@ -453,13 +482,23 @@ export const placeholdersUtils = {
|
|||
finalSubs['tags_full_list'] = placeholdersUtils.failSafePlaceholders(tags_full_list[0]);
|
||||
break;
|
||||
case 'thunderai_def_sign':
|
||||
let prefs_def_sign = await browser.storage.sync.get({default_sign_name: ''});
|
||||
let prefs_def_sign = await browser.storage.sync.get({ default_sign_name: prefs_default.default_sign_name });
|
||||
finalSubs['thunderai_def_sign'] = placeholdersUtils.failSafePlaceholders(prefs_def_sign.default_sign_name);
|
||||
break;
|
||||
case 'thunderai_def_lang':
|
||||
let prefs_def_lang = await browser.storage.sync.get({default_chatgpt_lang: ''});
|
||||
let prefs_def_lang = await browser.storage.sync.get({ default_chatgpt_lang: prefs_default.default_chatgpt_lang });
|
||||
finalSubs['thunderai_def_lang'] = placeholdersUtils.failSafePlaceholders(prefs_def_lang.default_chatgpt_lang);
|
||||
break;
|
||||
case 'mail_attachments_info':
|
||||
let attachments_info_string = "";
|
||||
let attachments_info = await browser.messages.listAttachments(curr_message.id);
|
||||
if(attachments_info && attachments_info.length > 0){
|
||||
attachments_info_string = attachments_info.map(att => "\"" + att.name + "\" [" + att.contentType + "] (" + Math.round(att.size / 1024) + " KB)").join("\n");
|
||||
}
|
||||
attachments_info_string = attachments_info_string.trimEnd();
|
||||
finalSubs['mail_attachments_info'] = placeholdersUtils.failSafePlaceholders(attachments_info_string);
|
||||
// console.log(">>>>>>>>>> mail_attachments_info: " + finalSubs['mail_attachments_info']);
|
||||
break;
|
||||
case 'empty':
|
||||
finalSubs['empty'] = '';
|
||||
break;
|
||||
|
|
@ -479,4 +518,4 @@ export const placeholdersUtils = {
|
|||
return element;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,12 @@
|
|||
ChatGPT Web Custom GPT (chatgpt_web_custom_gpt attribute):
|
||||
<custom_gpt>: custom gpt id url
|
||||
|
||||
API Connection Type
|
||||
<api_type>: api type
|
||||
|
||||
API Model
|
||||
<api_model>: api model
|
||||
|
||||
*/
|
||||
|
||||
const defaultPrompts = [
|
||||
|
|
@ -89,6 +95,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -106,6 +114,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -123,6 +133,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -140,6 +152,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -157,6 +171,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -174,6 +190,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -191,6 +209,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -208,6 +228,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -225,6 +247,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -242,6 +266,8 @@ const defaultPrompts = [
|
|||
chatgpt_web_model: '',
|
||||
chatgpt_web_project: '',
|
||||
chatgpt_web_custom_gpt: '',
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "0",
|
||||
},
|
||||
|
|
@ -259,6 +285,8 @@ const specialPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "0",
|
||||
use_diff_viewer: "0",
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "1",
|
||||
},
|
||||
|
|
@ -273,6 +301,8 @@ const specialPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "0",
|
||||
use_diff_viewer: "0",
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "1",
|
||||
},
|
||||
|
|
@ -287,6 +317,8 @@ const specialPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "0",
|
||||
use_diff_viewer: "0",
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "1",
|
||||
},
|
||||
|
|
@ -301,24 +333,26 @@ const specialPrompts = [
|
|||
need_custom_text: "0",
|
||||
define_response_lang: "0",
|
||||
use_diff_viewer: "0",
|
||||
api_type: '',
|
||||
api_model: '',
|
||||
is_default: "1",
|
||||
is_special: "1",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
export async function getPrompts(onlyEnabled = false, includeSpecial = []){ // includeSpecial is an array of active special prompts ids
|
||||
export async function getPrompts(onlyEnabled = false, includeSpecial = [], allSpecial = false){ // includeSpecial is an array of active special prompts ids
|
||||
const _defaultPrompts = await getDefaultPrompts_withProps();
|
||||
// console.log('>>>>>>>>>>>> getPrompts _defaultPrompts: ' + JSON.stringify(_defaultPrompts));
|
||||
const customPrompts = await getCustomPrompts();
|
||||
// console.log('>>>>>>>>>>>> getPrompts customPrompts: ' + JSON.stringify(customPrompts));
|
||||
const specialPrompts = await getSpecialPrompts();
|
||||
let output = specialPrompts.concat(_defaultPrompts).concat(customPrompts);
|
||||
if(includeSpecial.length == 0){
|
||||
if((includeSpecial.length == 0) && !allSpecial){
|
||||
output = output.filter(obj => obj.is_special != 1); // we do not want special prompts
|
||||
}else{
|
||||
// console.log(">>>>>>>>>> getPrompts includeSpecial: " + JSON.stringify(includeSpecial));
|
||||
output = output.filter(obj => includeSpecial.includes(obj.id) || obj.is_special != 1);
|
||||
output = output.filter(obj => includeSpecial.includes(obj.id) || obj.is_special != 1 || allSpecial);
|
||||
// output = output.filter(obj => {
|
||||
// const isIncluded = includeSpecial.includes(obj.id);
|
||||
// const isNotSpecial = obj.is_special != 1;
|
||||
|
|
@ -402,6 +436,11 @@ async function getDefaultPrompts_withProps() {
|
|||
prompt.position_display = prefs._default_prompts_properties[prompt.id].position_display;
|
||||
prompt.enabled = prefs._default_prompts_properties[prompt.id].enabled;
|
||||
prompt.need_custom_text = prefs._default_prompts_properties[prompt.id].need_custom_text;
|
||||
prompt.chatgpt_web_model = prefs._default_prompts_properties[prompt.id].chatgpt_web_model;
|
||||
prompt.chatgpt_web_project = prefs._default_prompts_properties[prompt.id].chatgpt_web_project;
|
||||
prompt.chatgpt_web_custom_gpt = prefs._default_prompts_properties[prompt.id].chatgpt_web_custom_gpt;
|
||||
prompt.api_type = prefs._default_prompts_properties[prompt.id].api_type;
|
||||
prompt.api_model = prefs._default_prompts_properties[prompt.id].api_model;
|
||||
}else{
|
||||
prompt.position_display = pos;
|
||||
prompt.position_compose = pos;
|
||||
|
|
@ -433,6 +472,12 @@ async function getCustomPrompts() {
|
|||
if(prompt.chatgpt_web_custom_gpt === undefined){
|
||||
prompt.chatgpt_web_custom_gpt = "";
|
||||
}
|
||||
if(prompt.api_type === undefined){
|
||||
prompt.api_type = "";
|
||||
}
|
||||
if(prompt.api_model === undefined){
|
||||
prompt.api_model = "";
|
||||
}
|
||||
});
|
||||
return prefs._custom_prompt;
|
||||
}
|
||||
|
|
@ -441,7 +486,17 @@ async function getCustomPrompts() {
|
|||
export async function setDefaultPromptsProperties(prompts) {
|
||||
let default_prompts_properties = {};
|
||||
prompts.forEach((prompt) => {
|
||||
default_prompts_properties[prompt.id] = {position_compose: prompt.position_compose, position_display: prompt.position_display, enabled: prompt.enabled, need_custom_text: prompt.need_custom_text};
|
||||
default_prompts_properties[prompt.id] = {
|
||||
position_compose: (prompt.position_compose === undefined || prompt.position_compose === "undefined") ? "" : prompt.position_compose,
|
||||
position_display: (prompt.position_display === undefined || prompt.position_display === "undefined") ? "" : prompt.position_display,
|
||||
enabled: (prompt.enabled === undefined || prompt.enabled === "undefined") ? "" : prompt.enabled,
|
||||
need_custom_text: (prompt.need_custom_text === undefined || prompt.need_custom_text === "undefined") ? "" : prompt.need_custom_text,
|
||||
chatgpt_web_model: (prompt.chatgpt_web_model === undefined || prompt.chatgpt_web_model === "undefined") ? "" : prompt.chatgpt_web_model,
|
||||
chatgpt_web_project: (prompt.chatgpt_web_project === undefined || prompt.chatgpt_web_project === "undefined") ? "" : prompt.chatgpt_web_project,
|
||||
chatgpt_web_custom_gpt: (prompt.chatgpt_web_custom_gpt === undefined || prompt.chatgpt_web_custom_gpt === "undefined") ? "" : prompt.chatgpt_web_custom_gpt,
|
||||
api_type: (prompt.api_type === undefined || prompt.api_type === "undefined") ? "" : prompt.api_type,
|
||||
api_model: (prompt.api_model === undefined || prompt.api_model === "undefined") ? "" : prompt.api_model
|
||||
};
|
||||
});
|
||||
//console.log('>>>>>>>>>>>>>> default_prompts_properties: ' + JSON.stringify(default_prompts_properties));
|
||||
await browser.storage.local.set({_default_prompts_properties: default_prompts_properties});
|
||||
|
|
@ -486,4 +541,56 @@ export async function setSpecialPrompts(prompts) {
|
|||
|
||||
export async function getSpamFilterPrompt(){
|
||||
return (await getSpecialPrompts()).find(prompt => prompt.id == 'prompt_spamfilter');
|
||||
}
|
||||
|
||||
export async function loadPrompt(id) {
|
||||
let allPrompts = await getPrompts(false,[],true);
|
||||
// console.log(">>>>>>>>>>>> loadPrompt id: " + id + " - allPrompts: " + JSON.stringify(allPrompts));
|
||||
return allPrompts.find(prompt => prompt.id === id);
|
||||
}
|
||||
|
||||
export async function savePrompt(prompt) {
|
||||
// console.log(">>>>>>>>>>>>> savePrompt prompt: " + JSON.stringify(prompt));
|
||||
if (prompt.id === undefined) {
|
||||
throw new Error("Invalid prompt: " + JSON.stringify(prompt));
|
||||
}
|
||||
// Special Prompt
|
||||
if (prompt.is_special === "1") {
|
||||
let specialPrompts = await getSpecialPrompts();
|
||||
let index = specialPrompts.findIndex(p => p.id === prompt.id);
|
||||
if (index === -1) {
|
||||
specialPrompts.push(prompt);
|
||||
} else {
|
||||
specialPrompts[index] = prompt;
|
||||
}
|
||||
await setSpecialPrompts(specialPrompts);
|
||||
return;
|
||||
}
|
||||
// Custom Prompt
|
||||
if (prompt.is_default === "0") {
|
||||
let customPrompts = await getCustomPrompts();
|
||||
let index = customPrompts.findIndex(p => p.id === prompt.id);
|
||||
if (index === -1) {
|
||||
customPrompts.push(prompt);
|
||||
} else {
|
||||
customPrompts[index] = prompt;
|
||||
}
|
||||
await setCustomPrompts(customPrompts);
|
||||
} else { // Default Prompt
|
||||
let defaultPrompts = getDefaultPrompts_withProps();
|
||||
let index = defaultPrompts.findIndex(p => p.id === prompt.id);
|
||||
if (index === -1) {
|
||||
defaultPrompts.push(prompt);
|
||||
} else {
|
||||
defaultPrompts[index] = prompt;
|
||||
}
|
||||
await setDefaultPromptsProperties(defaultPrompts);
|
||||
}
|
||||
}
|
||||
|
||||
export async function clearPromptAPI(id){
|
||||
let _prompt = await loadPrompt(id);
|
||||
_prompt.api = "";
|
||||
_prompt.model = "";
|
||||
await savePrompt(_prompt);
|
||||
}
|
||||
|
|
@ -17,22 +17,29 @@
|
|||
*/
|
||||
// Call the API to use a special prompt
|
||||
|
||||
|
||||
import { prefs_default } from "../options/mzta-options-default.js";
|
||||
import { taLogger } from './mzta-logger.js';
|
||||
|
||||
|
||||
export class mzta_specialCommand {
|
||||
|
||||
prompt = "";
|
||||
worker = null;
|
||||
llm = "";
|
||||
custom_model = "";
|
||||
full_message = "";
|
||||
logger = null;
|
||||
do_debug = false;
|
||||
|
||||
constructor(prompt, llm, do_debug = false) {
|
||||
constructor(args = {}) {
|
||||
let {
|
||||
prompt = '',
|
||||
llm = '',
|
||||
custom_model = '',
|
||||
do_debug = false
|
||||
} = args;
|
||||
this.prompt = prompt;
|
||||
this.llm = llm;
|
||||
this.custom_model = custom_model;
|
||||
this.logger = new taLogger('mzta_specialCommand', do_debug);
|
||||
this.do_debug = do_debug;
|
||||
switch (this.llm) {
|
||||
|
|
@ -58,30 +65,92 @@
|
|||
}
|
||||
|
||||
async initWorker() {
|
||||
// console.log((">>>>>>>>>>>> this.custom_model: " + this.custom_model));
|
||||
switch (this.llm) {
|
||||
case "chatgpt_api": {
|
||||
let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', chatgpt_developer_messages: ''});
|
||||
this.worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model, chatgpt_developer_messages: prefs_api.chatgpt_developer_messages, do_debug: this.do_debug, i18nStrings: ''});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
chatgpt_api_key: prefs_default.chatgpt_api_key,
|
||||
chatgpt_model: prefs_default.chatgpt_model,
|
||||
chatgpt_developer_messages: prefs_default.chatgpt_developer_messages,
|
||||
});
|
||||
this.worker.postMessage({
|
||||
type: 'init',
|
||||
chatgpt_api_key: prefs_api.chatgpt_api_key,
|
||||
chatgpt_model: this.custom_model != '' ? this.custom_model : prefs_api.chatgpt_model,
|
||||
chatgpt_developer_messages: prefs_api.chatgpt_developer_messages,
|
||||
do_debug: this.do_debug,
|
||||
i18nStrings: ''
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "google_gemini_api": {
|
||||
let prefs_api = await browser.storage.sync.get({google_gemini_api_key: '', google_gemini_model: '', google_gemini_system_instruction: ''});
|
||||
this.worker.postMessage({ type: 'init', google_gemini_api_key: prefs_api.google_gemini_api_key, google_gemini_model: prefs_api.google_gemini_model, google_gemini_system_instruction: prefs_api.google_gemini_system_instruction, do_debug: this.do_debug, i18nStrings: ''});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
google_gemini_api_key: prefs_default.google_gemini_api_key,
|
||||
google_gemini_model: prefs_default.google_gemini_model,
|
||||
google_gemini_system_instruction: prefs_default.google_gemini_system_instruction,
|
||||
google_gemini_thinking_budget: prefs_default.google_gemini_thinking_budget,
|
||||
});
|
||||
this.worker.postMessage({
|
||||
type: 'init',
|
||||
google_gemini_api_key: prefs_api.google_gemini_api_key,
|
||||
google_gemini_model: this.custom_model != '' ? this.custom_model : prefs_api.google_gemini_model,
|
||||
google_gemini_system_instruction: prefs_api.google_gemini_system_instruction,
|
||||
google_gemini_thinking_budget: prefs_api.google_gemini_thinking_budget,
|
||||
do_debug: this.do_debug,
|
||||
i18nStrings: ''
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "ollama_api": {
|
||||
let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: ''});
|
||||
this.worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, do_debug: this.do_debug, i18nStrings: ''});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
ollama_host: prefs_default.ollama_host,
|
||||
ollama_model: prefs_default.ollama_model,
|
||||
});
|
||||
this.worker.postMessage({
|
||||
type: 'init',
|
||||
ollama_host: prefs_api.ollama_host,
|
||||
ollama_model: this.custom_model != '' ? this.custom_model : prefs_api.ollama_model,
|
||||
do_debug: this.do_debug,
|
||||
i18nStrings: ''
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "openai_comp_api": {
|
||||
let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_comp_api_key: '', openai_comp_use_v1: true, openai_comp_chat_name: '', do_debug: false});
|
||||
this.worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, openai_comp_use_v1: prefs_api.openai_comp_use_v1, do_debug: this.do_debug, i18nStrings: ''});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
openai_comp_host: prefs_default.openai_comp_host,
|
||||
openai_comp_model: prefs_default.openai_comp_model,
|
||||
openai_comp_api_key: prefs_default.openai_comp_api_key,
|
||||
openai_comp_use_v1: prefs_default.openai_comp_use_v1,
|
||||
openai_comp_chat_name: prefs_default.openai_comp_chat_name,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
this.worker.postMessage({
|
||||
type: 'init',
|
||||
openai_comp_host: prefs_api.openai_comp_host,
|
||||
openai_comp_model: this.custom_model != '' ? this.custom_model : prefs_api.openai_comp_model,
|
||||
openai_comp_api_key: prefs_api.openai_comp_api_key,
|
||||
openai_comp_use_v1: prefs_api.openai_comp_use_v1,
|
||||
do_debug: this.do_debug,
|
||||
i18nStrings: ''
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "anthropic_api": {
|
||||
let prefs_api = await browser.storage.sync.get({anthropic_api_key: '', anthropic_model: '', anthropic_version: '2023-06-01', anthropic_max_tokens: 4096});
|
||||
this.worker.postMessage({ type: 'init', anthropic_api_key: prefs_api.anthropic_api_key, anthropic_model: prefs_api.anthropic_model, anthropic_version: prefs_api.anthropic_version, anthropic_max_tokens: prefs_api.anthropic_max_tokens, do_debug: this.do_debug, i18nStrings: ''});
|
||||
let prefs_api = await browser.storage.sync.get({
|
||||
anthropic_api_key: prefs_default.anthropic_api_key,
|
||||
anthropic_model: prefs_default.anthropic_model,
|
||||
anthropic_version: prefs_default.anthropic_version,
|
||||
anthropic_max_tokens: prefs_default.anthropic_max_tokens,
|
||||
});
|
||||
this.worker.postMessage({
|
||||
type: 'init',
|
||||
anthropic_api_key: prefs_api.anthropic_api_key,
|
||||
anthropic_model: this.custom_model != '' ? this.custom_model : prefs_api.anthropic_model,
|
||||
anthropic_version: prefs_api.anthropic_version,
|
||||
anthropic_max_tokens: prefs_api.anthropic_max_tokens,
|
||||
do_debug: this.do_debug,
|
||||
i18nStrings: ''
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -131,4 +200,4 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@
|
|||
|
||||
import { placeholdersUtils } from './mzta-placeholders.js';
|
||||
import { extractJsonObject } from './mzta-utils.js';
|
||||
import { prefs_default } from '../options/mzta-options-default.js';
|
||||
|
||||
export const taPromptUtils = {
|
||||
|
||||
async getDefaultSignature(){
|
||||
let prefs = await browser.storage.sync.get({default_sign_name: ''});
|
||||
let prefs = await browser.storage.sync.get({ default_sign_name: prefs_default.default_sign_name });
|
||||
if(prefs.default_sign_name===''){
|
||||
return '';
|
||||
}else{
|
||||
|
|
@ -30,7 +31,21 @@ export const taPromptUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
async preparePrompt(curr_prompt, curr_message, chatgpt_lang, selection_text, selection_html, body_text, subject_text, msg_text, only_typed_text, only_quoted_text, tags_full_list){
|
||||
async preparePrompt(args){
|
||||
const {
|
||||
curr_prompt = {},
|
||||
curr_message = {},
|
||||
chatgpt_lang = '',
|
||||
selection_text = '',
|
||||
selection_html = '',
|
||||
body_text = '',
|
||||
subject_text = '',
|
||||
msg_text = {},
|
||||
only_typed_text = '',
|
||||
only_quoted_text = '',
|
||||
tags_full_list = ["", []]
|
||||
} = args || {};
|
||||
|
||||
let fullPrompt = '';
|
||||
|
||||
if(!placeholdersUtils.hasPlaceholder(curr_prompt.text)){
|
||||
|
|
@ -42,22 +57,40 @@ export const taPromptUtils = {
|
|||
if(placeholdersUtils.hasCustomPlaceholder(curr_prompt.text)){
|
||||
curr_prompt.text = await placeholdersUtils.replaceCustomPlaceholders(curr_prompt.text);
|
||||
}
|
||||
let finalSubs = await placeholdersUtils.getPlaceholdersValues(curr_prompt.text, curr_message, subject_text, body_text, msg_text, only_typed_text, only_quoted_text, selection_text, selection_html, tags_full_list);
|
||||
// console.log(">>>>>>>>>> finalSubs: " + JSON.stringify(finalSubs));
|
||||
let prefs_ph = await browser.storage.sync.get({placeholders_use_default_value: false});
|
||||
fullPrompt = (placeholdersUtils.replacePlaceholders(curr_prompt.text, finalSubs, prefs_ph.placeholders_use_default_value, true) + (String(curr_prompt.need_signature) == "1" ? " " + await taPromptUtils.getDefaultSignature():"") + " " + chatgpt_lang).trim();
|
||||
let finalSubs = await placeholdersUtils.getPlaceholdersValues({
|
||||
prompt_text: curr_prompt.text,
|
||||
curr_message: curr_message,
|
||||
mail_subject: subject_text,
|
||||
body_text: body_text,
|
||||
msg_text: msg_text,
|
||||
only_typed_text: only_typed_text,
|
||||
only_quoted_text: only_quoted_text,
|
||||
selection_text: selection_text,
|
||||
selection_html: selection_html,
|
||||
tags_full_list: tags_full_list
|
||||
});
|
||||
let prefs_ph = await browser.storage.sync.get({ placeholders_use_default_value: prefs_default.placeholders_use_default_value });
|
||||
fullPrompt = (placeholdersUtils.replacePlaceholders({
|
||||
text: curr_prompt.text,
|
||||
replacements: finalSubs,
|
||||
use_default_value: prefs_ph.placeholders_use_default_value,
|
||||
skip_additional_text: true
|
||||
}) + (String(curr_prompt.need_signature) == "1" ? " " + await taPromptUtils.getDefaultSignature():"") + " " + chatgpt_lang).trim();
|
||||
}
|
||||
|
||||
return fullPrompt;
|
||||
},
|
||||
|
||||
finalizePrompt_add_tags(fullPrompt, add_tags_maxnum, add_tags_force_lang, default_chatgpt_lang){
|
||||
finalizePrompt_add_tags(fullPrompt, add_tags_maxnum, add_tags_force_lang, default_chatgpt_lang, add_tags_auto_uselist = false, add_tags_auto_uselist_list = ''){
|
||||
if(add_tags_maxnum > 0){
|
||||
fullPrompt += " \n" + browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + add_tags_maxnum +".";
|
||||
}
|
||||
if(add_tags_force_lang && default_chatgpt_lang !== ''){
|
||||
fullPrompt += " \n" + browser.i18n.getMessage("prompt_add_tags_force_lang") + " " + default_chatgpt_lang + ".";
|
||||
}
|
||||
if(add_tags_auto_uselist && add_tags_auto_uselist_list && add_tags_auto_uselist_list.length > 0){
|
||||
fullPrompt += " \n" + browser.i18n.getMessage("prompt_add_tags_use_list") + ": " + add_tags_auto_uselist_list + ".";
|
||||
}
|
||||
|
||||
return fullPrompt;
|
||||
},
|
||||
|
|
@ -72,7 +105,7 @@ export const taPromptUtils = {
|
|||
async getDefaultLang(curr_prompt){
|
||||
let chatgpt_lang = '';
|
||||
if(String(curr_prompt.define_response_lang) == "1"){
|
||||
let prefs = await browser.storage.sync.get({default_chatgpt_lang: ''});
|
||||
let prefs = await browser.storage.sync.get({ default_chatgpt_lang: prefs_default.default_chatgpt_lang });
|
||||
chatgpt_lang = prefs.default_chatgpt_lang;
|
||||
if(chatgpt_lang === ''){
|
||||
chatgpt_lang = browser.i18n.getMessage("reply_same_lang");
|
||||
|
|
@ -97,7 +130,7 @@ export const taPromptUtils = {
|
|||
* For backwords compatibility, if the response text is not a valid JSON,
|
||||
* it will try to split the text by commas and return the resulting array.
|
||||
*/
|
||||
getTagsFromResponse(response_text){
|
||||
getTagsFromResponse(response_text, filter_tags = false, filter_tags_list = ''){
|
||||
let tags = [];
|
||||
if(response_text && response_text.length > 0){
|
||||
try {
|
||||
|
|
@ -114,6 +147,10 @@ export const taPromptUtils = {
|
|||
tags = response_text.split(/,\s*/).map(tag => tag.trim());
|
||||
}
|
||||
}
|
||||
if(filter_tags && filter_tags_list && filter_tags_list.length > 0){
|
||||
const allowedTags = filter_tags_list.split(',').map(tag => tag.trim().toLowerCase()).filter(tag => tag.length > 0);
|
||||
tags = tags.filter(tag => allowedTags.includes(tag.toLowerCase()));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { prefs_default } from '../options/mzta-options-default.js';
|
||||
const sparks_min = '1.2.0'; // Minimum version of ThunderAI-Sparks required for the add-on to work
|
||||
export const ChatGPTWeb_models = ['gpt-5','gpt-5-instant','gpt-5-t-mini','gpt-5-thinking']; // List of models available in ChatGPT Web
|
||||
|
||||
|
|
@ -24,6 +25,10 @@ export const getMenuContextDisplay = () => 'message_display_action_menu';
|
|||
|
||||
export const contextMenuID_AddTags = 'mzta-add-tags';
|
||||
export const contextMenuID_Spamfilter = 'mzta-spamfilter';
|
||||
export const contextMenuIconsPath = {
|
||||
[contextMenuID_AddTags]: 'moz-extension:images/autotags.png',
|
||||
[contextMenuID_Spamfilter]: 'moz-extension:images/spamfilter.png',
|
||||
};
|
||||
|
||||
export function getLanguageDisplayName(languageCode) {
|
||||
const languageDisplay = new Intl.DisplayNames([languageCode], {type: 'language'});
|
||||
|
|
@ -250,6 +255,7 @@ export function convertNewlinesToParagraphs(input) {
|
|||
// This method is used to convert the model string id used in the URL
|
||||
// to the model string used in the webpage
|
||||
export function getGPTWebModelString(model) {
|
||||
if (!model) return '';
|
||||
model = model.toLowerCase().trim();
|
||||
switch (model) {
|
||||
case 'gpt-5':
|
||||
|
|
@ -388,7 +394,7 @@ export async function getTagsList(){
|
|||
}
|
||||
|
||||
export async function createTag(tag) {
|
||||
let prefs_tag = await browser.storage.sync.get({add_tags_first_uppercase: true});
|
||||
let prefs_tag = await browser.storage.sync.get({ add_tags_first_uppercase: prefs_default.add_tags_first_uppercase });
|
||||
if(prefs_tag.add_tags_first_uppercase) tag = tag.toLowerCase().charAt(0).toUpperCase() + tag.toLowerCase().slice(1);
|
||||
try {
|
||||
if(await isThunderbird128OrGreater()) {
|
||||
|
|
@ -477,6 +483,26 @@ function sanitizeString(input) {
|
|||
return sanitized;
|
||||
}
|
||||
|
||||
/* returnType:
|
||||
0: string comma separated (default)
|
||||
1: string \n separated
|
||||
2: array
|
||||
*/
|
||||
export function normalizeStringList(list, returnType = 0) {
|
||||
let _array_new = list.split(/[\n,]+/);
|
||||
_array_new = Array.from(new Set(_array_new.map(item => item.trim().toLowerCase()))).sort();
|
||||
switch(returnType) {
|
||||
case 0:
|
||||
return _array_new.join(', ');
|
||||
case 1:
|
||||
return _array_new.join('\n');
|
||||
case 2:
|
||||
return _array_new;
|
||||
default:
|
||||
return _array_new.join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
function generateHexColorForTag() {
|
||||
const red = Math.floor(Math.random() * 256);
|
||||
const green = Math.floor(Math.random() * 256);
|
||||
|
|
@ -497,7 +523,15 @@ export async function transformTagsLabels(labels, tags_list) {
|
|||
return output;
|
||||
}
|
||||
|
||||
export function getAPIsInitMessageString(api_string, model_string = '', host_string = '', version_string = '', additional_messages = []) {
|
||||
export function getAPIsInitMessageString(args = {}) {
|
||||
const {
|
||||
api_string = '',
|
||||
model_string = '',
|
||||
host_string = '',
|
||||
version_string = '',
|
||||
additional_messages = []
|
||||
} = args;
|
||||
|
||||
let output = "<i class='info_obj'>" + browser.i18n.getMessage("_api_connecting", api_string) + "</i>";
|
||||
if (model_string !== '') {
|
||||
output += "\n<span class='info_obj'>" + browser.i18n.getMessage("_api_connecting_model") + ":</span> " + model_string;
|
||||
|
|
@ -506,7 +540,7 @@ export function getAPIsInitMessageString(api_string, model_string = '', host_str
|
|||
output += "\n<span class='info_obj'>" + browser.i18n.getMessage("_api_connecting_host") + ":</span> " + host_string;
|
||||
}
|
||||
if (version_string !== '') {
|
||||
output += "\n<span class='info_obj'>" + browser.i18n.getMessage("_api_connecting_version") + ":</span> " + version_string;
|
||||
output += "\n<span class='info_obj'>" + browser.i18n.getMessage("_api_connecting_version") + ":</span> " + version_string;
|
||||
}
|
||||
let additional_message = '';
|
||||
if (additional_messages.length > 0) {
|
||||
|
|
@ -520,10 +554,21 @@ export function getAPIsInitMessageString(api_string, model_string = '', host_str
|
|||
}
|
||||
|
||||
export function getActiveSpecialPromptsIDs(args = {}) {
|
||||
const { addtags = false, get_calendar_event = false, get_task = false, is_chatgpt_web = false } = args;
|
||||
const {
|
||||
addtags = false,
|
||||
addtags_api = false,
|
||||
get_calendar_event = false,
|
||||
get_task = false,
|
||||
is_chatgpt_web = false
|
||||
} = args;
|
||||
// The Antispam filter is not here, because this method is used only
|
||||
// to reload the ThunderAI button menu, not the context menu
|
||||
let output = [];
|
||||
// console.log(">>>>>>>>>> getActiveSpecialPromptsIDs args: " + JSON.stringify(args));
|
||||
if (is_chatgpt_web) {
|
||||
if (addtags_api && addtags) {
|
||||
output.push('prompt_add_tags');
|
||||
}
|
||||
return output;
|
||||
}
|
||||
if (addtags) {
|
||||
|
|
@ -539,6 +584,14 @@ export function getActiveSpecialPromptsIDs(args = {}) {
|
|||
return output;
|
||||
}
|
||||
|
||||
export function checkAPIIntegration(connection_type, use_specific_integration, specific_integration_conntype){
|
||||
return (connection_type !== "chatgpt_web") || (use_specific_integration && (specific_integration_conntype != null) && (specific_integration_conntype !== ''));
|
||||
}
|
||||
|
||||
export function hasSpecificIntegration(use, conntype){
|
||||
return use && (conntype != null) && (conntype !== '');
|
||||
}
|
||||
|
||||
export function extractJsonObject(inputString) {
|
||||
try {
|
||||
const jsonMatch = inputString.match(/\{[\s\S]*\}/);
|
||||
|
|
@ -558,6 +611,22 @@ export function extractJsonObject(inputString) {
|
|||
}
|
||||
}
|
||||
|
||||
export function isAPIKeyValue(id){
|
||||
return id=="chatgpt_api_key" || id=="openai_comp_api_key" || id=="google_gemini_api_key" || id=="anthropic_api_key";
|
||||
}
|
||||
|
||||
export function getConnectionType(conntype, prompt, use_promptspecific_api = true) {
|
||||
if(!use_promptspecific_api) {
|
||||
return conntype;
|
||||
}
|
||||
// console.log(">>>>>>>>>>> getConnectionType conntype: " + conntype + " prompt: " + JSON.stringify(prompt));
|
||||
if (prompt?.api != null && prompt.api !== '') {
|
||||
return prompt.api;
|
||||
} else {
|
||||
return conntype;
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkSparksPresence() {
|
||||
try {
|
||||
let sparks_current = await browser.runtime.sendMessage('thunderai-sparks@micz.it',{action: "checkPresence"});
|
||||
|
|
@ -579,10 +648,12 @@ export function validateChatGPTWebCustomData(data) {
|
|||
}
|
||||
|
||||
export function sanitizeChatGPTModelData(input) {
|
||||
if(!input) return '';
|
||||
return encodeURIComponent(input).toLowerCase()
|
||||
}
|
||||
|
||||
export function sanitizeChatGPTWebCustomData(input) {
|
||||
if(!input) return '';
|
||||
// Removes all characters that are not letters, numbers, dashes, or slashes
|
||||
return input.replace(/[^\p{L}\p{N}\/-]+/gu, '');
|
||||
}
|
||||
|
|
@ -725,4 +796,4 @@ export async function* getMessages(list) {
|
|||
yield message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,16 @@ let assistantResponseAccumulator = '';
|
|||
|
||||
self.onmessage = async function(event) {
|
||||
if (event.data.type === 'init') {
|
||||
// console.log(">>>>>>>>>>>>>> event.data: " + JSON.stringify(event.data));
|
||||
anthropic_api_key = event.data.anthropic_api_key;
|
||||
anthropic_model = event.data.anthropic_model;
|
||||
anthropic = new Anthropic(anthropic_api_key, event.data.anthropic_version, anthropic_model, event.data.anthropic_max_tokens, true);
|
||||
anthropic = new Anthropic({
|
||||
apiKey: anthropic_api_key,
|
||||
version: event.data.anthropic_version,
|
||||
model: anthropic_model,
|
||||
max_tokens: event.data.anthropic_max_tokens,
|
||||
stream: true
|
||||
});
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-anthropic', do_debug);
|
||||
|
|
@ -64,7 +71,7 @@ self.onmessage = async function(event) {
|
|||
taLog.log("error_message: " + JSON.stringify(error_message));
|
||||
}
|
||||
postMessage({ type: 'error', payload: i18nStrings["anthropic_api_request_failed"] + ": " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail });
|
||||
throw new Error("[ThunderAI] Anthropic API request failed: " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail);
|
||||
throw new Error("[ThunderAI] Claude API request failed: " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail);
|
||||
}
|
||||
|
||||
const reader = response.body.getReader();
|
||||
|
|
@ -87,7 +94,7 @@ self.onmessage = async function(event) {
|
|||
postMessage({ type: 'tokensDone' });
|
||||
break;
|
||||
}
|
||||
// lots of low-level Anthropic response parsing stuff
|
||||
// lots of low-level Claude response parsing stuff
|
||||
const chunk = decoder.decode(value);
|
||||
buffer += chunk;
|
||||
taLog.log("buffer " + buffer);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,13 @@ self.onmessage = async function(event) {
|
|||
if (event.data.type === 'init') {
|
||||
google_gemini_api_key = event.data.google_gemini_api_key;
|
||||
google_gemini_model = event.data.google_gemini_model;
|
||||
google_gemini = new GoogleGemini(google_gemini_api_key, google_gemini_model, event.data.google_gemini_system_instruction, true);
|
||||
google_gemini = new GoogleGemini({
|
||||
apiKey: google_gemini_api_key,
|
||||
model: google_gemini_model,
|
||||
system_instruction: event.data.google_gemini_system_instruction,
|
||||
thinking_budget: event.data.google_gemini_thinking_budget,
|
||||
stream: true
|
||||
});
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-google_gemini', do_debug);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,12 @@ self.onmessage = async function(event) {
|
|||
ollama_model = event.data.ollama_model;
|
||||
ollama_num_ctx = event.data.ollama_num_ctx;
|
||||
//console.log(">>>>>>>>>>> ollama_host: " + ollama_host);
|
||||
ollama = new Ollama(ollama_host, ollama_model, true, ollama_num_ctx);
|
||||
ollama = new Ollama({
|
||||
host: ollama_host,
|
||||
model: ollama_model,
|
||||
stream: true,
|
||||
num_ctx: ollama_num_ctx
|
||||
});
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-ollama', do_debug);
|
||||
|
|
@ -138,4 +143,4 @@ self.onmessage = async function(event) {
|
|||
stopStreaming = true;
|
||||
break; //stop
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,7 +38,13 @@ self.onmessage = async function(event) {
|
|||
if (event.data.type === 'init') {
|
||||
chatgpt_api_key = event.data.chatgpt_api_key;
|
||||
chatgpt_model = event.data.chatgpt_model;
|
||||
openai = new OpenAI(chatgpt_api_key, chatgpt_model, event.data.chatgpt_developer_messages, true, event.data.chatgpt_api_store);
|
||||
openai = new OpenAI({
|
||||
apiKey: chatgpt_api_key,
|
||||
model: chatgpt_model,
|
||||
developer_messages: event.data.chatgpt_developer_messages,
|
||||
stream: true,
|
||||
store: event.data.chatgpt_api_store
|
||||
});
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-openai', do_debug);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,13 @@ self.onmessage = async function(event) {
|
|||
openai_comp_model = event.data.openai_comp_model;
|
||||
openai_comp_api_key = event.data.openai_comp_api_key;
|
||||
openai_comp_use_v1 = event.data.openai_comp_use_v1;
|
||||
openai_comp = new OpenAIComp(openai_comp_host, openai_comp_model, openai_comp_api_key, true, openai_comp_use_v1);
|
||||
openai_comp = new OpenAIComp({
|
||||
host: openai_comp_host,
|
||||
model: openai_comp_model,
|
||||
apiKey: openai_comp_api_key,
|
||||
stream: true,
|
||||
use_v1: openai_comp_use_v1
|
||||
});
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-openai_comp', do_debug);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"manifest_version": 2,
|
||||
"name": "ThunderAI",
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"version": "3.6.1",
|
||||
"version": "3.7.0",
|
||||
"author": "Mic (m@micz.it)",
|
||||
"homepage_url": "https://micz.it/thunderbird-addon-thunderai/",
|
||||
"browser_specific_settings": {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,37 @@ import { mzta_script } from './js/mzta-chatgpt.js';
|
|||
import { prefs_default } from './options/mzta-options-default.js';
|
||||
import { mzta_Menus } from './js/mzta-menus.js';
|
||||
import { taLogger } from './js/mzta-logger.js';
|
||||
import { getCurrentIdentity, getOriginalBody, replaceBody, setBody, i18nConditionalGet, generateCallID, migrateCustomPromptsStorage, migrateDefaultPromptsPropStorage, getGPTWebModelString, getTagsList, createTag, assignTagsToMessage, checkIfTagLabelExists, getActiveSpecialPromptsIDs, checkSparksPresence, getMessages, getMailBody, extractJsonObject, contextMenuID_AddTags, contextMenuID_Spamfilter, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, stripHtmlKeepLines, htmlBodyToPlainText, convertNewlinesToParagraphs } from './js/mzta-utils.js';
|
||||
import {
|
||||
getCurrentIdentity,
|
||||
getOriginalBody,
|
||||
replaceBody,
|
||||
setBody,
|
||||
i18nConditionalGet,
|
||||
generateCallID,
|
||||
migrateCustomPromptsStorage,
|
||||
migrateDefaultPromptsPropStorage,
|
||||
getGPTWebModelString,
|
||||
getTagsList,
|
||||
createTag,
|
||||
assignTagsToMessage,
|
||||
checkIfTagLabelExists,
|
||||
getActiveSpecialPromptsIDs,
|
||||
checkSparksPresence,
|
||||
getMessages,
|
||||
getMailBody,
|
||||
extractJsonObject,
|
||||
contextMenuID_AddTags,
|
||||
contextMenuID_Spamfilter,
|
||||
contextMenuIconsPath,
|
||||
sanitizeChatGPTModelData,
|
||||
sanitizeChatGPTWebCustomData,
|
||||
stripHtmlKeepLines,
|
||||
htmlBodyToPlainText,
|
||||
convertNewlinesToParagraphs,
|
||||
getConnectionType,
|
||||
checkAPIIntegration,
|
||||
hasSpecificIntegration,
|
||||
} from './js/mzta-utils.js';
|
||||
import { taPromptUtils } from './js/mzta-utils-prompt.js';
|
||||
import { mzta_specialCommand } from './js/mzta-special-commands.js';
|
||||
import { getSpamFilterPrompt } from './js/mzta-prompts.js';
|
||||
|
|
@ -56,6 +86,7 @@ taWorkingStatus.taLog = taLog;
|
|||
|
||||
let special_prompts_ids = getActiveSpecialPromptsIDs({
|
||||
addtags: prefs_init.add_tags,
|
||||
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
|
||||
get_calendar_event: doGetSparkFeature(prefs_init.get_calendar_event),
|
||||
get_task: doGetSparkFeature(prefs_init.get_task),
|
||||
is_chatgpt_web: (prefs_init.connection_type === "chatgpt_web")
|
||||
|
|
@ -146,6 +177,7 @@ async function _reload_menus() {
|
|||
let getTask = doGetSparkFeature(prefs_reload.get_task);
|
||||
const special_prompts_ids = getActiveSpecialPromptsIDs({
|
||||
addtags: prefs_reload.add_tags,
|
||||
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
|
||||
get_calendar_event: getCalendarEvent,
|
||||
get_task: getTask,
|
||||
is_chatgpt_web: (prefs_reload.connection_type === "chatgpt_web")
|
||||
|
|
@ -414,7 +446,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
if((originalText == null) || (originalText == "")) {
|
||||
originalText = prompt_info.body_text;
|
||||
}
|
||||
let reply_type_pref = await browser.storage.sync.get({reply_type: 'reply_all'});
|
||||
let reply_type_pref = await browser.storage.sync.get({ reply_type: prefs_default.reply_type });
|
||||
//console.log(">>>>>>>>>> prompt_info: " + JSON.stringify(prompt_info));
|
||||
let pre_script = `let mztaWinId = `+ createdTab.windowId +`;
|
||||
let mztaStatusPageDesc="`+ browser.i18n.getMessage("prefs_status_page") +`";
|
||||
|
|
@ -430,6 +462,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
let mztaReplyType="`+ reply_type_pref.reply_type + `";
|
||||
`;
|
||||
|
||||
taLog.log("pre_script: " + pre_script);
|
||||
taLog.log("Waiting " + _wait_time + " millisec");
|
||||
await new Promise(resolve => setTimeout(resolve, _wait_time));
|
||||
taLog.log("Waiting " + _wait_time + " millisec done");
|
||||
|
|
@ -492,7 +525,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener2);
|
||||
|
||||
let win_options2 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id2+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id2+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +576,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener5);
|
||||
|
||||
let win_options5 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -601,7 +634,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener3);
|
||||
|
||||
let win_options3 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id3+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id3+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -654,7 +687,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener4);
|
||||
|
||||
let win_options4 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id4+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id4+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -709,7 +742,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener5);
|
||||
|
||||
let win_options5 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -749,7 +782,25 @@ function doGetSparkFeature(spark_feature_active) {
|
|||
}
|
||||
|
||||
async function reload_pref_init(){
|
||||
prefs_init = await browser.storage.sync.get({do_debug: prefs_default.do_debug, add_tags: prefs_default.add_tags, get_calendar_event: prefs_default.get_calendar_event, get_task: prefs_default.get_task, connection_type: prefs_default.connection_type, add_tags_auto: prefs_default.add_tags_auto, add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing, add_tags_auto_only_inbox: prefs_default.add_tags_auto_only_inbox, spamfilter: prefs_default.spamfilter, spamfilter_threshold: prefs_default.spamfilter_threshold, dynamic_menu_force_enter: prefs_default.dynamic_menu_force_enter, add_tags_context_menu: prefs_default.add_tags_context_menu, spamfilter_context_menu: prefs_default.spamfilter_context_menu});
|
||||
prefs_init = await browser.storage.sync.get({
|
||||
do_debug: prefs_default.do_debug,
|
||||
add_tags: prefs_default.add_tags,
|
||||
get_calendar_event: prefs_default.get_calendar_event,
|
||||
get_task: prefs_default.get_task,
|
||||
connection_type: prefs_default.connection_type,
|
||||
add_tags_auto: prefs_default.add_tags_auto,
|
||||
add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing,
|
||||
add_tags_auto_only_inbox: prefs_default.add_tags_auto_only_inbox,
|
||||
spamfilter: prefs_default.spamfilter,
|
||||
spamfilter_threshold: prefs_default.spamfilter_threshold,
|
||||
dynamic_menu_force_enter: prefs_default.dynamic_menu_force_enter,
|
||||
add_tags_context_menu: prefs_default.add_tags_context_menu,
|
||||
spamfilter_context_menu: prefs_default.spamfilter_context_menu,
|
||||
add_tags_use_specific_integration: prefs_default.add_tags_use_specific_integration,
|
||||
add_tags_connection_type: prefs_default.add_tags_connection_type,
|
||||
spamfilter_use_specific_integration: prefs_default.spamfilter_use_specific_integration,
|
||||
spamfilter_connection_type: prefs_default.spamfilter_connection_type
|
||||
});
|
||||
_process_incoming = prefs_init.add_tags_auto || prefs_init.spamfilter;
|
||||
_sparks_presence = await checkSparksPresence();
|
||||
}
|
||||
|
|
@ -767,6 +818,7 @@ function setupStorageChangeListener() {
|
|||
let getTask = doGetSparkFeature(prefs_init.get_task);
|
||||
const special_prompts_ids = getActiveSpecialPromptsIDs({
|
||||
addtags: newTags,
|
||||
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
|
||||
get_calendar_event: getCalendarEvent,
|
||||
get_task: getTask,
|
||||
is_chatgpt_web: (prefs_init.connection_type === "chatgpt_web")
|
||||
|
|
@ -781,6 +833,7 @@ function setupStorageChangeListener() {
|
|||
let getTask = doGetSparkFeature(prefs_init.get_task);
|
||||
const special_prompts_ids = getActiveSpecialPromptsIDs({
|
||||
addtags: prefs_init.add_tags,
|
||||
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
|
||||
get_calendar_event: getCalendarEvent,
|
||||
get_task: getTask,
|
||||
is_chatgpt_web: (prefs_init.connection_type === "chatgpt_web")
|
||||
|
|
@ -795,6 +848,7 @@ function setupStorageChangeListener() {
|
|||
let getTask = doGetSparkFeature(newTask);
|
||||
const special_prompts_ids = getActiveSpecialPromptsIDs({
|
||||
addtags: prefs_init.add_tags,
|
||||
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
|
||||
get_calendar_event: getCalendarEvent,
|
||||
get_task: getTask,
|
||||
is_chatgpt_web: (prefs_init.connection_type === "chatgpt_web")
|
||||
|
|
@ -809,6 +863,7 @@ function setupStorageChangeListener() {
|
|||
let getTask = doGetSparkFeature(prefs_init.get_task);
|
||||
const special_prompts_ids = getActiveSpecialPromptsIDs({
|
||||
addtags: prefs_init.add_tags,
|
||||
addtags_api: hasSpecificIntegration(prefs_init.add_tags_use_specific_integration, prefs_init.add_tags_connection_type),
|
||||
get_calendar_event: getCalendarEvent,
|
||||
get_task: getTask,
|
||||
is_chatgpt_web: (newConnectionType === "chatgpt_web")
|
||||
|
|
@ -818,14 +873,8 @@ function setupStorageChangeListener() {
|
|||
if(newConnectionType === "chatgpt_web"){
|
||||
removeContextMenu(contextMenuID_AddTags);
|
||||
removeContextMenu(contextMenuID_Spamfilter);
|
||||
}else{
|
||||
if(prefs_init.add_tags && prefs_init.add_tags_context_menu){
|
||||
addContextMenu(contextMenuID_AddTags);
|
||||
}
|
||||
if(prefs_init.spamfilter && prefs_init.spamfilter_context_menu){
|
||||
addContextMenu(contextMenuID_Spamfilter);
|
||||
}
|
||||
}
|
||||
addContextMenuItems();
|
||||
}
|
||||
|
||||
// context menu changes for add_tags and spamfilter
|
||||
|
|
@ -895,12 +944,15 @@ menus.loadMenus(special_prompts_ids);
|
|||
|
||||
// Context Menus
|
||||
function addContextMenu(menu_id) {
|
||||
browser.menus.remove(menu_id);
|
||||
browser.menus.create({
|
||||
id: menu_id,
|
||||
title: browser.i18n.getMessage("context_menu_" + menu_id),
|
||||
contexts: ["message_list"]
|
||||
contexts: ["message_list"],
|
||||
icons: contextMenuIconsPath[menu_id],
|
||||
});
|
||||
taLog.log("Context menu added: " + menu_id);
|
||||
// console.log(">>>>>>> contextMenuIconsPath[menu_id]: " + contextMenuIconsPath[menu_id]);
|
||||
}
|
||||
|
||||
function removeContextMenu(menu_id) {
|
||||
|
|
@ -908,16 +960,19 @@ function removeContextMenu(menu_id) {
|
|||
taLog.log("Context menu removed: " + menu_id);
|
||||
}
|
||||
|
||||
// Add Context menu: Add tags
|
||||
if(prefs_init.add_tags && prefs_init.add_tags_context_menu && (prefs_init.connection_type !== "chatgpt_web")){
|
||||
addContextMenu(contextMenuID_AddTags);
|
||||
}
|
||||
|
||||
// Add Context menu: Spamfilter
|
||||
if(prefs_init.spamfilter && prefs_init.spamfilter_context_menu && (prefs_init.connection_type !== "chatgpt_web")){
|
||||
addContextMenu(contextMenuID_Spamfilter);
|
||||
function addContextMenuItems() {
|
||||
// Add Context menu: Add tags
|
||||
if(prefs_init.add_tags && prefs_init.add_tags_context_menu && checkAPIIntegration(prefs_init.connection_type, prefs_init.add_tags_use_specific_integration,prefs_init.add_tags_connection_type)){
|
||||
addContextMenu(contextMenuID_AddTags);
|
||||
}
|
||||
|
||||
// Add Context menu: Spamfilter
|
||||
if(prefs_init.spamfilter && prefs_init.spamfilter_context_menu && checkAPIIntegration(prefs_init.connection_type, prefs_init.spamfilter_use_specific_integration,prefs_init.spamfilter_connection_type)){
|
||||
addContextMenu(contextMenuID_Spamfilter);
|
||||
}
|
||||
}
|
||||
|
||||
addContextMenuItems();
|
||||
|
||||
// Listen for context menu item clicks
|
||||
browser.menus.onClicked.addListener( (info, tab) => {
|
||||
|
|
@ -973,7 +1028,12 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
|
|||
add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing,
|
||||
add_tags_enabled_accounts: prefs_default.add_tags_enabled_accounts,
|
||||
add_tags_exclusions_exact_match: prefs_default.add_tags_exclusions_exact_match,
|
||||
add_tags_auto_uselist: prefs_default.add_tags_auto_uselist,
|
||||
add_tags_auto_uselist_list: prefs_default.add_tags_auto_uselist_list,
|
||||
spamfilter_enabled_accounts: prefs_default.spamfilter_enabled_accounts,
|
||||
add_tags_use_specific_integration: prefs_default.add_tags_use_specific_integration,
|
||||
spamfilter_use_specific_integration: prefs_default.spamfilter_use_specific_integration,
|
||||
do_debug: prefs_default.do_debug,
|
||||
});
|
||||
|
||||
for await (let message of messages) {
|
||||
|
|
@ -984,7 +1044,7 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
|
|||
if (addTagsAuto || spamFilter) {
|
||||
curr_fullMessage = await browser.messages.getFull(message.id);
|
||||
msg_text = getMailBody(curr_fullMessage);
|
||||
taLog.log("Startin from the HTML body if present and converting to plain text...");
|
||||
taLog.log("Starting from the HTML body if present and converting to plain text...");
|
||||
body_text = htmlBodyToPlainText(msg_text.html);
|
||||
if( body_text.length == 0 ){
|
||||
taLog.log("No HTML found in the message body, using plain text...");
|
||||
|
|
@ -1003,16 +1063,30 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
|
|||
let specialFullPrompt_add_tags = '';
|
||||
let curr_prompt_add_tags = menus.allPrompts.find(p => p.id === 'prompt_add_tags');
|
||||
let tags_full_list = await getTagsList();
|
||||
// console.log(">>>>>>>>>>>>> curr_prompt_add_tags: " + curr_prompt_add_tags);
|
||||
// console.log(">>>>>>>>>>>>> curr_prompt_add_tags: " + JSON.stringify(curr_prompt_add_tags));
|
||||
let chatgpt_lang = await taPromptUtils.getDefaultLang(curr_prompt_add_tags);
|
||||
specialFullPrompt_add_tags = await taPromptUtils.preparePrompt(curr_prompt_add_tags, message, chatgpt_lang, '', '', body_text, curr_fullMessage.headers.subject, msg_text, '', '', tags_full_list);
|
||||
specialFullPrompt_add_tags = taPromptUtils.finalizePrompt_add_tags(specialFullPrompt_add_tags, prefs_aats.add_tags_maxnum, prefs_aats.add_tags_force_lang, prefs_aats.default_chatgpt_lang);
|
||||
specialFullPrompt_add_tags = await taPromptUtils.preparePrompt({
|
||||
curr_prompt: curr_prompt_add_tags,
|
||||
curr_message: message,
|
||||
chatgpt_lang: chatgpt_lang,
|
||||
body_text: body_text,
|
||||
subject_text: curr_fullMessage.headers.subject,
|
||||
msg_text: msg_text,
|
||||
tags_full_list: tags_full_list
|
||||
});
|
||||
specialFullPrompt_add_tags = taPromptUtils.finalizePrompt_add_tags(specialFullPrompt_add_tags, prefs_aats.add_tags_maxnum, prefs_aats.add_tags_force_lang, prefs_aats.default_chatgpt_lang, prefs_aats.add_tags_auto_uselist, prefs_aats.add_tags_auto_uselist_list);
|
||||
taLog.log("Special prompt: " + specialFullPrompt_add_tags);
|
||||
let cmd_addTags = new mzta_specialCommand(specialFullPrompt_add_tags, prefs_aats.connection_type, prefs_init.do_debug);
|
||||
// console.log(">>>>>>>>>> curr_prompt_add_tags.model: " + curr_prompt_add_tags.model);
|
||||
let cmd_addTags = new mzta_specialCommand({
|
||||
prompt: specialFullPrompt_add_tags,
|
||||
llm: getConnectionType(prefs_aats.connection_type, curr_prompt_add_tags, prefs_aats.add_tags_use_specific_integration),
|
||||
custom_model: curr_prompt_add_tags.model ? curr_prompt_add_tags.model : '',
|
||||
do_debug: prefs_aats.do_debug
|
||||
});
|
||||
await cmd_addTags.initWorker();
|
||||
let tags_current_email = [];
|
||||
try {
|
||||
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt());
|
||||
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt(), prefs_aats.add_tags_auto_uselist, prefs_aats.add_tags_auto_uselist_list);
|
||||
} catch (err) {
|
||||
console.error("[ThunderAI | Auto add_tags] Error getting tags: ", err);
|
||||
}
|
||||
|
|
@ -1030,12 +1104,24 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
|
|||
}
|
||||
}
|
||||
let curr_prompt_spamfilter = await getSpamFilterPrompt();
|
||||
// console.log(">>>>>>>>>>>>> curr_prompt_spamfilter: " + curr_prompt_spamfilter);
|
||||
// console.log(">>>>>>>>>>>>> curr_prompt_spamfilter: " + JSON.stringify(curr_prompt_spamfilter));
|
||||
let chatgpt_lang = await taPromptUtils.getDefaultLang(curr_prompt_spamfilter);
|
||||
let specialFullPrompt_spamfilter = await taPromptUtils.preparePrompt(curr_prompt_spamfilter, message, chatgpt_lang, '', '', body_text, curr_fullMessage.headers.subject, msg_text, '', '', []);
|
||||
let specialFullPrompt_spamfilter = await taPromptUtils.preparePrompt({
|
||||
curr_prompt: curr_prompt_spamfilter,
|
||||
curr_message: message,
|
||||
chatgpt_lang: chatgpt_lang,
|
||||
body_text: body_text,
|
||||
subject_text: curr_fullMessage.headers.subject,
|
||||
msg_text: msg_text
|
||||
});
|
||||
taLog.log("Special prompt: " + specialFullPrompt_spamfilter);
|
||||
console.log(">>>>>>>> Special prompt for spamfilter: " + specialFullPrompt_spamfilter);
|
||||
let cmd_spamfilter = new mzta_specialCommand(specialFullPrompt_spamfilter, prefs_init.connection_type, prefs_init.do_debug);
|
||||
// console.log(">>>>>>>> Special prompt for spamfilter: " + specialFullPrompt_spamfilter);
|
||||
let cmd_spamfilter = new mzta_specialCommand({
|
||||
prompt: specialFullPrompt_spamfilter,
|
||||
llm: getConnectionType(prefs_aats.connection_type, curr_prompt_spamfilter, prefs_aats.spamfilter_use_specific_integration),
|
||||
custom_model: curr_prompt_spamfilter.model ? curr_prompt_spamfilter.model : '',
|
||||
do_debug: prefs_aats.do_debug
|
||||
});
|
||||
await cmd_spamfilter.initWorker();
|
||||
let spamfilter_result = '';
|
||||
taLog.log("Sending the prompt...");
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export const prefs_default = {
|
|||
google_gemini_api_key: '',
|
||||
google_gemini_model: '',
|
||||
google_gemini_system_instruction: '',
|
||||
google_gemini_thinking_budget: '',
|
||||
anthropic_api_key: '',
|
||||
anthropic_model: '',
|
||||
anthropic_version: '2023-06-01',
|
||||
|
|
@ -62,8 +63,17 @@ export const prefs_default = {
|
|||
add_tags_auto: false,
|
||||
add_tags_auto_force_existing: false,
|
||||
add_tags_auto_only_inbox: true,
|
||||
add_tags_auto_uselist: false,
|
||||
add_tags_auto_uselist_list: '',
|
||||
add_tags_context_menu: true,
|
||||
add_tags_enabled_accounts: [],
|
||||
add_tags_use_specific_integration: false,
|
||||
add_tags_connection_type: 'chatgpt_api',
|
||||
add_tags_chatgpt_model: '',
|
||||
add_tags_ollama_model: '',
|
||||
add_tags_openai_comp_model: '',
|
||||
add_tags_google_gemini_model: '',
|
||||
add_tags_anthropic_model: '',
|
||||
get_calendar_event: true,
|
||||
get_task: true,
|
||||
calendar_enforce_timezone: false,
|
||||
|
|
@ -72,4 +82,11 @@ export const prefs_default = {
|
|||
spamfilter_threshold: 70,
|
||||
spamfilter_context_menu: true,
|
||||
spamfilter_enabled_accounts: [],
|
||||
}
|
||||
spamfilter_use_specific_integration: false,
|
||||
spamfilter_connection_type: 'chatgpt_api',
|
||||
spamfilter_chatgpt_model: '',
|
||||
spamfilter_ollama_model: '',
|
||||
spamfilter_openai_comp_model: '',
|
||||
spamfilter_google_gemini_model: '',
|
||||
spamfilter_anthropic_model: '',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,10 +82,6 @@ span.dims_label{
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
span.opt_title{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#btn_custom_prompts{
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
|
|
@ -104,38 +100,9 @@ div#miczTranslate{
|
|||
font-size:smaller;
|
||||
}
|
||||
|
||||
tr.conntype_chatgpt_api, tr.conntype_chatgpt_api2{
|
||||
background-color: rgb(185, 220, 252);
|
||||
}
|
||||
|
||||
tr.conntype_chatgpt_web, tr.conntype_chatgpt_web2{
|
||||
background-color: rgb(255, 209, 183);
|
||||
}
|
||||
|
||||
tr.conntype_ollama_api, tr.conntype_ollama_api2{
|
||||
background-color: rgb(177, 238, 169);
|
||||
}
|
||||
|
||||
tr.conntype_openai_comp_api, tr.conntype_openai_comp_api2{
|
||||
background-color: rgb(213, 169, 238);
|
||||
}
|
||||
|
||||
tr.conntype_google_gemini_api, tr.conntype_google_gemini_api2{
|
||||
background-color: rgb(233, 238, 169);
|
||||
}
|
||||
|
||||
tr.conntype_anthropic_api, tr.conntype_anthropic_api2{
|
||||
background-color: rgb(255, 168, 204);
|
||||
}
|
||||
|
||||
#chatgpt_model_fetch_loading{
|
||||
.warn_API_needed{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#google_gemini_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#no_sparks td{
|
||||
|
|
@ -144,53 +111,6 @@ tr.conntype_anthropic_api, tr.conntype_anthropic_api2{
|
|||
background: #bbf7f1;
|
||||
}
|
||||
|
||||
textarea.option-textarea{
|
||||
width: -moz-available;
|
||||
height: 10em;
|
||||
}
|
||||
|
||||
.api_key-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.api_key-container input {
|
||||
width: -moz-available;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
input[type="text"], input[type="password"]{
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
input.option-input[type="text"]{
|
||||
width: -moz-available;
|
||||
}
|
||||
|
||||
.api_key-container .toggle-icon {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#ollama_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#openai_comp_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#anthropic_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#owl_warning{
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -235,10 +155,6 @@ input.option-input[type="text"]{
|
|||
color: #FF6600;
|
||||
}
|
||||
|
||||
.conntype_chatgpt_web_option{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn_small{
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="mzta-options.css">
|
||||
<link rel="stylesheet" href="../pages/_lib/connection-ui.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="miczRelNotes"><a href="mzta-release-notes.html">__MSG_prefs_OptionText_release_notes__</a></div>
|
||||
|
|
@ -113,375 +114,7 @@
|
|||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_prefs_Connection_type__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<select id="connection_type" name="connection_type" class="option-input">
|
||||
<option value="chatgpt_web">__MSG_prefs_Connection_type_ChatGPT_Web__</option>
|
||||
<option value="chatgpt_api">__MSG_prefs_Connection_type_ChatGPT_API__</option>
|
||||
<option value="google_gemini_api">__MSG_prefs_Connection_type_Google_Gemini_API__</option>
|
||||
<option value="anthropic_api">__MSG_prefs_Connection_type_Anthropic_API__</option>
|
||||
<option value="ollama_api">__MSG_prefs_Connection_type_Ollama_API__</option>
|
||||
<option value="openai_comp_api">__MSG_prefs_Connection_type_OpenAI_Comp_API__</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_apiwebchat_info__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
__MSG_prefs_OptionText_chatgpt_web_br_replace_info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_model__</span>
|
||||
<br><table title="__MSG_prefs_OptionText_chatgpt_web_model_tooltip__"><tr id="chatgpt_web_models_list"></tr></table>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="chatgpt_web_model" name="chatgpt_web_model" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_model_info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_project__</span>
|
||||
<br><i class="small_info" id="chatgpt_web_project_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b class="lightbold">/g/PROJECT-ID-PROJECT-NAME/project</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="chatgpt_web_project" name="chatgpt_web_project" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_project_info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_custom_gpt__</span>
|
||||
<br><i class="small_info" id="chatgpt_web_custom_gpt_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b class="lightbold">/g/CUSTOM-GPT-ID</b>
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="chatgpt_web_custom_gpt" name="chatgpt_web_custom_gpt" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_chatgpt_web_custom_gpt_info__
|
||||
<br>__MSG_prefs_OptionText_CustomGPT_Warn__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_chatgpt_web_tempchat__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="chatgpt_web_tempchat" name="chatgpt_web_tempchat" class="option-input" />
|
||||
<span>__MSG_prefs_OptionText_chatgpt_web_tempchat_info__
|
||||
<br>__MSG_prefs_OptionText_Project_No_temporary_chat_warn__
|
||||
</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_web">
|
||||
<td colspan="2" style="padding:0px 2em;text-align:center;"><span>__MSG_OpenChatGPTTab_Info__</span>
|
||||
<br><br><button id="btnChatGPTWeb_Tab">__MSG_OpenChatGPTTab__</button>
|
||||
<br><br>__MSG_OpenChatGPTTab_Info2__
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_ChatGPT_API_Key__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<div class="api_key-container">
|
||||
<label>
|
||||
<input type="password" id="chatgpt_api_key" name="chatgpt_api_key" class="option-input"/>
|
||||
</label>
|
||||
<span class="toggle-icon" id="toggle_chatgpt_api_key"><img src="../images/pwd-show.png" id="pwd-icon_chatgpt_api_key"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_ChatGPT_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<button id="btnUpdateChatGPTModels">__MSG_ChatGPT_Models_Fetch__</button> <span id="chatgpt_model_fetch_loading">__MSG_Loading__</span><br>
|
||||
<label>
|
||||
<select id="chatgpt_model" name="chatgpt_model" class="option-input">
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_ChatGPT_chatgpt_api_store__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="chatgpt_api_store" name="chatgpt_api_store" class="option-input" />
|
||||
<span>__MSG_ChatGPT_chatgpt_api_store_info__</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_chatgpt_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_ChatGPT_Developer_Messages__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<textarea id="chatgpt_developer_messages" name="chatgpt_developer_messages" class="option-input option-textarea"></textarea>
|
||||
<br>__MSG_ChatGPT_Developer_Messages_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_google_gemini_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_GoogleGemini_API_Key__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<div class="api_key-container">
|
||||
<label>
|
||||
<input type="password" id="google_gemini_api_key" name="google_gemini_api_key" class="option-input"/>
|
||||
</label>
|
||||
<span class="toggle-icon" id="toggle_google_gemini_api_key"><img src="../images/pwd-show.png" id="pwd-icon_google_gemini_api_key"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_google_gemini_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_GoogleGemini_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<button id="btnUpdateGoogleGeminiModels">__MSG_GoogleGemini_Models_Fetch__</button> <span id="google_gemini_model_fetch_loading">__MSG_Loading__</span><br>
|
||||
<label>
|
||||
<select id="google_gemini_model" name="google_gemini_model" class="option-input">
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_google_gemini_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_GoogleGemini_SystemInstruction__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<textarea id="google_gemini_system_instruction" name="google_gemini_system_instruction" class="option-input option-textarea"></textarea>
|
||||
<br>__MSG_GoogleGemini_SystemInstruction_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_ollama_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_API_Host__</span>
|
||||
<br><i class="small_info">__MSG_prefs_API_Host_Info__ http://127.0.0.1:11434</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="ollama_host" name="ollama_host" class="option-input"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_ollama_api" id="ollama_api_cors_warning">
|
||||
<td colspan="2" style="text-align:center;">
|
||||
__MSG_remember_CORS__ [<a href="https://micz.it/thunderbird-addon-thunderai/ollama-cors-information/">__MSG_more_info_string__</a>]
|
||||
<br><br><b>__MSG_CORS_alternative_1__</b>
|
||||
<br>__MSG_CORS_alternative_2__
|
||||
<br><br><button id="btnGiveAllUrlsPermission_ollama_api">__MSG_CORS_give_allurls_perm__</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_ollama_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_Ollama_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<button id="btnUpdateOllamaModels">__MSG_Ollama_Models_Fetch__</button> <span id="ollama_model_fetch_loading">__MSG_Loading__</span><br>
|
||||
<label>
|
||||
<select id="ollama_model" name="ollama_model" class="option-input">
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_ollama_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_ollama_think__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="ollama_think" name="ollama_think" class="option-input"/>
|
||||
__MSG_prefs_ollama_think_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_ollama_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_ollama_num_ctx__ <i>[num_ctx]</i></span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="number" id="ollama_num_ctx" name="ollama_num_ctx" class="option-input"/>
|
||||
<br>__MSG_prefs_ollama_num_ctx_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OpenAIComp_AvailableServices__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<select id="openai_comp_services_shortcut">
|
||||
</select>
|
||||
<br>__MSG_prefs_OpenAIComp_AvailableServices_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_API_Host__</span>
|
||||
<br><i class="small_info">__MSG_prefs_API_Host_Info__ http://localhost:1234</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="openai_comp_host" name="openai_comp_host" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_openai_comp_info_remote__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api" id="openai_comp_api_cors_warning">
|
||||
<td colspan="2" style="text-align:center;">
|
||||
__MSG_maybe_CORS_openai_comp__ [<a href="https://micz.it/thunderbird-addon-thunderai/ollama-cors-information/">__MSG_more_info_string__</a>]
|
||||
<br><br><b>__MSG_CORS_alternative_1__</b>
|
||||
<br>__MSG_CORS_alternative_2__
|
||||
<br><br><button id="btnGiveAllUrlsPermission_openai_comp_api">__MSG_CORS_give_allurls_perm__</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OptionText_openai_comp_use_v1__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="openai_comp_use_v1" name="openai_comp_use_v1" class="option-input" />
|
||||
<span>__MSG_prefs_OptionText_openai_comp_use_v1_info__</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OpenAIComp_API_Key__</span>
|
||||
<br><i class="small_info">__MSG_Optional__</i>
|
||||
</label></td>
|
||||
<td>
|
||||
<div class="api_key-container">
|
||||
<label>
|
||||
<input type="password" id="openai_comp_api_key" name="openai_comp_api_key" class="option-input"/>
|
||||
</label>
|
||||
<span class="toggle-icon" id="toggle_openai_comp_api_key"><img src="../images/pwd-show.png" id="pwd-icon_openai_comp_api_key"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_OpenAIComp_Models__</span>
|
||||
<br><button id="btnOpenAICompForceModel" class="btn_small">__MSG_prefs_OpenAIComp_ForceModel__</button>
|
||||
<br><button id="btnOpenAICompClearModelsList" class="btn_small">__MSG_prefs_OpenAIComp_ClearModelsList__</button></td>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<button id="btnUpdateOpenAICompModels">__MSG_OpenAIComp_Models_Fetch__</button> <span id="openai_comp_model_fetch_loading">__MSG_Loading__</span><br>
|
||||
<label>
|
||||
<select id="openai_comp_model" name="openai_comp_model" class="option-input">
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_OpenAIComp_ChatName__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="openai_comp_chat_name" name="openai_comp_chat_name" class="option-input" />
|
||||
<br>__MSG_prefs_OpenAIComp_ChatName_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_anthropic_api">
|
||||
<td><label>
|
||||
<span class="opt_title">__MSG_prefs_Anthropic_API_Key__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<div class="api_key-container">
|
||||
<label>
|
||||
<input type="password" id="anthropic_api_key" name="anthropic_api_key" class="option-input"/>
|
||||
</label>
|
||||
<span class="toggle-icon" id="toggle_anthropic_api_key"><img src="../images/pwd-show.png" id="pwd-icon_anthropic_api_key"></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_anthropic_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_Anthropic_Models__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<button id="btnUpdateAnthropicModels">__MSG_Anthropic_Models_Fetch__</button> <span id="anthropic_model_fetch_loading">__MSG_Loading__</span><br>
|
||||
<label>
|
||||
<select id="anthropic_model" name="anthropic_model" class="option-input">
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_anthropic_api">
|
||||
<td>
|
||||
<label>
|
||||
<span class="opt_title">__MSG_Anthropic_Version__</span>
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="text" id="anthropic_version" name="anthropic_version" class="option-input" />
|
||||
<br>__MSG_Anthropic_Version_Info__ <a href="https://docs.anthropic.com/en/api/versioning">https://docs.anthropic.com/en/api/versioning</a>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_anthropic_api">
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_anthropic_max_tokens__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="number" id="anthropic_max_tokens" name="anthropic_max_tokens" class="option-input" />
|
||||
<br>__MSG_prefs_OptionText_anthropic_max_tokens_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="connection_ui_anchor"></tr>
|
||||
<tr id="max_prompt_length_tr">
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_max_prompt_length__</span></td>
|
||||
<td>
|
||||
|
|
@ -499,6 +132,7 @@
|
|||
<label>
|
||||
<input type="checkbox" id="add_tags" name="add_tags" class="option-input" />
|
||||
__MSG_prefs_OptionText_add_tags_Info__
|
||||
<br><span class="warn_API_needed" id="add_tags_warn_API_needed">__MSG_warn_API_needed__</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -509,6 +143,7 @@
|
|||
<label>
|
||||
<input type="checkbox" id="spamfilter" name="spamfilter" class="option-input" />
|
||||
__MSG_prefs_OptionText_spamfilter_Info__
|
||||
<br><span class="warn_API_needed" id="spamfilter_warn_API_needed">__MSG_warn_API_needed__</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -18,17 +18,24 @@
|
|||
|
||||
import { prefs_default } from './mzta-options-default.js';
|
||||
import { taLogger } from '../js/mzta-logger.js';
|
||||
import { OpenAI } from '../js/api/openai.js';
|
||||
import { Ollama } from '../js/api/ollama.js';
|
||||
import { OpenAIComp } from '../js/api/openai_comp.js'
|
||||
import { GoogleGemini } from '../js/api/google_gemini.js';
|
||||
import { Anthropic } from '../js/api/anthropic.js';
|
||||
import { ChatGPTWeb_models, checkSparksPresence, isThunderbird128OrGreater, openTab, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, validateCustomData_ChatGPTWeb, getChatGPTWebModelsList_HTML } from '../js/mzta-utils.js';
|
||||
import { openAICompConfigs } from '../js/api/openai_comp_configs.js';
|
||||
import {
|
||||
ChatGPTWeb_models,
|
||||
checkSparksPresence,
|
||||
isThunderbird128OrGreater,
|
||||
openTab,
|
||||
getChatGPTWebModelsList_HTML,
|
||||
isAPIKeyValue,
|
||||
getConnectionType,
|
||||
} from '../js/mzta-utils.js';
|
||||
import {
|
||||
injectConnectionUI,
|
||||
varConnectionUI,
|
||||
showConnectionOptions,
|
||||
updateWarnings
|
||||
} from '../pages/_lib/connection-ui.js';
|
||||
|
||||
let taLog = new taLogger("mzta-options",true);
|
||||
let _isThunderbird128OrGreater = true;
|
||||
let permission_all_urls = false;
|
||||
|
||||
function saveOptions(e) {
|
||||
e.preventDefault();
|
||||
|
|
@ -70,7 +77,7 @@ function saveOptions(e) {
|
|||
async function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelectorAll(".option-input").forEach(element => {
|
||||
taLog.log("Options restoring " + element.id + " = " + (element.id=="chatgpt_api_key" || element.id=="openai_comp_api_key" || element.id=="google_gemini_api_key" || element.id=="anthropic_api_key" ? "****************" : result[element.id]));
|
||||
taLog.log("Options restoring " + element.id + " = " + (isAPIKeyValue(element.id) ? "****************" : result[element.id]));
|
||||
switch (element.type) {
|
||||
case 'checkbox':
|
||||
element.checked = result[element.id] || false;
|
||||
|
|
@ -109,211 +116,6 @@ async function restoreOptions() {
|
|||
setCurrentChoice(getting);
|
||||
}
|
||||
|
||||
function showConnectionOptions() {
|
||||
disable_MaxPromptLength();
|
||||
disable_AddTags();
|
||||
disable_SpamFilter();
|
||||
disable_GetCalendarEvent();
|
||||
let chatgpt_web_display = 'table-row';
|
||||
let chatgpt_api_display = 'none';
|
||||
let ollama_api_display = 'none';
|
||||
let openai_comp_api_display = 'none';
|
||||
let google_gemini_api_display = 'none';
|
||||
let anthropic_api_display = 'none';
|
||||
let conntype_select = document.getElementById("connection_type");
|
||||
let parent = conntype_select.parentElement.parentElement.parentElement;
|
||||
parent.classList.toggle("conntype_chatgpt_web", (conntype_select.value === "chatgpt_web"));
|
||||
parent.classList.toggle("conntype_chatgpt_api", (conntype_select.value === "chatgpt_api"));
|
||||
parent.classList.toggle("conntype_ollama_api", (conntype_select.value === "ollama_api"));
|
||||
parent.classList.toggle("conntype_openai_comp_api", (conntype_select.value === "openai_comp_api"));
|
||||
parent.classList.toggle("conntype_google_gemini_api", (conntype_select.value === "google_gemini_api"));
|
||||
parent.classList.toggle("conntype_anthropic_api", (conntype_select.value === "anthropic_api"));
|
||||
if (conntype_select.value === "chatgpt_web") {
|
||||
chatgpt_web_display = 'table-row';
|
||||
}else{
|
||||
chatgpt_web_display = 'none';
|
||||
}
|
||||
if (conntype_select.value === "chatgpt_api") {
|
||||
chatgpt_api_display = 'table-row';
|
||||
}else{
|
||||
chatgpt_api_display = 'none';
|
||||
}
|
||||
if (conntype_select.value === "ollama_api") {
|
||||
ollama_api_display = 'table-row';
|
||||
}else{
|
||||
ollama_api_display = 'none';
|
||||
}
|
||||
if (conntype_select.value === "openai_comp_api") {
|
||||
openai_comp_api_display = 'table-row';
|
||||
}else{
|
||||
openai_comp_api_display = 'none';
|
||||
}
|
||||
if (conntype_select.value === "google_gemini_api") {
|
||||
google_gemini_api_display = 'table-row';
|
||||
}else{
|
||||
google_gemini_api_display = 'none';
|
||||
}
|
||||
if (conntype_select.value === "anthropic_api") {
|
||||
anthropic_api_display = 'table-row';
|
||||
}else{
|
||||
anthropic_api_display = 'none';
|
||||
}
|
||||
document.querySelectorAll(".conntype_chatgpt_web").forEach(element => {
|
||||
element.style.display = chatgpt_web_display;
|
||||
});
|
||||
document.querySelectorAll(".conntype_chatgpt_api").forEach(element => {
|
||||
element.style.display = chatgpt_api_display;
|
||||
});
|
||||
document.querySelectorAll(".conntype_ollama_api").forEach(element => {
|
||||
element.style.display = ollama_api_display;
|
||||
});
|
||||
document.querySelectorAll(".conntype_openai_comp_api").forEach(element => {
|
||||
element.style.display = openai_comp_api_display;
|
||||
});
|
||||
document.querySelectorAll(".conntype_google_gemini_api").forEach(element => {
|
||||
element.style.display = google_gemini_api_display;
|
||||
});
|
||||
document.querySelectorAll(".conntype_anthropic_api").forEach(element => {
|
||||
element.style.display = anthropic_api_display;
|
||||
});
|
||||
if (permission_all_urls) {
|
||||
document.getElementById('openai_comp_api_cors_warning').style.display = 'none';
|
||||
document.getElementById('ollama_api_cors_warning').style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function warn_ChatGPT_APIKeyEmpty() {
|
||||
let apiKeyInput = document.getElementById('chatgpt_api_key');
|
||||
let btnFetchChatGPTModels = document.getElementById('btnUpdateChatGPTModels');
|
||||
let modelChatGPT = document.getElementById('chatgpt_model');
|
||||
if(apiKeyInput.value === ''){
|
||||
apiKeyInput.style.border = '2px solid red';
|
||||
btnFetchChatGPTModels.disabled = true;
|
||||
modelChatGPT.disabled = true;
|
||||
modelChatGPT.selectedIndex = -1;
|
||||
modelChatGPT.style.border = '';
|
||||
}else{
|
||||
apiKeyInput.style.border = '';
|
||||
btnFetchChatGPTModels.disabled = false;
|
||||
modelChatGPT.disabled = false;
|
||||
if((modelChatGPT.selectedIndex === -1)||(modelChatGPT.value === '')){
|
||||
modelChatGPT.style.border = '2px solid red';
|
||||
}else{
|
||||
modelChatGPT.style.border = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function warn_GoogleGemini_APIKeyEmpty() {
|
||||
let apiKeyInput = document.getElementById('google_gemini_api_key');
|
||||
let btnFetchGoogleGeminiModels = document.getElementById('btnUpdateGoogleGeminiModels');
|
||||
let modelGoogleGemini = document.getElementById('google_gemini_model');
|
||||
if(apiKeyInput.value === ''){
|
||||
apiKeyInput.style.border = '2px solid red';
|
||||
btnFetchGoogleGeminiModels.disabled = true;
|
||||
modelGoogleGemini.disabled = true;
|
||||
modelGoogleGemini.selectedIndex = -1;
|
||||
modelGoogleGemini.style.border = '';
|
||||
}else{
|
||||
apiKeyInput.style.border = '';
|
||||
btnFetchGoogleGeminiModels.disabled = false;
|
||||
modelGoogleGemini.disabled = false;
|
||||
if((modelGoogleGemini.selectedIndex === -1)||(modelGoogleGemini.value === '')){
|
||||
modelGoogleGemini.style.border = '2px solid red';
|
||||
}else{
|
||||
modelGoogleGemini.style.border = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function warn_Ollama_HostEmpty() {
|
||||
let hostInput = document.getElementById('ollama_host');
|
||||
let btnFetchOllamaModels = document.getElementById('btnUpdateOllamaModels');
|
||||
let modelOllama = document.getElementById('ollama_model');
|
||||
if(hostInput.value === ''){
|
||||
hostInput.style.border = '2px solid red';
|
||||
btnFetchOllamaModels.disabled = true;
|
||||
modelOllama.disabled = true;
|
||||
modelOllama.selectedIndex = -1;
|
||||
modelOllama.style.border = '';
|
||||
}else{
|
||||
hostInput.style.border = '';
|
||||
btnFetchOllamaModels.disabled = false;
|
||||
modelOllama.disabled = false;
|
||||
if((modelOllama.selectedIndex === -1)||(modelOllama.value === '')){
|
||||
modelOllama.style.border = '2px solid red';
|
||||
}else{
|
||||
modelOllama.style.border = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function warn_OpenAIComp_HostEmpty() {
|
||||
let hostInput = document.getElementById('openai_comp_host');
|
||||
let btnUpdateOpenAICompModels = document.getElementById('btnUpdateOpenAICompModels');
|
||||
let modelOpenAIComp = document.getElementById('openai_comp_model');
|
||||
if(hostInput.value === ''){
|
||||
hostInput.style.border = '2px solid red';
|
||||
btnUpdateOpenAICompModels.disabled = true;
|
||||
modelOpenAIComp.disabled = true;
|
||||
modelOpenAIComp.selectedIndex = -1;
|
||||
modelOpenAIComp.style.border = '';
|
||||
}else{
|
||||
hostInput.style.border = '';
|
||||
btnUpdateOpenAICompModels.disabled = false;
|
||||
modelOpenAIComp.disabled = false;
|
||||
if((modelOpenAIComp.selectedIndex === -1)||(modelOpenAIComp.value === '')){
|
||||
modelOpenAIComp.style.border = '2px solid red';
|
||||
}else{
|
||||
modelOpenAIComp.style.border = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function warn_Anthropic_APIKeyEmpty() {
|
||||
let apiKeyInput = document.getElementById('anthropic_api_key');
|
||||
let btnFetchAnthropicModels = document.getElementById('btnUpdateAnthropicModels');
|
||||
let modelAnthropic = document.getElementById('anthropic_model');
|
||||
if(apiKeyInput.value === ''){
|
||||
apiKeyInput.style.border = '2px solid red';
|
||||
btnFetchAnthropicModels.disabled = true;
|
||||
modelAnthropic.disabled = true;
|
||||
modelAnthropic.selectedIndex = -1;
|
||||
modelAnthropic.style.border = '';
|
||||
}else{
|
||||
apiKeyInput.style.border = '';
|
||||
btnFetchAnthropicModels.disabled = false;
|
||||
modelAnthropic.disabled = false;
|
||||
if((modelAnthropic.selectedIndex === -1)||(modelAnthropic.value === '')){
|
||||
modelAnthropic.style.border = '2px solid red';
|
||||
}else{
|
||||
modelAnthropic.style.border = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function warn_Anthropic_VersionEmpty() {
|
||||
let versionInput = document.getElementById('anthropic_version');
|
||||
let btnFetchAnthropicModels = document.getElementById('btnUpdateAnthropicModels');
|
||||
let modelAnthropic = document.getElementById('anthropic_model');
|
||||
if(versionInput.value === ''){
|
||||
versionInput.style.border = '2px solid red';
|
||||
btnFetchAnthropicModels.disabled = true;
|
||||
modelAnthropic.disabled = true;
|
||||
modelAnthropic.selectedIndex = -1;
|
||||
modelAnthropic.style.border = '';
|
||||
}else{
|
||||
versionInput.style.border = '';
|
||||
btnFetchAnthropicModels.disabled = false;
|
||||
modelAnthropic.disabled = false;
|
||||
if((modelAnthropic.selectedIndex === -1)||(modelAnthropic.value === '')){
|
||||
modelAnthropic.style.border = '2px solid red';
|
||||
}else{
|
||||
modelAnthropic.style.border = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disable_MaxPromptLength(){
|
||||
let maxPromptLength = document.getElementById('max_prompt_length');
|
||||
let conntype_select = document.getElementById("connection_type");
|
||||
|
|
@ -322,39 +124,36 @@ function disable_MaxPromptLength(){
|
|||
maxPromptLength_tr.style.display = (maxPromptLength.disabled) ? 'none' : 'table-row';
|
||||
}
|
||||
|
||||
function disable_AddTags(){
|
||||
function disable_AddTags(prefs_opt){
|
||||
let add_tags = document.getElementById('add_tags');
|
||||
let conntype_select = document.getElementById("connection_type");
|
||||
add_tags.disabled = (conntype_select.value === "chatgpt_web");
|
||||
add_tags.checked = add_tags.disabled ? false : add_tags.checked;
|
||||
let add_tags_disabled = (getConnectionType(conntype_select.value, {api: prefs_opt.add_tags_use_specific_integration ? prefs_opt.add_tags_connection_type : ''}) === "chatgpt_web");
|
||||
// console.log('>>>>>>>>>>>>> add_tags_disabled: ' + add_tags_disabled);
|
||||
add_tags.checked = add_tags_disabled ? false : add_tags.checked;
|
||||
let add_tags_checked_original = add_tags.checked;
|
||||
if(!add_tags.checked){
|
||||
let add_tags_info_btn = document.getElementById('btnManageTagsInfo');
|
||||
add_tags_info_btn.disabled = 'disabled';
|
||||
}
|
||||
let add_tags_tr_elements = document.querySelectorAll('.add_tags_tr');
|
||||
add_tags_tr_elements.forEach(add_tags_tr => {
|
||||
add_tags_tr.style.display = (add_tags.disabled) ? 'none' : 'table-row';
|
||||
});
|
||||
let add_tags_warn_API_needed = document.getElementById('add_tags_warn_API_needed');
|
||||
add_tags_warn_API_needed.style.display = (add_tags_disabled) ? 'inline-block' : 'none';
|
||||
if(add_tags_checked_original != add_tags.checked){
|
||||
browser.storage.sync.set({add_tags: add_tags.checked});
|
||||
}
|
||||
}
|
||||
|
||||
function disable_SpamFilter(){
|
||||
function disable_SpamFilter(prefs_opt){
|
||||
let spamfilter = document.getElementById('spamfilter');
|
||||
let conntype_select = document.getElementById("connection_type");
|
||||
spamfilter.disabled = (conntype_select.value === "chatgpt_web");
|
||||
let spamfilter_disabled = (getConnectionType(conntype_select.value, {api: prefs_opt.spamfilter_use_specific_integration ? prefs_opt.spamfilter_connection_type : ''}) === "chatgpt_web");;
|
||||
let spamfilter_checked_original = spamfilter.checked;
|
||||
spamfilter.checked = spamfilter.disabled ? false : spamfilter.checked;
|
||||
spamfilter.checked = spamfilter_disabled ? false : spamfilter.checked;
|
||||
if(!spamfilter.checked){
|
||||
let spamfilter_info_btn = document.getElementById('btnManageSpamFilterInfo');
|
||||
spamfilter_info_btn.disabled = 'disabled';
|
||||
}
|
||||
let spamfilter_tr_elements = document.querySelectorAll('.spamfilter_tr');
|
||||
spamfilter_tr_elements.forEach(spamfilter_tr => {
|
||||
spamfilter_tr.style.display = (spamfilter.disabled) ? 'none' : 'table-row';
|
||||
});
|
||||
let spamfilter_warn_API_needed = document.getElementById('spamfilter_warn_API_needed');
|
||||
spamfilter_warn_API_needed.style.display = (spamfilter_disabled) ? 'inline-block' : 'none';
|
||||
if(spamfilter_checked_original != spamfilter.checked){
|
||||
browser.storage.sync.set({spamfilter: spamfilter.checked});
|
||||
}
|
||||
|
|
@ -383,21 +182,6 @@ async function disable_GetCalendarEvent(){
|
|||
wrong_sparks_text.style.display = (is_spark_present == 0) ? 'inline' : 'none';
|
||||
}
|
||||
|
||||
function loadOpenAICompConfigs(){
|
||||
let select_openai_comp_model = document.getElementById('openai_comp_services_shortcut');
|
||||
openAICompConfigs.forEach(config => {
|
||||
const option = document.createElement('option');
|
||||
option.value = config.id;
|
||||
option.text = config.name;
|
||||
select_openai_comp_model.appendChild(option);
|
||||
});
|
||||
}
|
||||
|
||||
function resetOpenAICompConfigs(){
|
||||
let select_openai_comp_model = document.getElementById('openai_comp_services_shortcut');
|
||||
select_openai_comp_model.value = 'custom';
|
||||
}
|
||||
|
||||
function resetMaxPromptLength(){
|
||||
let maxPromptLength = document.getElementById('max_prompt_length');
|
||||
maxPromptLength.value = prefs_default.max_prompt_length;
|
||||
|
|
@ -405,9 +189,15 @@ function resetMaxPromptLength(){
|
|||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
await injectConnectionUI({
|
||||
afterTrId: 'connection_ui_anchor',
|
||||
selectId: 'connection_type',
|
||||
taLog: taLog
|
||||
});
|
||||
|
||||
await restoreOptions();
|
||||
|
||||
permission_all_urls = await messenger.permissions.contains({ origins: ["<all_urls>"] })
|
||||
varConnectionUI.permission_all_urls = await messenger.permissions.contains({ origins: ["<all_urls>"] })
|
||||
|
||||
_isThunderbird128OrGreater = await isThunderbird128OrGreater();
|
||||
|
||||
|
|
@ -502,39 +292,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
openTab('/pages/get-task/mzta-get-task.html');
|
||||
});
|
||||
|
||||
document.getElementById('btnOpenAICompForceModel').addEventListener('click', () => {
|
||||
let modelName = prompt(browser.i18n.getMessage('OpenAIComp_force_model_ask')).trim();
|
||||
if ((modelName !== null) && (modelName !== undefined) && (modelName !== '')) {
|
||||
let select_openai_comp_model = document.getElementById('openai_comp_model');
|
||||
let option = document.createElement('option');
|
||||
option.value = modelName;
|
||||
option.text = modelName;
|
||||
select_openai_comp_model.appendChild(option);
|
||||
select_openai_comp_model.value = modelName;
|
||||
select_openai_comp_model.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('btnOpenAICompClearModelsList').addEventListener('click', () => {
|
||||
if (!confirm(browser.i18n.getMessage('OpenAIComp_ClearModelsList_Confirm'))) {
|
||||
return;
|
||||
}
|
||||
let select_openai_comp_model = document.getElementById('openai_comp_model');
|
||||
while (select_openai_comp_model.options.length > 0) {
|
||||
select_openai_comp_model.remove(0);
|
||||
}
|
||||
select_openai_comp_model.value = '';
|
||||
select_openai_comp_model.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
});
|
||||
|
||||
document.getElementById('btnGiveAllUrlsPermission_ollama_api').addEventListener('click', async () => {
|
||||
permission_all_urls = await messenger.permissions.request({ origins: ["<all_urls>"] });
|
||||
});
|
||||
|
||||
document.getElementById('btnGiveAllUrlsPermission_openai_comp_api').addEventListener('click', async () => {
|
||||
permission_all_urls = await messenger.permissions.request({ origins: ["<all_urls>"] });
|
||||
});
|
||||
|
||||
getChatGPTWebModelsList_HTML(ChatGPTWeb_models, 'chatgpt_web_models_list');
|
||||
document.querySelectorAll(".conntype_chatgpt_web_option").forEach(element => {
|
||||
element.addEventListener("click", () => {
|
||||
|
|
@ -544,330 +301,26 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
});
|
||||
|
||||
let prefs_opt = await browser.storage.sync.get({
|
||||
add_tags_use_specific_integration: prefs_default.add_tags_use_specific_integration,
|
||||
add_tags_connection_type: prefs_default.add_tags_connection_type,
|
||||
spamfilter_use_specific_integration: prefs_default.spamfilter_use_specific_integration,
|
||||
spamfilter_connection_type: prefs_default.spamfilter_connection_type,
|
||||
});
|
||||
|
||||
let conntype_select = document.getElementById("connection_type");
|
||||
conntype_select.addEventListener("change", showConnectionOptions);
|
||||
conntype_select.addEventListener("change", warn_ChatGPT_APIKeyEmpty);
|
||||
conntype_select.addEventListener("change", warn_Ollama_HostEmpty);
|
||||
conntype_select.addEventListener("change", warn_OpenAIComp_HostEmpty);
|
||||
conntype_select.addEventListener("change", warn_GoogleGemini_APIKeyEmpty);
|
||||
conntype_select.addEventListener("change", warn_Anthropic_APIKeyEmpty);
|
||||
conntype_select.addEventListener("change", warn_Anthropic_VersionEmpty);
|
||||
conntype_select.addEventListener("change", disable_AddTags);
|
||||
conntype_select.addEventListener("change", disable_SpamFilter);
|
||||
conntype_select.addEventListener("change", disable_MaxPromptLength);
|
||||
conntype_select.addEventListener("change", () => disable_AddTags(prefs_opt));
|
||||
conntype_select.addEventListener("change", () => disable_SpamFilter(prefs_opt));
|
||||
conntype_select.addEventListener("change", disable_GetCalendarEvent);
|
||||
document.getElementById("chatgpt_api_key").addEventListener("change", warn_ChatGPT_APIKeyEmpty);
|
||||
document.getElementById("ollama_host").addEventListener("change", warn_Ollama_HostEmpty);
|
||||
document.getElementById("openai_comp_host").addEventListener("change", warn_OpenAIComp_HostEmpty);
|
||||
document.getElementById("google_gemini_api_key").addEventListener("change", warn_GoogleGemini_APIKeyEmpty);
|
||||
document.getElementById("chatgpt_web_project").addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
document.getElementById("chatgpt_web_custom_gpt").addEventListener("input", validateCustomData_ChatGPTWeb);
|
||||
document.getElementById("anthropic_api_key").addEventListener("change", warn_Anthropic_APIKeyEmpty);
|
||||
document.getElementById("anthropic_version").addEventListener("change", warn_Anthropic_VersionEmpty);
|
||||
document.getElementById("openai_comp_host").addEventListener("input", resetOpenAICompConfigs);
|
||||
document.getElementById("openai_comp_chat_name").addEventListener("input", resetOpenAICompConfigs);
|
||||
document.getElementById("openai_comp_use_v1").addEventListener("input", resetOpenAICompConfigs);
|
||||
|
||||
|
||||
let prefs = await browser.storage.sync.get({chatgpt_web_model: '', chatgpt_model: '', ollama_model: '', openai_comp_model: '', google_gemini_model: '', anthropic_model: '', anthropic_version: '', chatgpt_win_height: 0, chatgpt_win_width: 0 });
|
||||
|
||||
// OpenAI API ChatGPT model fetching
|
||||
let select_chatgpt_model = document.getElementById('chatgpt_model');
|
||||
const chatgpt_option = document.createElement('option');
|
||||
chatgpt_option.value = prefs.chatgpt_model;
|
||||
chatgpt_option.text = prefs.chatgpt_model;
|
||||
select_chatgpt_model.appendChild(chatgpt_option);
|
||||
select_chatgpt_model.addEventListener("change", warn_ChatGPT_APIKeyEmpty);
|
||||
|
||||
document.getElementById('btnUpdateChatGPTModels').addEventListener('click', async () => {
|
||||
document.getElementById('chatgpt_model_fetch_loading').style.display = 'inline';
|
||||
let openai = new OpenAI(document.getElementById("chatgpt_api_key").value, '', true);
|
||||
openai.fetchModels().then((data) => {
|
||||
if(!data.ok){
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('chatgpt_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("ChatGPT_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("ChatGPT_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
taLog.log("ChatGPT models: " + JSON.stringify(data));
|
||||
data.response.forEach(model => {
|
||||
if (!Array.from(select_chatgpt_model.options).some(option => option.value === model.id)) {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.id;
|
||||
option.text = model.id;
|
||||
select_chatgpt_model.appendChild(option);
|
||||
}
|
||||
});
|
||||
document.getElementById('chatgpt_model_fetch_loading').style.display = 'none';
|
||||
});
|
||||
|
||||
warn_ChatGPT_APIKeyEmpty();
|
||||
});
|
||||
|
||||
// Google Gemini API model fetching
|
||||
let select_google_gemini_model = document.getElementById('google_gemini_model');
|
||||
const google_gemini_option = document.createElement('option');
|
||||
google_gemini_option.value = prefs.google_gemini_model;
|
||||
google_gemini_option.text = prefs.google_gemini_model;
|
||||
select_google_gemini_model.appendChild(google_gemini_option);
|
||||
select_google_gemini_model.addEventListener("change", warn_GoogleGemini_APIKeyEmpty);
|
||||
|
||||
document.getElementById('btnUpdateGoogleGeminiModels').addEventListener('click', async () => {
|
||||
document.getElementById('google_gemini_model_fetch_loading').style.display = 'inline';
|
||||
let google_gemini = new GoogleGemini(document.getElementById("google_gemini_api_key").value, '', true);
|
||||
google_gemini.fetchModels().then((data) => {
|
||||
if(!data.ok){
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('google_gemini_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("GoogleGemini_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("GoogleGemini_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
taLog.log("GoogleGemini models: " + JSON.stringify(data));
|
||||
data.response.forEach(model => {
|
||||
if (!Array.from(select_google_gemini_model.options).some(option => option.value === model.name.substring(model.name.lastIndexOf("/") + 1))) {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.name.substring(model.name.lastIndexOf("/") + 1);
|
||||
option.text = model.displayName;
|
||||
select_google_gemini_model.appendChild(option);
|
||||
}
|
||||
});
|
||||
document.getElementById('google_gemini_model_fetch_loading').style.display = 'none';
|
||||
});
|
||||
|
||||
warn_GoogleGemini_APIKeyEmpty();
|
||||
});
|
||||
|
||||
// Ollama API Model fetching
|
||||
let select_ollama_model = document.getElementById('ollama_model');
|
||||
const ollama_option = document.createElement('option');
|
||||
ollama_option.value = prefs.ollama_model;
|
||||
ollama_option.text = prefs.ollama_model;
|
||||
select_ollama_model.appendChild(ollama_option);
|
||||
select_ollama_model.addEventListener("change", warn_Ollama_HostEmpty);
|
||||
|
||||
document.getElementById('btnUpdateOllamaModels').addEventListener('click', async () => {
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'inline';
|
||||
let ollama = new Ollama(document.getElementById("ollama_host").value, true);
|
||||
try {
|
||||
let data = await ollama.fetchModels();
|
||||
if(!data){
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("Ollama_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("Ollama_Models_Error_fetching"));
|
||||
return;
|
||||
}
|
||||
if(!data.ok){
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("Ollama_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("Ollama_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
if(data.response.models.length == 0){
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("Ollama_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("Ollama_Models_Error_fetching")+": " + browser.i18n.getMessage("API_Models_Error_NoModels"));
|
||||
return;
|
||||
}
|
||||
taLog.log("Ollama models: " + JSON.stringify(data));
|
||||
data.response.models.forEach(model => {
|
||||
if (!Array.from(select_ollama_model.options).some(option => option.value === model.model)) {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.model;
|
||||
option.text = model.name + " (" + model.model + ")";
|
||||
select_ollama_model.appendChild(option);
|
||||
}
|
||||
});
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'none';
|
||||
} catch (error) {
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'none';
|
||||
taLog.error(browser.i18n.getMessage("Ollama_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("Ollama_Models_Error_fetching")+": " + error.message);
|
||||
}
|
||||
|
||||
warn_Ollama_HostEmpty();
|
||||
});
|
||||
|
||||
|
||||
// OpenAI Comp API Model fetching
|
||||
let select_openai_comp_model = document.getElementById('openai_comp_model');
|
||||
const openai_comp_option = document.createElement('option');
|
||||
openai_comp_option.value = prefs.openai_comp_model;
|
||||
openai_comp_option.text = prefs.openai_comp_model;
|
||||
select_openai_comp_model.appendChild(openai_comp_option);
|
||||
select_openai_comp_model.addEventListener("change", warn_OpenAIComp_HostEmpty);
|
||||
|
||||
document.getElementById('btnUpdateOpenAICompModels').addEventListener('click', async () => {
|
||||
document.getElementById('openai_comp_model_fetch_loading').style.display = 'inline';
|
||||
let openai_comp = new OpenAIComp(document.getElementById("openai_comp_host").value , null, document.getElementById("openai_comp_api_key").value, true, document.getElementById("openai_comp_use_v1").checked);
|
||||
openai_comp.fetchModels().then((data) => {
|
||||
if(!data.ok){
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('openai_comp_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("OpenAIComp_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("OpenAIComp_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
taLog.log("OpenAIComp models: " + JSON.stringify(data));
|
||||
data.response.forEach(model => {
|
||||
if (!Array.from(select_openai_comp_model.options).some(option => option.value === model.id)) {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.id;
|
||||
option.text = model.id;
|
||||
select_openai_comp_model.appendChild(option);
|
||||
}
|
||||
});
|
||||
document.getElementById('openai_comp_model_fetch_loading').style.display = 'none';
|
||||
});
|
||||
|
||||
warn_OpenAIComp_HostEmpty();
|
||||
});
|
||||
|
||||
// Anthropic API model fetching
|
||||
let select_anthropic_model = document.getElementById('anthropic_model');
|
||||
const anthropic_option = document.createElement('option');
|
||||
anthropic_option.value = prefs.anthropic_model;
|
||||
anthropic_option.text = prefs.anthropic_model;
|
||||
select_anthropic_model.appendChild(anthropic_option);
|
||||
select_anthropic_model.addEventListener("change", warn_Anthropic_APIKeyEmpty);
|
||||
select_anthropic_model.addEventListener("change", warn_Anthropic_VersionEmpty);
|
||||
|
||||
document.getElementById('btnUpdateAnthropicModels').addEventListener('click', async () => {
|
||||
document.getElementById('anthropic_model_fetch_loading').style.display = 'inline';
|
||||
let anthropic = new Anthropic(document.getElementById("anthropic_api_key").value, document.getElementById("anthropic_version").value, '');
|
||||
anthropic.fetchModels().then((data) => {
|
||||
if(!data.ok){
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('anthropic_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("Anthropic_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("Anthropic_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
taLog.log("Anthropic models: " + JSON.stringify(data));
|
||||
data.response.forEach(model => {
|
||||
const existingOption = Array.from(select_anthropic_model.options).find(option => option.value === model.id);
|
||||
if (existingOption) {
|
||||
existingOption.text = model.display_name + " (" + model.id + ")";
|
||||
} else {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.id;
|
||||
option.text = model.display_name + " (" + model.id + ")";
|
||||
select_anthropic_model.appendChild(option);
|
||||
}
|
||||
});
|
||||
document.getElementById('anthropic_model_fetch_loading').style.display = 'none';
|
||||
});
|
||||
|
||||
warn_Anthropic_APIKeyEmpty();
|
||||
});
|
||||
|
||||
showConnectionOptions();
|
||||
warn_ChatGPT_APIKeyEmpty();
|
||||
warn_Ollama_HostEmpty();
|
||||
warn_OpenAIComp_HostEmpty();
|
||||
warn_GoogleGemini_APIKeyEmpty();
|
||||
warn_Anthropic_APIKeyEmpty();
|
||||
warn_Anthropic_VersionEmpty();
|
||||
showConnectionOptions(conntype_select);
|
||||
disable_MaxPromptLength();
|
||||
disable_AddTags();
|
||||
disable_SpamFilter();
|
||||
disable_AddTags(prefs_opt);
|
||||
disable_SpamFilter(prefs_opt);
|
||||
disable_GetCalendarEvent();
|
||||
|
||||
const passwordField_chatgpt_api_key = document.getElementById('chatgpt_api_key');
|
||||
const toggleIcon_chatgpt_api_key = document.getElementById('toggle_chatgpt_api_key');
|
||||
const icon_img_chatgpt_api_key = document.getElementById('pwd-icon_chatgpt_api_key');
|
||||
|
||||
toggleIcon_chatgpt_api_key.addEventListener('click', () => {
|
||||
const type = passwordField_chatgpt_api_key.getAttribute('type') === 'password' ? 'text' : 'password';
|
||||
passwordField_chatgpt_api_key.setAttribute('type', type);
|
||||
|
||||
icon_img_chatgpt_api_key.src = type === 'password' ? "../images/pwd-show.png" : "../images/pwd-hide.png";
|
||||
});
|
||||
|
||||
const passwordField_google_gemini_api_key = document.getElementById('google_gemini_api_key');
|
||||
const toggleIcon_google_gemini_api_key = document.getElementById('toggle_google_gemini_api_key');
|
||||
const icon_img_google_gemini_api_key = document.getElementById('pwd-icon_google_gemini_api_key');
|
||||
|
||||
toggleIcon_google_gemini_api_key.addEventListener('click', () => {
|
||||
const type = passwordField_google_gemini_api_key.getAttribute('type') === 'password' ? 'text' : 'password';
|
||||
passwordField_google_gemini_api_key.setAttribute('type', type);
|
||||
|
||||
icon_img_google_gemini_api_key.src = type === 'password' ? "../images/pwd-show.png" : "../images/pwd-hide.png";
|
||||
});
|
||||
|
||||
const passwordField_openai_comp_api_key = document.getElementById('openai_comp_api_key');
|
||||
const toggleIcon_openai_comp_api_key = document.getElementById('toggle_openai_comp_api_key');
|
||||
const icon_img_openai_comp_api_key = document.getElementById('pwd-icon_openai_comp_api_key');
|
||||
|
||||
toggleIcon_openai_comp_api_key.addEventListener('click', () => {
|
||||
const type = passwordField_openai_comp_api_key.getAttribute('type') === 'password' ? 'text' : 'password';
|
||||
passwordField_openai_comp_api_key.setAttribute('type', type);
|
||||
|
||||
icon_img_openai_comp_api_key.src = type === 'password' ? "../images/pwd-show.png" : "../images/pwd-hide.png";
|
||||
});
|
||||
|
||||
const passwordField_anthropic_api_key = document.getElementById('anthropic_api_key');
|
||||
const toggleIcon_anthropic_api_key = document.getElementById('toggle_anthropic_api_key');
|
||||
const icon_img_anthropic_api_key = document.getElementById('pwd-icon_anthropic_api_key');
|
||||
|
||||
toggleIcon_anthropic_api_key.addEventListener('click', () => {
|
||||
const type = passwordField_anthropic_api_key.getAttribute('type') === 'password' ? 'text' : 'password';
|
||||
passwordField_anthropic_api_key.setAttribute('type', type);
|
||||
|
||||
icon_img_anthropic_api_key.src = type === 'password' ? "../images/pwd-show.png" : "../images/pwd-hide.png";
|
||||
});
|
||||
|
||||
const btnChatGPTWeb_Tab = document.getElementById('btnChatGPTWeb_Tab');
|
||||
btnChatGPTWeb_Tab.addEventListener('click', async () => {
|
||||
let prefs_mod = await browser.storage.sync.get({chatgpt_web_model: prefs_default.chatgpt_web_model, chatgpt_web_project: prefs_default.chatgpt_web_project, chatgpt_web_custom_gpt: prefs_default.chatgpt_web_custom_gpt});
|
||||
|
||||
let base_url = 'https://chatgpt.com';
|
||||
let model_opt = '';
|
||||
let webproject_set = false;
|
||||
|
||||
if((prefs_mod.chatgpt_web_model != '') && (prefs_mod.chatgpt_web_model != undefined)){
|
||||
model_opt = '?model=' + sanitizeChatGPTModelData(prefs_mod.chatgpt_web_model);
|
||||
}
|
||||
if((prefs_mod.chatgpt_web_project != '') && (prefs_mod.chatgpt_web_project != undefined)){
|
||||
base_url += sanitizeChatGPTWebCustomData(prefs_mod.chatgpt_web_project);
|
||||
webproject_set = true;
|
||||
}
|
||||
if(!webproject_set && (prefs_mod.chatgpt_web_custom_gpt != '') && (prefs_mod.chatgpt_web_custom_gpt != undefined)){
|
||||
base_url += sanitizeChatGPTWebCustomData(prefs_mod.chatgpt_web_custom_gpt);
|
||||
}
|
||||
browser.tabs.create({ url: base_url + model_opt });
|
||||
});
|
||||
document.getElementById('reset_max_prompt_length').addEventListener('click', resetMaxPromptLength);
|
||||
|
||||
browser.runtime.getPlatformInfo().then(info => {
|
||||
taLog.log("OS: " + info.os);
|
||||
|
|
@ -876,32 +329,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
});
|
||||
|
||||
loadOpenAICompConfigs();
|
||||
let select_openai_comp_services_shortcut = document.getElementById('openai_comp_services_shortcut');
|
||||
select_openai_comp_services_shortcut.addEventListener("change", () => {
|
||||
let selectedOption = select_openai_comp_services_shortcut.options[select_openai_comp_services_shortcut.selectedIndex];
|
||||
const config = openAICompConfigs.find(cfg => cfg.id === selectedOption.value);
|
||||
if (config) {
|
||||
if (!confirm(browser.i18n.getMessage('OpenAIComp_Configs_ConfirmApply', config.name))) {
|
||||
return;
|
||||
}
|
||||
document.getElementById('openai_comp_host').value = config.host || '';
|
||||
// Clear all options from the select except the first (placeholder) one
|
||||
const openaiCompModelSelect = document.getElementById('openai_comp_model');
|
||||
openaiCompModelSelect.value = '';
|
||||
while (openaiCompModelSelect.options.length > 0) {
|
||||
openaiCompModelSelect.remove(0);
|
||||
}
|
||||
document.getElementById('openai_comp_use_v1').checked = !!config.use_v1;
|
||||
document.getElementById('openai_comp_chat_name').value = config.chat_name || '';
|
||||
// Trigger change events if needed
|
||||
document.getElementById('openai_comp_host').dispatchEvent(new Event('change', { bubbles: true }));
|
||||
document.getElementById('openai_comp_model').dispatchEvent(new Event('change', { bubbles: true }));
|
||||
document.getElementById('openai_comp_use_v1').dispatchEvent(new Event('change', { bubbles: true }));
|
||||
document.getElementById('openai_comp_chat_name').dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('reset_max_prompt_length').addEventListener('click', resetMaxPromptLength);
|
||||
updateWarnings();
|
||||
|
||||
}, { once: true });
|
||||
|
|
|
|||
|
|
@ -7,6 +7,18 @@
|
|||
<body>
|
||||
<div id="miczBackPrefs"><a href="mzta-options.html">__MSG_backToOptionsText__</a></div>
|
||||
<div id="miczRelNotes"><h1>ThunderAI Release Notes</h1>
|
||||
<h2>Version 3.7.0 - ??/??/2025</h2>
|
||||
<ul>
|
||||
<li><i>[All APIs]</i> It's now possibile to define a list of tags to be used when autotagging received emails [<a href="https://github.com/micz/ThunderAI/issues/436">#436</a>]. The tags are are now shown in the information header in the AI API chat [<a href="https://github.com/micz/ThunderAI/issues/289">#289</a>].</li>
|
||||
<li><i>[All APIs]</i> The prompt id and name are now shown in the information header in the AI API chat [<a href="https://github.com/micz/ThunderAI/issues/436">#436</a>].</li>
|
||||
<li>Added the <i>{%mail_attachments_info%}</i> placeholder to retrieve the name, type and file size of the mail attachments [<a href="https://github.com/micz/ThunderAI/issues/446">#446</a>].</li>
|
||||
<li><i>[Google Gemini API]</i>Support for the thinkingBudget parameter has been added [<a href="https://github.com/micz/ThunderAI/issues/494">#494</a>].</li>
|
||||
<li><i>[OpenAI Comp API]</i> Added DeepSeek configuration [<a href="https://github.com/micz/ThunderAI/issues/486">#486</a>].</li>
|
||||
<li><i>[ChatGPT Web]</i> Added a message to explain to click on "Force completion" if the ChatGPT job is not done after 7 seconds [<a href="https://github.com/micz/ThunderAI/issues/419">#419</a>].</li>
|
||||
<li>Anthropic API renamed to Claude API [<a href="https://github.com/micz/ThunderAI/issues/510">#510</a>].</li>
|
||||
<li>Various code improvements and minor bugs fixed.</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
<h2>Version 3.6.1 - 23/08/2025</h2>
|
||||
<ul>
|
||||
<li><i>[OpenAI Comp API]</i> Perplexity configuration fixed [<a href="https://github.com/micz/ThunderAI/issues/461">#461</a>].</li>
|
||||
|
|
|
|||
118
pages/_lib/connection-ui.css
Normal file
118
pages/_lib/connection-ui.css
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
tr.conntype_chatgpt_api, tr.conntype_chatgpt_api2{
|
||||
background-color: rgb(185, 220, 252);
|
||||
}
|
||||
|
||||
tr.conntype_chatgpt_web, tr.conntype_chatgpt_web2{
|
||||
background-color: rgb(255, 209, 183);
|
||||
}
|
||||
|
||||
tr.conntype_ollama_api, tr.conntype_ollama_api2{
|
||||
background-color: rgb(177, 238, 169);
|
||||
}
|
||||
|
||||
tr.conntype_openai_comp_api, tr.conntype_openai_comp_api2{
|
||||
background-color: rgb(213, 169, 238);
|
||||
}
|
||||
|
||||
tr.conntype_google_gemini_api, tr.conntype_google_gemini_api2{
|
||||
background-color: rgb(233, 238, 169);
|
||||
}
|
||||
|
||||
tr.conntype_anthropic_api, tr.conntype_anthropic_api2{
|
||||
background-color: rgb(255, 168, 204);
|
||||
}
|
||||
|
||||
#chatgpt_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#google_gemini_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
textarea.option-textarea{
|
||||
width: -moz-available;
|
||||
height: 10em;
|
||||
}
|
||||
|
||||
.api_key-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.api_key-container input {
|
||||
width: -moz-available;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
input[type="text"], input[type="password"]{
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
input.option-input[type="text"]{
|
||||
width: -moz-available;
|
||||
}
|
||||
|
||||
.api_key-container .toggle-icon {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#ollama_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#openai_comp_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#anthropic_model_fetch_loading{
|
||||
display: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.conntype_chatgpt_web_option{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
span.opt_title{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
tr.conntype_chatgpt_api, tr.conntype_chatgpt_api2{
|
||||
background-color: rgb(0, 0, 58);
|
||||
}
|
||||
|
||||
tr.conntype_chatgpt_web,tr.conntype_chatgpt_web2{
|
||||
background-color: rgb(39, 11, 0);
|
||||
}
|
||||
|
||||
tr.conntype_ollama_api, tr.conntype_ollama_api2{
|
||||
background-color: rgb(7, 58, 0);
|
||||
}
|
||||
|
||||
tr.conntype_openai_comp_api, tr.conntype_openai_comp_api2{
|
||||
background-color: rgb(89, 20, 129);
|
||||
}
|
||||
|
||||
tr.conntype_google_gemini_api, tr.conntype_google_gemini_api2{
|
||||
background-color: rgb(72, 77, 3);
|
||||
}
|
||||
|
||||
tr.conntype_anthropic_api, tr.conntype_anthropic_api2{
|
||||
background-color: rgb(83, 0, 35);
|
||||
}
|
||||
|
||||
.api_key-container .toggle-icon img {
|
||||
filter: invert(1);
|
||||
}
|
||||
}
|
||||
1120
pages/_lib/connection-ui.js
Normal file
1120
pages/_lib/connection-ui.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -17,10 +17,16 @@
|
|||
margin: 40px auto;
|
||||
}
|
||||
|
||||
#addtags_excl_list{
|
||||
#addtags_excl_list, #add_tags_auto_uselist_list{
|
||||
width: 30em;
|
||||
}
|
||||
|
||||
#add_tags_auto_uselist_list:disabled {
|
||||
background-color: #eee;
|
||||
color: #888;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
#account_selector_container{
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -37,13 +43,53 @@
|
|||
background-color: #e9ffdf;
|
||||
}
|
||||
|
||||
.specific_integration{
|
||||
background-color: #dfeaff;
|
||||
}
|
||||
|
||||
tr.add_tags_auto_sub td,
|
||||
tr.specific_integration_sub td{
|
||||
padding-left: 0.8em !important;
|
||||
}
|
||||
|
||||
.specific_integration_sub{
|
||||
display: none;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.group td {
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.specific_integration_sub td:first-child {
|
||||
border-left: 10px solid #dfeaff;
|
||||
}
|
||||
|
||||
.specific_integration_sub td:last-child {
|
||||
border-right: 10px solid #dfeaff;
|
||||
}
|
||||
|
||||
#connection_ui_end td{
|
||||
height: 6px;
|
||||
background-color: #dfeaff;
|
||||
}
|
||||
|
||||
#connection_ui_end{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.btn_div{
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#addtags_info_additional_statements, #add_tags_auto_only_inbox_tr{
|
||||
#addtags_info_additional_statements, #add_tags_auto_only_inbox_tr, #add_tags_auto_uselist_tr{
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +108,7 @@ table#miczPrefs {
|
|||
|
||||
.section_title{
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
table#miczPrefs td{
|
||||
|
|
@ -149,4 +196,20 @@ table#miczPrefs tr:last-child td {
|
|||
.add_tags_auto{
|
||||
background-color: #415c35;
|
||||
}
|
||||
|
||||
.specific_integration{
|
||||
background-color: #2E3A4F;
|
||||
}
|
||||
|
||||
.specific_integration_sub td:first-child {
|
||||
border-left: 10px solid #2E3A4F;
|
||||
}
|
||||
|
||||
.specific_integration_sub td:last-child {
|
||||
border-right: 10px solid #2E3A4F;
|
||||
}
|
||||
|
||||
#connection_ui_end td{
|
||||
background-color: #2E3A4F;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>ThunderAI - __MSG_AddTags_PageTitle__</title>
|
||||
<link rel="stylesheet" href="mzta-add-tags.css">
|
||||
<link rel="stylesheet" href="../_lib/connection-ui.css">
|
||||
<link rel="icon" href="../../images/icon-16px.png">
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -13,8 +14,20 @@
|
|||
</div>
|
||||
<div class="addtags_table_title section_title">__MSG_AddTags_prompt_prefs_title__</div>
|
||||
<table id="miczPrefs">
|
||||
<tr class="add_tags_tr specific_integration">
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_use_specific_integration__</span>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_use_specific_integration" name="add_tags_use_specific_integration" class="option-input" />
|
||||
__MSG_prefs_OptionText_add_tags_use_specific_integration_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="connection_ui_anchor"></tr>
|
||||
<tr id="connection_ui_end"><td colspan="2"></td></tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_maxnum__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_maxnum__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="number" id="add_tags_maxnum" name="add_tags_maxnum" class="option-input" />
|
||||
|
|
@ -23,7 +36,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_exclusions_exact_match__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_exclusions_exact_match__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_exclusions_exact_match" name="add_tags_exclusions_exact_match" class="option-input" />
|
||||
|
|
@ -32,7 +45,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_hide_exclusions__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_hide_exclusions__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_hide_exclusions" name="add_tags_hide_exclusions" class="option-input" />
|
||||
|
|
@ -41,7 +54,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_first_uppercase__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_first_uppercase__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_first_uppercase" name="add_tags_first_uppercase" class="option-input" />
|
||||
|
|
@ -50,7 +63,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_force_lang__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_force_lang__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_force_lang" name="add_tags_force_lang" class="option-input" />
|
||||
|
|
@ -59,7 +72,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr add_tags_auto">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_auto__</span>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_auto__</span>
|
||||
<span class="infoline" id="add_tags_auto_infoline"><br>__MSG_prefs_OptionText_add_tags_auto_Info2__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
|
|
@ -68,8 +81,8 @@
|
|||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr add_tags_auto" id="add_tags_auto_only_inbox_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_auto_only_inbox__</span></td>
|
||||
<tr class="add_tags_tr add_tags_auto add_tags_auto_sub" id="add_tags_auto_only_inbox_tr">
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_auto_only_inbox__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_auto_only_inbox" name="add_tags_auto_only_inbox" class="option-input" />
|
||||
|
|
@ -77,8 +90,19 @@
|
|||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr add_tags_auto add_tags_auto_sub" id="add_tags_auto_uselist_tr">
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_auto_uselist__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_auto_uselist" name="add_tags_auto_uselist" class="option-input" />
|
||||
__MSG_prefs_OptionText_add_tags_auto_uselist_Info__
|
||||
<br/><span class="infoline">__MSG_prefs_OptionText_add_tags_auto_uselist_list_Info__</span>
|
||||
<br/><textarea id="add_tags_auto_uselist_list" class="option-input" rows="7"></textarea>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_context_menu__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_context_menu__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_context_menu" name="add_tags_context_menu" class="option-input" />
|
||||
|
|
@ -87,7 +111,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="add_tags_tr">
|
||||
<td><span>__MSG_prefs_OptionText_add_tags_auto_force_existing__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_add_tags_auto_force_existing__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="add_tags_auto_force_existing" name="add_tags_auto_force_existing" class="option-input" />
|
||||
|
|
@ -120,8 +144,8 @@
|
|||
<div id="account_selector_info"><span class="section_title">__MSG_AccountSelector_AutoTags__</span>
|
||||
<br><span class="infoline">__MSG_AccountSelector_AutoTags_infoline__</span></div>
|
||||
<div id="account_selector_checkboxes"></div>
|
||||
<button type="button" id="accounts_select_all">Select All</button>
|
||||
<button type="button" id="accounts_deselect_all">Deselect All</button>
|
||||
<button type="button" id="accounts_select_all">__MSG_SelectAll__</button>
|
||||
<button type="button" id="accounts_deselect_all">__MSG_DeselectAll__</button>
|
||||
</div>
|
||||
<script src="mzta-add-tags.js" type="module"></script>
|
||||
<script src="../../js/mzta-i18n.js"></script>
|
||||
|
|
|
|||
|
|
@ -18,17 +18,48 @@
|
|||
|
||||
import { prefs_default } from '../../options/mzta-options-default.js';
|
||||
import { taLogger } from '../../js/mzta-logger.js';
|
||||
import { getSpecialPrompts, setSpecialPrompts } from "../../js/mzta-prompts.js";
|
||||
import {
|
||||
getSpecialPrompts,
|
||||
setSpecialPrompts,
|
||||
loadPrompt,
|
||||
savePrompt,
|
||||
clearPromptAPI
|
||||
} from "../../js/mzta-prompts.js";
|
||||
import { getPlaceholders } from "../../js/mzta-placeholders.js";
|
||||
import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js";
|
||||
import { addTags_getExclusionList, addTags_setExclusionList } from "../../js/mzta-addatags-exclusion-list.js";
|
||||
import { getAccountsList } from "../../js/mzta-utils.js";
|
||||
import {
|
||||
addTags_getExclusionList,
|
||||
addTags_setExclusionList
|
||||
} from "../../js/mzta-addatags-exclusion-list.js";
|
||||
import {
|
||||
getAccountsList,
|
||||
normalizeStringList,
|
||||
isAPIKeyValue
|
||||
} from "../../js/mzta-utils.js";
|
||||
import {
|
||||
injectConnectionUI,
|
||||
updateWarnings,
|
||||
changeConnTypeRowColor
|
||||
} from "../_lib/connection-ui.js";
|
||||
|
||||
let autocompleteSuggestions = [];
|
||||
let taLog = new taLogger("mzta-addtags-page",true);
|
||||
let conntype_select_id = 'add_tags_connection_type';
|
||||
let model_prefix = 'add_tags_';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
try {
|
||||
await injectConnectionUI({
|
||||
afterTrId: 'connection_ui_anchor',
|
||||
tr_class: 'specific_integration_sub',
|
||||
selectId: conntype_select_id,
|
||||
modelId_prefix: model_prefix,
|
||||
no_chatgpt_web: true,
|
||||
taLog: taLog
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Failed to inject connection UI (add-tags)', e);
|
||||
}
|
||||
i18n.updateDocument();
|
||||
await restoreOptions();
|
||||
|
||||
|
|
@ -36,6 +67,47 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
element.addEventListener("change", saveOptions);
|
||||
});
|
||||
|
||||
document.querySelectorAll(".option-input-model").forEach(element => {
|
||||
element.addEventListener("change", updatePromptAPIInfo);
|
||||
});
|
||||
|
||||
let conntype_el = document.getElementById(conntype_select_id);
|
||||
let conntype_end_el = document.getElementById('connection_ui_end');
|
||||
|
||||
conntype_el.addEventListener('change', updatePromptAPIInfo);
|
||||
|
||||
let add_tags_use_specific_integration_el = document.getElementById('add_tags_use_specific_integration');
|
||||
let prefs_add_tags = await browser.storage.sync.get({ add_tags_enabled_accounts: [], connection_type: 'chatgpt_web' });
|
||||
if(prefs_add_tags.connection_type == 'chatgpt_web'){
|
||||
add_tags_use_specific_integration_el.checked = true;
|
||||
add_tags_use_specific_integration_el.dispatchEvent(new Event('change'));
|
||||
add_tags_use_specific_integration_el.disabled = true;
|
||||
}
|
||||
|
||||
let conntype_row = document.getElementById(conntype_select_id + '_tr');
|
||||
add_tags_use_specific_integration_el.addEventListener('change', (event) => {
|
||||
// console.log(">>>>>>>>>>>>> conntype_el.value: " + conntype_el.value);
|
||||
document.querySelectorAll(".specific_integration_sub").forEach(tr => {
|
||||
tr.style.display = event.target.checked && tr.classList.contains('conntype_' + conntype_el.value) ? 'table-row' : 'none';
|
||||
});
|
||||
conntype_el.style.display = event.target.checked ? 'table-row' : 'none';
|
||||
conntype_end_el.style.display = event.target.checked ? 'table-row' : 'none';
|
||||
changeConnTypeRowColor(conntype_row, conntype_el);
|
||||
if(!event.target.checked){
|
||||
clearPromptAPI('prompt_add_tags');
|
||||
}else{
|
||||
updatePromptAPIInfo();
|
||||
}
|
||||
});
|
||||
|
||||
// console.log(">>>>>>>>>>>>> conntype_el.value: " + conntype_el.value);
|
||||
document.querySelectorAll(".specific_integration_sub").forEach(tr => {
|
||||
tr.style.display = add_tags_use_specific_integration_el.checked && tr.classList.contains('conntype_' + conntype_el.value) ? 'table-row' : 'none';
|
||||
});
|
||||
document.getElementById(conntype_select_id + '_tr').style.display = add_tags_use_specific_integration_el.checked ? 'table-row' : 'none';
|
||||
conntype_end_el.style.display = add_tags_use_specific_integration_el.checked ? 'table-row' : 'none';
|
||||
changeConnTypeRowColor(conntype_row, conntype_el);
|
||||
|
||||
let addtags_textarea = document.getElementById('addtags_prompt_text');
|
||||
let addtags_save_btn = document.getElementById('btn_save_prompt');
|
||||
let addtags_reset_btn = document.getElementById('btn_reset_prompt');
|
||||
|
|
@ -57,14 +129,25 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
let add_tags_auto_only_inbox_tr = document.getElementById('add_tags_auto_only_inbox_tr');
|
||||
let account_selector_container = document.getElementById('account_selector_container');
|
||||
let add_tags_auto_infoline = document.getElementById('add_tags_auto_infoline');
|
||||
let add_tags_auto_uselist_tr = document.getElementById('add_tags_auto_uselist_tr');
|
||||
add_tags_auto_el.addEventListener('click', (event) => {
|
||||
add_tags_auto_only_inbox_tr.style.display = event.target.checked ? 'table-row' : 'none';
|
||||
account_selector_container.style.display = event.target.checked ? 'block' : 'none';
|
||||
add_tags_auto_infoline.style.display = event.target.checked ? 'inline' : 'none';
|
||||
add_tags_auto_uselist_tr.style.display = event.target.checked ? 'table-row' : 'none';
|
||||
|
||||
});
|
||||
add_tags_auto_only_inbox_tr.style.display = add_tags_auto_el.checked ? 'table-row' : 'none';
|
||||
account_selector_container.style.display = add_tags_auto_el.checked ? 'block' : 'none';
|
||||
add_tags_auto_infoline.style.display = add_tags_auto_el.checked ? 'inline' : 'none';
|
||||
add_tags_auto_uselist_tr.style.display = add_tags_auto_el.checked ? 'table-row' : 'none';
|
||||
|
||||
let add_tags_auto_uselist = document.getElementById('add_tags_auto_uselist');
|
||||
let add_tags_auto_uselist_list = document.getElementById('add_tags_auto_uselist_list');
|
||||
add_tags_auto_uselist.addEventListener('click', (event) => {
|
||||
add_tags_auto_uselist_list.disabled = !event.target.checked;
|
||||
});
|
||||
add_tags_auto_uselist_list.disabled = !add_tags_auto_uselist.checked;
|
||||
|
||||
addtags_reset_btn.addEventListener('click', () => {
|
||||
addtags_textarea.value = browser.i18n.getMessage('prompt_add_tags_full_text');
|
||||
|
|
@ -89,6 +172,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
|
||||
document.getElementById('add_tags_maxnum').addEventListener('change', updateAdditionalPromptStatements);
|
||||
document.getElementById('add_tags_force_lang').addEventListener('change', updateAdditionalPromptStatements);
|
||||
document.getElementById('add_tags_auto_uselist').addEventListener('change', updateAdditionalPromptStatements);
|
||||
document.getElementById('add_tags_auto_uselist_list').addEventListener('change', updateAdditionalPromptStatements);
|
||||
|
||||
updateAdditionalPromptStatements();
|
||||
|
||||
|
|
@ -113,8 +198,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
|
||||
excl_list_save_btn.addEventListener('click', () => {
|
||||
let excl_array_new = excl_list_textarea.value.split(/[\n,]+/);
|
||||
excl_array_new = Array.from(new Set(excl_array_new.map(item => item.trim().toLowerCase()))).sort();
|
||||
let excl_array_new = normalizeStringList(excl_list_textarea.value, 2);
|
||||
addTags_setExclusionList(excl_array_new);
|
||||
excl_list_save_btn.disabled = true;
|
||||
excl_list_textarea.value = excl_array_new.join('\n');
|
||||
|
|
@ -136,7 +220,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
accountsContainer.appendChild(document.createElement('br'));
|
||||
});
|
||||
|
||||
let prefs_add_tags = await browser.storage.sync.get({ add_tags_enabled_accounts: [] });
|
||||
let add_tags_enabled_accounts = prefs_add_tags.add_tags_enabled_accounts;
|
||||
taLog.log("add_tags_enabled_accounts = " + JSON.stringify(add_tags_enabled_accounts) + ".");
|
||||
document.querySelectorAll('.accountCheckbox').forEach(checkbox => {
|
||||
|
|
@ -175,23 +258,31 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
checkboxes.forEach(checkbox => checkbox.checked = false);
|
||||
});
|
||||
|
||||
updateWarnings(model_prefix);
|
||||
});
|
||||
|
||||
|
||||
async function updateAdditionalPromptStatements(){
|
||||
let prefs_ = await browser.storage.sync.get({add_tags_maxnum: 3, add_tags_force_lang: true, default_chatgpt_lang: ''});
|
||||
let prefs_ = await browser.storage.sync.get({
|
||||
add_tags_maxnum: prefs_default.add_tags_maxnum,
|
||||
add_tags_force_lang: prefs_default.add_tags_force_lang,
|
||||
default_chatgpt_lang: prefs_default.default_chatgpt_lang,
|
||||
add_tags_auto_uselist: prefs_default.add_tags_auto_uselist,
|
||||
add_tags_auto_uselist_list: prefs_default.add_tags_auto_uselist_list,
|
||||
});
|
||||
let el_tag_limit = document.getElementById('addtags_info_additional_statements');
|
||||
if((prefs_.add_tags_maxnum > 0)||(prefs_.add_tags_force_lang && prefs_.default_chatgpt_lang !== '')){
|
||||
if((prefs_.add_tags_maxnum > 0)||(prefs_.add_tags_force_lang && prefs_.default_chatgpt_lang !== '')||(prefs_.add_tags_auto_uselist && prefs_.add_tags_auto_uselist_list.trim() !== '')){
|
||||
el_tag_limit.textContent = browser.i18n.getMessage("addtags_info_additional_statements") + " \""
|
||||
if(prefs_.add_tags_maxnum > 0){
|
||||
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + prefs_.add_tags_maxnum +"."
|
||||
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + prefs_.add_tags_maxnum +". "
|
||||
}
|
||||
if(prefs_.add_tags_force_lang && prefs_.default_chatgpt_lang !== ''){
|
||||
if(prefs_.add_tags_maxnum > 0){
|
||||
el_tag_limit.textContent += " "
|
||||
}
|
||||
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_force_lang") + " " + prefs_.default_chatgpt_lang + "."
|
||||
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_force_lang") + " " + prefs_.default_chatgpt_lang + ". "
|
||||
}
|
||||
if(prefs_.add_tags_auto_uselist && prefs_.add_tags_auto_uselist_list.trim() !== ''){
|
||||
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_use_list") + ": " + prefs_.add_tags_auto_uselist_list + ".";
|
||||
}
|
||||
el_tag_limit.textContent = el_tag_limit.textContent.trim();
|
||||
el_tag_limit.textContent += "\".";
|
||||
el_tag_limit.style.display = 'block';
|
||||
}else{
|
||||
|
|
@ -199,6 +290,19 @@ async function updateAdditionalPromptStatements(){
|
|||
}
|
||||
}
|
||||
|
||||
async function updatePromptAPIInfo(){
|
||||
let conntype = document.getElementById(conntype_select_id).value;
|
||||
let model_value = conntype.substring(0, conntype.length - 4) + '_model';
|
||||
let model = document.getElementById(model_prefix + model_value).value;
|
||||
// console.log(">>>>>>>>>>> updatePromptAPIInfo: conntype: " + conntype + " - model: " + model + " - model_value: " + model_value);
|
||||
let add_tags_prompt = await loadPrompt('prompt_add_tags');
|
||||
// console.log(">>>>>>>>>>> updatePromptAPIInfo: BEFORE add_tags_prompt: " + JSON.stringify(add_tags_prompt));
|
||||
add_tags_prompt.api = conntype;
|
||||
add_tags_prompt.model = model;
|
||||
// console.log(">>>>>>>>>>> updatePromptAPIInfo: AFTER add_tags_prompt: " + JSON.stringify(add_tags_prompt));
|
||||
await savePrompt(add_tags_prompt);
|
||||
}
|
||||
|
||||
|
||||
// Methods to manage options, derived from: /options/mzta-options.js
|
||||
|
||||
|
|
@ -206,7 +310,7 @@ function saveOptions(e) {
|
|||
e.preventDefault();
|
||||
let options = {};
|
||||
let element = e.target;
|
||||
|
||||
// console.log(">>>>>>>>>> Saving option: " + element.id + " = " + element.value);
|
||||
switch (element.type) {
|
||||
case 'checkbox':
|
||||
options[element.id] = element.checked;
|
||||
|
|
@ -219,8 +323,15 @@ function saveOptions(e) {
|
|||
options[element.id] = element.value.trim();
|
||||
break;
|
||||
case 'select-one':
|
||||
// console.log(">>>>>>>>>> Saving option [select-one]: " + element.id + " = " + element.value);
|
||||
options[element.id] = element.value;
|
||||
break;
|
||||
case 'textarea':
|
||||
if(element.id === 'add_tags_auto_uselist_list') {
|
||||
element.value = normalizeStringList(element.value, 1);
|
||||
}
|
||||
options[element.id] = normalizeStringList(element.value);
|
||||
break;
|
||||
default:
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
}
|
||||
|
|
@ -231,7 +342,7 @@ function saveOptions(e) {
|
|||
async function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelectorAll(".option-input").forEach(element => {
|
||||
taLog.log("Options restoring " + element.id + " = " + (element.id=="chatgpt_api_key" || element.id=="openai_comp_api_key" ? "****************" : result[element.id]));
|
||||
taLog.log("Options restoring " + element.id + " = " + (isAPIKeyValue(element.id) ? "****************" : result[element.id]));
|
||||
switch (element.type) {
|
||||
case 'checkbox':
|
||||
element.checked = result[element.id] || false;
|
||||
|
|
@ -243,20 +354,31 @@ async function restoreOptions() {
|
|||
element.value = result[element.id] ?? default_number_value;
|
||||
break;
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'password':
|
||||
let default_text_value = '';
|
||||
if(element.id == 'default_chatgpt_lang') default_text_value = prefs_default.default_chatgpt_lang;
|
||||
if(element.id === 'add_tags_auto_uselist_list') {
|
||||
result[element.id] = normalizeStringList(result[element.id], 1);
|
||||
}
|
||||
element.value = result[element.id] || default_text_value;
|
||||
break;
|
||||
default:
|
||||
if (element.tagName === 'SELECT') {
|
||||
let default_select_value = '';
|
||||
if(element.id == 'reply_type') default_select_value = 'reply_all';
|
||||
if(element.id == 'connection_type') default_select_value = 'chatgpt_web';
|
||||
element.value = result[element.id] || default_select_value;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
let default_select_value = '';
|
||||
const restoreValue = result[element.id] || default_select_value;
|
||||
// Check if option exists
|
||||
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
|
||||
// If it doesn't exist and restoreValue is not empty, create it
|
||||
if (!optionExists && restoreValue !== '') {
|
||||
let newOption = new Option(restoreValue, restoreValue);
|
||||
element.add(newOption);
|
||||
}
|
||||
// Set value
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
}else{
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
}
|
||||
|
|
@ -266,4 +388,4 @@ async function restoreOptions() {
|
|||
|
||||
let getting = await browser.storage.sync.get(prefs_default);
|
||||
setCurrentChoice(getting);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import { taLogger } from '../../js/mzta-logger.js';
|
|||
import { getSpecialPrompts, setSpecialPrompts } from "../../js/mzta-prompts.js";
|
||||
import { getPlaceholders } from "../../js/mzta-placeholders.js";
|
||||
import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js";
|
||||
import { isAPIKeyValue } from "../../js/mzta-utils.js";
|
||||
|
||||
let autocompleteSuggestions = [];
|
||||
let taLog = new taLogger("mzta-get-calendar-event-page",true);
|
||||
|
|
@ -110,7 +111,7 @@ function saveOptions(e) {
|
|||
async function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelectorAll(".option-input").forEach(element => {
|
||||
taLog.log("Options restoring " + element.id + " = " + (element.id=="chatgpt_api_key" || element.id=="openai_comp_api_key" ? "****************" : result[element.id]));
|
||||
taLog.log("Options restoring " + element.id + " = " + (isAPIKeyValue(element.id) ? "****************" : result[element.id]));
|
||||
switch (element.type) {
|
||||
case 'checkbox':
|
||||
element.checked = result[element.id] || false;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import { taLogger } from '../../js/mzta-logger.js';
|
|||
import { getSpecialPrompts, setSpecialPrompts } from "../../js/mzta-prompts.js";
|
||||
import { getPlaceholders } from "../../js/mzta-placeholders.js";
|
||||
import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js";
|
||||
import { isAPIKeyValue } from "../../js/mzta-utils.js";
|
||||
|
||||
let autocompleteSuggestions = [];
|
||||
let taLog = new taLogger("mzta-get-calendar-event-page",true);
|
||||
|
|
@ -110,7 +111,7 @@ function saveOptions(e) {
|
|||
async function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelectorAll(".option-input").forEach(element => {
|
||||
taLog.log("Options restoring " + element.id + " = " + (element.id=="chatgpt_api_key" || element.id=="openai_comp_api_key" ? "****************" : result[element.id]));
|
||||
taLog.log("Options restoring " + element.id + " = " + (isAPIKeyValue(element.id) ? "****************" : result[element.id]));
|
||||
switch (element.type) {
|
||||
case 'checkbox':
|
||||
element.checked = result[element.id] || false;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,15 @@
|
|||
*/
|
||||
|
||||
import { taLogger } from '../../js/mzta-logger.js';
|
||||
import { prefs_default } from '../../options/mzta-options-default.js';
|
||||
|
||||
let taLog = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
let prefs = await browser.storage.sync.get({do_debug: false, connection_type: 'chatgpt_web'});
|
||||
let prefs = await browser.storage.sync.get({
|
||||
do_debug: prefs_default.do_debug,
|
||||
connection_type: prefs_default.connection_type,
|
||||
});
|
||||
taLog = new taLogger("mzta-popup",prefs.do_debug);
|
||||
i18n.updateDocument();
|
||||
if(prefs.connection_type === 'chatgpt_web'){
|
||||
|
|
@ -52,9 +56,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
if(granted){
|
||||
document.getElementById("anthropic_api_permission").style.display = "none";
|
||||
document.getElementById("integration_permission_ok").style.display = "block";
|
||||
taLog.log("Anthropic API permission granted");
|
||||
taLog.log("Claude API permission granted");
|
||||
}else{
|
||||
taLog.log("Anthropic API web permission denied");
|
||||
taLog.log("Claude API web permission denied");
|
||||
}
|
||||
});
|
||||
document.getElementById("integration_permission_ok").addEventListener("click", async () => {
|
||||
|
|
@ -62,4 +66,4 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
}
|
||||
}
|
||||
}, { once: true });
|
||||
}, { once: true });
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ table#miczPrefs {
|
|||
|
||||
.section_title{
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
table#miczPrefs td{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>ThunderAI - __MSG_SpamFilter_PageTitle__</title>
|
||||
<link rel="stylesheet" href="mzta-spamfilter.css">
|
||||
<link rel="stylesheet" href="../_lib/connection-ui.css">
|
||||
<link rel="icon" href="../../images/icon-16px.png">
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -13,8 +14,20 @@
|
|||
</div>
|
||||
<div class="spamfilter_table_title section_title">__MSG_SpamFilter_prompt_prefs_title__</div>
|
||||
<table id="miczPrefs">
|
||||
<tr class="spamfilter_tr specific_integration">
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_use_specific_integration__</span>
|
||||
</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="spamfilter_use_specific_integration" name="spamfilter_use_specific_integration" class="option-input" />
|
||||
__MSG_prefs_OptionText_spamfilter_use_specific_integration_Info__
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="connection_ui_anchor"></tr>
|
||||
<tr id="connection_ui_end"><td colspan="2"></td></tr>
|
||||
<tr class="spamfilter_tr">
|
||||
<td><span>__MSG_prefs_OptionText_spamfilter_threshold__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_spamfilter_threshold__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="number" id="spamfilter_threshold" name="spamfilter_threshold" min="0" max="100" class="option-input" /><span id="spamfilter_threshold_too_low">__MSG_spamfilter_threshold_too_low__</span>
|
||||
|
|
@ -23,7 +36,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr class="spamfilter_tr">
|
||||
<td><span>__MSG_prefs_OptionText_spamfilter_context_menu__</span></td>
|
||||
<td><span class="opt_title">__MSG_prefs_OptionText_spamfilter_context_menu__</span></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="spamfilter_context_menu" name="spamfilter_context_menu" class="option-input" />
|
||||
|
|
@ -48,8 +61,8 @@
|
|||
<div id="account_selector_info"><span class="section_title">__MSG_AccountSelector_Spamfilter__</span>
|
||||
<br><span class="infoline">__MSG_AccountSelector_AutoTags_infoline__</span></div>
|
||||
<div id="account_selector_checkboxes"></div>
|
||||
<button type="button" id="accounts_select_all">Select All</button>
|
||||
<button type="button" id="accounts_deselect_all">Deselect All</button>
|
||||
<button type="button" id="accounts_select_all">__MSG_SelectAll__</button>
|
||||
<button type="button" id="accounts_deselect_all">__MSG_DeselectAll__</button>
|
||||
</div>
|
||||
<div id="spamfitler_reports_container">
|
||||
<h2>__MSG_SpamReport_Title__</h2>
|
||||
|
|
@ -74,4 +87,4 @@
|
|||
<script src="mzta-spamfilter.js" type="module"></script>
|
||||
<script src="../../js/mzta-i18n.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -18,18 +18,39 @@
|
|||
|
||||
import { prefs_default } from '../../options/mzta-options-default.js';
|
||||
import { taLogger } from '../../js/mzta-logger.js';
|
||||
import { getSpecialPrompts, setSpecialPrompts } from "../../js/mzta-prompts.js";
|
||||
import { getSpecialPrompts, setSpecialPrompts, loadPrompt, savePrompt, clearPromptAPI } from "../../js/mzta-prompts.js";
|
||||
import { getPlaceholders } from "../../js/mzta-placeholders.js";
|
||||
import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js";
|
||||
import { taSpamReport } from '../../js/mzta-spamreport.js';
|
||||
import { getAccountsList } from "../../js/mzta-utils.js";
|
||||
import { getAccountsList, isAPIKeyValue } from "../../js/mzta-utils.js";
|
||||
import {
|
||||
injectConnectionUI,
|
||||
updateWarnings,
|
||||
changeConnTypeRowColor
|
||||
} from "../_lib/connection-ui.js";
|
||||
|
||||
let autocompleteSuggestions = [];
|
||||
let taLog = new taLogger("mzta-spamfilter-page",true);
|
||||
taSpamReport.logger = taLog;
|
||||
|
||||
let conntype_select_id = 'spamfilter_connection_type';
|
||||
let model_prefix = 'spamfilter_';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
try {
|
||||
await injectConnectionUI({
|
||||
afterTrId: 'connection_ui_anchor',
|
||||
tr_class: 'specific_integration_sub',
|
||||
selectId: conntype_select_id,
|
||||
modelId_prefix: model_prefix,
|
||||
no_chatgpt_web: true,
|
||||
taLog: taLog
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Failed to inject connection UI (spamfilter)', e);
|
||||
}
|
||||
|
||||
i18n.updateDocument();
|
||||
await restoreOptions();
|
||||
|
||||
|
|
@ -40,6 +61,48 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
document.getElementById("spamfilter_threshold").addEventListener("input", check_spamfilter_threshold);
|
||||
check_spamfilter_threshold({target: document.getElementById("spamfilter_threshold")});
|
||||
|
||||
// Bind prompt API updates to connection type and model selects
|
||||
document.querySelectorAll(".option-input-model").forEach(element => {
|
||||
element.addEventListener("change", updatePromptAPIInfo);
|
||||
});
|
||||
const conntype_el = document.getElementById(conntype_select_id);
|
||||
if (conntype_el) {
|
||||
conntype_el.addEventListener('change', updatePromptAPIInfo);
|
||||
const conntype_row = document.getElementById(conntype_select_id + '_tr');
|
||||
if (conntype_row) changeConnTypeRowColor(conntype_row, conntype_el);
|
||||
}
|
||||
|
||||
// Specific integration toggle behavior
|
||||
const spamfilter_use_specific_integration_el = document.getElementById('spamfilter_use_specific_integration');
|
||||
let prefs_spamfilter_init = await browser.storage.sync.get({ spamfilter_enabled_accounts: [], connection_type: 'chatgpt_web' });
|
||||
if(prefs_spamfilter_init.connection_type == 'chatgpt_web'){
|
||||
spamfilter_use_specific_integration_el.checked = true;
|
||||
spamfilter_use_specific_integration_el.dispatchEvent(new Event('change'));
|
||||
spamfilter_use_specific_integration_el.disabled = true;
|
||||
}
|
||||
const conntype_end_el = document.getElementById('connection_ui_end');
|
||||
const conntype_row = document.getElementById(conntype_select_id + '_tr');
|
||||
spamfilter_use_specific_integration_el.addEventListener('change', async (event) => {
|
||||
document.querySelectorAll('.specific_integration_sub').forEach(tr => {
|
||||
tr.style.display = event.target.checked && tr.classList.contains('conntype_' + conntype_el.value) ? 'table-row' : 'none';
|
||||
});
|
||||
if (conntype_row) conntype_row.style.display = event.target.checked ? 'table-row' : 'none';
|
||||
if (conntype_end_el) conntype_end_el.style.display = event.target.checked ? 'table-row' : 'none';
|
||||
if(!event.target.checked){
|
||||
await clearPromptAPI('prompt_spamfilter');
|
||||
}else{
|
||||
updatePromptAPIInfo();
|
||||
}
|
||||
if (conntype_row) changeConnTypeRowColor(conntype_row, conntype_el);
|
||||
});
|
||||
|
||||
// Initialize visibility per current toggle value
|
||||
document.querySelectorAll('.specific_integration_sub').forEach(tr => {
|
||||
tr.style.display = spamfilter_use_specific_integration_el.checked && tr.classList.contains('conntype_' + conntype_el.value) ? 'table-row' : 'none';
|
||||
});
|
||||
if (conntype_row) conntype_row.style.display = spamfilter_use_specific_integration_el.checked ? 'table-row' : 'none';
|
||||
if (conntype_end_el) conntype_end_el.style.display = spamfilter_use_specific_integration_el.checked ? 'table-row' : 'none';
|
||||
|
||||
let spamfilter_textarea = document.getElementById('spamfilter_prompt_text');
|
||||
let spamfilter_save_btn = document.getElementById('btn_save_prompt');
|
||||
let spamfilter_reset_btn = document.getElementById('btn_reset_prompt');
|
||||
|
|
@ -136,6 +199,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
});
|
||||
|
||||
loadSpamReport();
|
||||
updateWarnings(model_prefix);
|
||||
// Sync prompt API/model once on load
|
||||
updatePromptAPIInfo();
|
||||
});
|
||||
|
||||
function check_spamfilter_threshold(event) {
|
||||
|
|
@ -165,6 +231,21 @@ async function loadSpamReport(){
|
|||
}
|
||||
}
|
||||
|
||||
async function updatePromptAPIInfo(){
|
||||
const conntypeEl = document.getElementById(conntype_select_id);
|
||||
if (!conntypeEl || !conntypeEl.value) return;
|
||||
const conntype = conntypeEl.value;
|
||||
const model_value = conntype.substring(0, conntype.length - 4) + '_model';
|
||||
const modelEl = document.getElementById(model_prefix + model_value);
|
||||
if (!modelEl) return;
|
||||
const model = modelEl.value;
|
||||
let spamfilter_prompt = await loadPrompt('prompt_spamfilter');
|
||||
if (!spamfilter_prompt) return;
|
||||
spamfilter_prompt.api = conntype;
|
||||
spamfilter_prompt.model = model;
|
||||
await savePrompt(spamfilter_prompt);
|
||||
}
|
||||
|
||||
// Function to populate the table
|
||||
function populateTable(data) {
|
||||
const tableBody = document.getElementById("report_data_body");
|
||||
|
|
@ -228,13 +309,16 @@ function saveOptions(e) {
|
|||
case 'number':
|
||||
options[element.id] = element.valueAsNumber;
|
||||
break;
|
||||
case 'text':
|
||||
case 'password':
|
||||
case 'text':
|
||||
case 'password':
|
||||
options[element.id] = element.value.trim();
|
||||
break;
|
||||
case 'select-one':
|
||||
options[element.id] = element.value;
|
||||
break;
|
||||
case 'textarea':
|
||||
options[element.id] = element.value;
|
||||
break;
|
||||
default:
|
||||
console.error("[ThunderAI] Unhandled input type:", element.type);
|
||||
}
|
||||
|
|
@ -245,7 +329,7 @@ function saveOptions(e) {
|
|||
async function restoreOptions() {
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelectorAll(".option-input").forEach(element => {
|
||||
taLog.log("Options restoring " + element.id + " = " + (element.id=="chatgpt_api_key" || element.id=="openai_comp_api_key" ? "****************" : result[element.id]));
|
||||
taLog.log("Options restoring " + element.id + " = " + (isAPIKeyValue(element.id) ? "****************" : result[element.id]));
|
||||
switch (element.type) {
|
||||
case 'checkbox':
|
||||
element.checked = result[element.id] || false;
|
||||
|
|
@ -257,6 +341,7 @@ async function restoreOptions() {
|
|||
element.value = result[element.id] ?? default_number_value;
|
||||
break;
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'password':
|
||||
let default_text_value = '';
|
||||
if(element.id == 'default_chatgpt_lang') default_text_value = prefs_default.default_chatgpt_lang;
|
||||
|
|
@ -267,7 +352,15 @@ async function restoreOptions() {
|
|||
let default_select_value = '';
|
||||
if(element.id == 'reply_type') default_select_value = 'reply_all';
|
||||
if(element.id == 'connection_type') default_select_value = 'chatgpt_web';
|
||||
element.value = result[element.id] || default_select_value;
|
||||
if(element.id == 'spamfilter_connection_type') default_select_value = 'chatgpt_api';
|
||||
const restoreValue = result[element.id] || default_select_value;
|
||||
// Ensure option exists before restoring
|
||||
let optionExists = Array.from(element.options).some(opt => opt.value === restoreValue);
|
||||
if (!optionExists && restoreValue !== '') {
|
||||
let newOption = new Option(restoreValue, restoreValue);
|
||||
element.add(newOption);
|
||||
}
|
||||
element.value = restoreValue;
|
||||
if (element.value === '') {
|
||||
element.selectedIndex = -1;
|
||||
}
|
||||
|
|
@ -280,4 +373,4 @@ async function restoreOptions() {
|
|||
|
||||
let getting = await browser.storage.sync.get(prefs_default);
|
||||
setCurrentChoice(getting);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,17 @@
|
|||
|
||||
import { prefs_default } from "../options/mzta-options-default.js";
|
||||
import { taLogger } from "../js/mzta-logger.js";
|
||||
import { checkSparksPresence } from "../js/mzta-utils.js";
|
||||
import {
|
||||
checkSparksPresence,
|
||||
checkAPIIntegration,
|
||||
} from "../js/mzta-utils.js";
|
||||
|
||||
let menuSendImmediately = false;
|
||||
let taLog = console;
|
||||
let connection_type = 'chatgpt_web';
|
||||
let add_tags = false;
|
||||
let add_tags_use_specific_integration = false;
|
||||
let add_tags_connection_type = '';
|
||||
let get_calendar_event = false;
|
||||
let get_task = false;
|
||||
let _ok_sparks = false;
|
||||
|
|
@ -31,7 +36,16 @@ let tabType;
|
|||
let num_special_menu_items = 0;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
let prefs = await browser.storage.sync.get({do_debug: prefs_default.do_debug, dynamic_menu_force_enter: prefs_default.dynamic_menu_force_enter, add_tags: prefs_default.add_tags, get_calendar_event: prefs_default.get_calendar_event, get_task: prefs_default.get_task, connection_type: prefs_default.connection_type});
|
||||
let prefs = await browser.storage.sync.get({
|
||||
do_debug: prefs_default.do_debug,
|
||||
dynamic_menu_force_enter: prefs_default.dynamic_menu_force_enter,
|
||||
add_tags: prefs_default.add_tags,
|
||||
add_tags_use_specific_integration: prefs_default.add_tags_use_specific_integration,
|
||||
add_tags_connection_type: prefs_default.add_tags_connection_type,
|
||||
get_calendar_event: prefs_default.get_calendar_event,
|
||||
get_task: prefs_default.get_task,
|
||||
connection_type: prefs_default.connection_type
|
||||
});
|
||||
taLog = new taLogger("mzta-popup",prefs.do_debug);
|
||||
i18n.updateDocument();
|
||||
let reponse = await browser.runtime.sendMessage({command: "popup_menu_ready"});
|
||||
|
|
@ -42,10 +56,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
let _prompts_data = reponse.lastShortcutPromptsData;
|
||||
taLog.log("_prompts_data: " + JSON.stringify(_prompts_data));
|
||||
let active_prompts = filterPromptsForTab(_prompts_data, filtering);
|
||||
active_prompts.forEach(item => {
|
||||
item.label = new DOMParser().parseFromString(item.label, "text/html").documentElement.textContent;
|
||||
});
|
||||
taLog.log("active_prompts: " + JSON.stringify(active_prompts));
|
||||
menuSendImmediately = prefs.dynamic_menu_force_enter;
|
||||
connection_type = prefs.connection_type;
|
||||
add_tags = prefs.add_tags;
|
||||
add_tags_use_specific_integration = prefs.add_tags_use_specific_integration;
|
||||
add_tags_connection_type = prefs.add_tags_connection_type;
|
||||
get_calendar_event = prefs.get_calendar_event;
|
||||
get_task = prefs.get_task;
|
||||
_ok_sparks = await checkSparksPresence() == 1;
|
||||
|
|
@ -352,7 +371,7 @@ function filterPromptsForTab(prompts_data, filtering){
|
|||
}
|
||||
|
||||
function checkDoAddTags(){
|
||||
return add_tags && (connection_type !== "chatgpt_web" && tabType !== 'messageCompose');
|
||||
return add_tags && checkAPIIntegration(connection_type, add_tags_use_specific_integration,add_tags_connection_type) && (tabType !== 'messageCompose');
|
||||
}
|
||||
|
||||
function checkDoCalendarEvent(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue