diff --git a/CHANGELOG.md b/CHANGELOG.md index e77b94f419..0faee34796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # QOwnNotes Changelog +## 24.8.1 +- In the *AI settings* in the list of AI backends from scripts now also the API base + URL will be shown (for [#3064](https://github.com/pbek/QOwnNotes/issues/3064)) + - In addition, a button to search the *Script repository* was added ## 24.8.0 - In the *AI settings* there now are buttons to test the connection to the AI services (for [#3062](https://github.com/pbek/QOwnNotes/issues/3062)) diff --git a/src/dialogs/settingsdialog.cpp b/src/dialogs/settingsdialog.cpp index c5d480dceb..e5240ae3e5 100644 --- a/src/dialogs/settingsdialog.cpp +++ b/src/dialogs/settingsdialog.cpp @@ -4416,21 +4416,23 @@ void SettingsDialog::buildAiScriptingTreeWidget() { return; } - for (const auto &key : backendNames.keys()) { + for (const auto &backendId : backendNames.keys()) { // Continue on groq and openai - if (key == QStringLiteral("groq") || key == QStringLiteral("openai")) { + if (backendId == QStringLiteral("groq") || backendId == QStringLiteral("openai")) { continue; } - const QString &name = backendNames.value(key); + const QString &backendName = backendNames.value(backendId); auto backendItem = new QTreeWidgetItem(ui->aiScriptingTreeWidget); - backendItem->setText(0, name); - backendItem->setToolTip(0, tr("AI backend: %1").arg(key)); - backendItem->setData(0, Qt::UserRole, key); + backendItem->setText(0, backendName); + backendItem->setToolTip(0, tr("AI backend: %1").arg(backendId)); + backendItem->setData(0, Qt::UserRole, backendId); + backendItem->setText(1, openAiService->getApiBaseUrlForBackend(backendId)); + backendItem->setToolTip(1, tr("API base URL").arg(backendId)); backendItem->setFlags(backendItem->flags() & ~Qt::ItemIsSelectable); - auto models = openAiService->getModelsForBackend(key); + auto models = openAiService->getModelsForBackend(backendId); for (const auto &model : models) { auto modelItem = new QTreeWidgetItem(backendItem); modelItem->setText(0, model); @@ -4441,11 +4443,11 @@ void SettingsDialog::buildAiScriptingTreeWidget() { // Add test button in new column auto testButton = new QPushButton(); testButton->setText(tr("Test")); - testButton->setToolTip(tr("Test connection to %1 (%2)").arg(name, model)); + testButton->setToolTip(tr("Test connection to %1 (%2)").arg(backendName, model)); testButton->setIcon( QIcon::fromTheme(QStringLiteral("network-connect"), QIcon(":/icons/breeze-qownnotes/16x16/network-connect.svg"))); - testButton->setProperty("backend", key); + testButton->setProperty("backend", backendId); testButton->setProperty("model", model); connect(testButton, &QPushButton::clicked, this, [this, testButton]() { QString backend = testButton->property("backend").toString(); @@ -4453,11 +4455,17 @@ void SettingsDialog::buildAiScriptingTreeWidget() { runAiApiTest(backend, model); }); - ui->aiScriptingTreeWidget->setItemWidget(modelItem, 1, testButton); + ui->aiScriptingTreeWidget->setItemWidget(modelItem, 2, testButton); } } ui->aiScriptingTreeWidget->expandAll(); ui->aiScriptingTreeWidget->resizeColumnToContents(0); ui->aiScriptingTreeWidget->resizeColumnToContents(1); -} \ No newline at end of file + ui->aiScriptingTreeWidget->resizeColumnToContents(2); +} + +void SettingsDialog::on_searchScriptRepositoryButton_clicked() { + searchScriptInRepository(); + buildAiScriptingTreeWidget(); +} diff --git a/src/dialogs/settingsdialog.h b/src/dialogs/settingsdialog.h index 20ce1bce1f..320436a4fa 100644 --- a/src/dialogs/settingsdialog.h +++ b/src/dialogs/settingsdialog.h @@ -338,6 +338,8 @@ class SettingsDialog : public MasterDialog { void on_openAiApiKeyLineEdit_textChanged(const QString &arg1); + void on_searchScriptRepositoryButton_clicked(); + private: Ui::SettingsDialog *ui; QStatusBar *noteFolderRemotePathTreeStatusBar; diff --git a/src/dialogs/settingsdialog.ui b/src/dialogs/settingsdialog.ui index 4ce56138ed..dcadc752e0 100644 --- a/src/dialogs/settingsdialog.ui +++ b/src/dialogs/settingsdialog.ui @@ -6886,8 +6886,235 @@ Just test yourself if you get sync conflicts and set a higher value if so.0 - - + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 15 + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 100 + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + To make use of the AI backends, you can either use the scripting command <a href="%1">aiComplete</a>, or look in the script repository for already-written scripts. + + + true + + + true + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 15 + + + + + + + + You can use the scripting hook <a href="%1">openAiBackendsHook</a> to add more OpenAI API compatible backends. + + + true + + + true + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 15 + + + + + + + + Alternatively, you can also look in the script repository for already created AI integration scripts. + + + true + + + + + + + + + + + 0 + 0 + + + + AI backends added via the scripting engine + + + + + + + 0 + 0 + + + + false + + + false + + + + Name + + + + + Test + + + + + Endpoint + + + + + - + + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 15 + + + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + + 0 + 0 + + + + Search script repository + + + Search script repository for AI integration scripts + + + + :/icons/breeze-qownnotes/16x16/edit-find.svg:/icons/breeze-qownnotes/16x16/edit-find.svg + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + API keys @@ -6986,133 +7213,6 @@ Just test yourself if you get sync conflicts and set a higher value if so. - - - - - 0 - 0 - - - - AI backends added via the scripting engine - - - - - - - 0 - 0 - - - - false - - - false - - - - Name - - - - - Test - - - - - - - - - - - - - - - - - Qt::Orientation::Vertical - - - QSizePolicy::Policy::Fixed - - - - 20 - 15 - - - - - - - - To make use of the AI backends, you can either use the scripting command <a href="%1">aiComplete</a>, or look in the script repository for already-written scripts. - - - true - - - true - - - - - - - Qt::Orientation::Vertical - - - QSizePolicy::Policy::Fixed - - - - 20 - 15 - - - - - - - - You can use the scripting hook <a href="%1">openAiBackendsHook</a> to add more OpenAI API compatible backends. - - - true - - - true - - - - - - - Alternatively, you can also look in the script repository for already created AI integration scripts. - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/src/languages/QOwnNotes_en.ts b/src/languages/QOwnNotes_en.ts index 9aab9a3710..7a321d2aac 100644 --- a/src/languages/QOwnNotes_en.ts +++ b/src/languages/QOwnNotes_en.ts @@ -4560,7 +4560,7 @@ If the trash is enabled on your ownCloud server you should be able to restore th OpenAiCompleter - + Timeout, while waiting for the AI response @@ -4568,7 +4568,7 @@ If the trash is enabled on your ownCloud server you should be able to restore th OpenAiService - + AI system is disabled. Please enable it in the main menu or the AI toolbar. @@ -7023,64 +7023,69 @@ Just test yourself if you get sync conflicts and set a higher value if so. - + + Search script repository for AI integration scripts + + + + API keys - + OpenAI API key: - + Create Groq API key - + Create OpenAI API key - - + + Test connection - + AI backends added via the scripting engine - + Test - + To make use of the AI backends, you can either use the scripting command <a href="%1">aiComplete</a>, or look in the script repository for already-written scripts. - + You can use the scripting hook <a href="%1">openAiBackendsHook</a> to add more OpenAI API compatible backends. - + Alternatively, you can also look in the script repository for already created AI integration scripts. - + Groq API key: - - + + API key @@ -7570,6 +7575,7 @@ Just test yourself if you get sync conflicts and set a higher value if so. + Search script repository @@ -8223,12 +8229,17 @@ Connection error message: - + + API base URL + + + + AI model: %1 - + Test connection to %1 (%2) diff --git a/src/services/openaiservice.cpp b/src/services/openaiservice.cpp index 68bbd8260a..0b451bb5ca 100644 --- a/src/services/openaiservice.cpp +++ b/src/services/openaiservice.cpp @@ -131,8 +131,10 @@ QStringList OpenAiService::getModelsForCurrentBackend() { QMap OpenAiService::getBackendNames() { return _backendNames; } QString OpenAiService::getApiBaseUrlForCurrentBackend() { - auto backendId = getBackendId(); + return getApiBaseUrlForBackend(getBackendId()); +} +QString OpenAiService::getApiBaseUrlForBackend(const QString& backendId) { if (_backendApiBaseUrls.contains(backendId)) { return _backendApiBaseUrls.value(backendId); } else { diff --git a/src/services/openaiservice.h b/src/services/openaiservice.h index 3210194e5c..e5481eb72c 100644 --- a/src/services/openaiservice.h +++ b/src/services/openaiservice.h @@ -64,6 +64,7 @@ class OpenAiService : public QObject { void setApiKeyForCurrentBackend(); void setApiKeyForCurrentBackend(const QString& apiKey); QMap getBackendNames(); + QString getApiBaseUrlForBackend(const QString& backendId); private: QMap _backendModels;