Skip to content

Commit f824153

Browse files
committed
#3026 add: finish AI support for release
1 parent e915cfc commit f824153

11 files changed

+1277
-1074
lines changed

CHANGELOG.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
# QOwnNotes Changelog
22

3+
## 24.5.3
4+
- QOwnNotes now has **AI support**, currently for **[Groq](https://groq.com/)**
5+
(because you can get free API keys) and **[OpenAI](https://openai.com/)**
6+
(for [#3026](https://github.com/pbek/QOwnNotes/issues/3026))
7+
- There is a new **AI toolbar** where can turn the service on, and you can select the AI backend and model
8+
- As a first step, there is a new script `ai-autocomplete` in the script repository
9+
that uses the selected AI model to **autocomplete the current block** in the note text edit
10+
- You can now add a [OpenAI](https://openai.com/) API key in the new *AI settings*
11+
- Use the new `script.aiComplete(prompt)` scripting command to your own imagination (see below)
12+
- There now is a new scripting command `script.aiComplete(prompt)` to use a completion prompt
13+
on the currently selected AI model (for [#3026](https://github.com/pbek/QOwnNotes/issues/3026))
14+
- For more information please take a look at the
15+
[Scripting documentation](https://www.qownnotes.org/scripting/methods-and-objects.html#use-a-completion-prompt-on-the-currently-selected-ai-model)
16+
- There now is a new scripting command `script.noteTextEditCurrentBlock()` to get
17+
the text of the current block (for [#3026](https://github.com/pbek/QOwnNotes/issues/3026))
18+
- For more information please take a look at the
19+
[Scripting documentation](https://www.qownnotes.org/scripting/methods-and-objects.html#read-the-current-block-from-the-note-text-edit)
20+
321
## 24.5.2
422
- Try to fix "QFont::setPointSize: Point size <= 0" warnings
5-
- The first part of the upcoming AI support is already visible
23+
- The first part of the upcoming **AI support** is already visible
624
(for [#3026](https://github.com/pbek/QOwnNotes/issues/3026))
725
- You can add a [Groq](https://groq.com/) API key in the new *AI settings*
826
- A PPA for Ubuntu 24.10 (Oracular Oriole) was added
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import QtQml 2.0
2+
import QOwnNotesTypes 1.0
3+
4+
/**
5+
* This script is an example for using the AI completer to complete the current
6+
* line and adding text to the autocompletion list
7+
*/
8+
Script {
9+
/**
10+
* Hook to feed the autocompletion AI generated text
11+
*/
12+
function autocompletionHook() {
13+
const text = script.noteTextEditCurrentBlock();
14+
15+
return script.aiComplete("Complete this sentence, don't add the text from the prompt: " + text);
16+
}
17+
}

src/dialogs/settingsdialog.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ void SettingsDialog::storeSettings() {
887887

888888
settings.setValue(QStringLiteral("ai/groq/apiKey"),
889889
CryptoService::instance()->encryptToString(ui->groqApiKeyLineEdit->text()));
890+
891+
settings.setValue(QStringLiteral("ai/openai/apiKey"),
892+
CryptoService::instance()->encryptToString(ui->openAiApiKeyLineEdit->text()));
890893
}
891894

892895
/**
@@ -1340,6 +1343,9 @@ void SettingsDialog::readSettings() {
13401343

13411344
ui->groqApiKeyLineEdit->setText(CryptoService::instance()->decryptToString(
13421345
settings.value(QStringLiteral("ai/groq/apiKey")).toString()));
1346+
1347+
ui->openAiApiKeyLineEdit->setText(CryptoService::instance()->decryptToString(
1348+
settings.value(QStringLiteral("ai/openai/apiKey")).toString()));
13431349
}
13441350

13451351
/**
@@ -4334,3 +4340,7 @@ void SettingsDialog::on_nextcloudDeckStackTreeWidget_currentItemChanged(QTreeWid
43344340
void SettingsDialog::on_groqApiKeyWebButton_clicked() {
43354341
QDesktopServices::openUrl(QUrl(QStringLiteral("https://console.groq.com/keys")));
43364342
}
4343+
4344+
void SettingsDialog::on_openAiApiKeyWebButton_clicked() {
4345+
QDesktopServices::openUrl(QUrl(QStringLiteral("https://platform.openai.com/api-keys")));
4346+
}

src/dialogs/settingsdialog.h

+2
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ class SettingsDialog : public MasterDialog {
326326

327327
void on_groqApiKeyWebButton_clicked();
328328

329+
void on_openAiApiKeyWebButton_clicked();
330+
329331
private:
330332
Ui::SettingsDialog *ui;
331333
QStatusBar *noteFolderRemotePathTreeStatusBar;

src/dialogs/settingsdialog.ui

+40-6
Original file line numberDiff line numberDiff line change
@@ -6864,7 +6864,27 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
68646864
<string>API keys</string>
68656865
</property>
68666866
<layout class="QGridLayout" name="gridLayout_85">
6867-
<item row="0" column="2">
6867+
<item row="0" column="0">
6868+
<widget class="QLabel" name="groqApiKeyHeadlineLabel">
6869+
<property name="text">
6870+
<string>Groq API key:</string>
6871+
</property>
6872+
<property name="alignment">
6873+
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
6874+
</property>
6875+
</widget>
6876+
</item>
6877+
<item row="1" column="0">
6878+
<widget class="QLabel" name="openAiApiKeyHeadlineLabel">
6879+
<property name="text">
6880+
<string>OpenAI API key:</string>
6881+
</property>
6882+
<property name="alignment">
6883+
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
6884+
</property>
6885+
</widget>
6886+
</item>
6887+
<item row="0" column="3">
68686888
<widget class="QToolButton" name="groqApiKeyWebButton">
68696889
<property name="toolTip">
68706890
<string>Create Groq API key</string>
@@ -6878,13 +6898,27 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
68786898
</property>
68796899
</widget>
68806900
</item>
6881-
<item row="0" column="0">
6882-
<widget class="QLabel" name="groqApiKeyHeadlineLabel">
6901+
<item row="1" column="1">
6902+
<widget class="PasswordLineEdit" name="openAiApiKeyLineEdit">
6903+
<property name="placeholderText">
6904+
<string>API key</string>
6905+
</property>
6906+
<property name="clearButtonEnabled">
6907+
<bool>true</bool>
6908+
</property>
6909+
</widget>
6910+
</item>
6911+
<item row="1" column="3">
6912+
<widget class="QToolButton" name="openAiApiKeyWebButton">
6913+
<property name="toolTip">
6914+
<string>Create OpenAI API key</string>
6915+
</property>
68836916
<property name="text">
6884-
<string>Groq API key:</string>
6917+
<string notr="true">…</string>
68856918
</property>
6886-
<property name="alignment">
6887-
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
6919+
<property name="icon">
6920+
<iconset theme="text-html" resource="../breeze-qownnotes.qrc">
6921+
<normaloff>:/icons/breeze-qownnotes/16x16/text-html.svg</normaloff>:/icons/breeze-qownnotes/16x16/text-html.svg</iconset>
68886922
</property>
68896923
</widget>
68906924
</item>

0 commit comments

Comments
 (0)