Skip to content

Commit

Permalink
#3037 add: reloading of OpenAI UI, custom API key handling, hook docu…
Browse files Browse the repository at this point in the history
…mentation, example script additions, changelog entry and settings information

Signed-off-by: Patrizio Bekerle <[email protected]>
  • Loading branch information
pbek committed Jun 14, 2024
1 parent b0d309a commit 4740c49
Show file tree
Hide file tree
Showing 9 changed files with 475 additions and 392 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# QOwnNotes Changelog

## 24.6.2
- A new scripting hook `openAiBackendsHook` was added, that is called when the OpenAI
service config is reloaded (for [#3037](https://github.com/pbek/QOwnNotes/issues/3037))
- For example this is also done when the script engine is reloaded
- You can use it to provide config for custom OpenAI backends, like your own OpenAI API compatible LLMs
- Please take a look at the
[openAiBackendsHook documentation](https://www.qownnotes.org/scripting/hooks.html#openaibackendshook)
for more information

## 24.6.1
- When using the `Insert` key in the note text edit to toggle overwrite mode, it
now will be made sure that no modifier key is pressed (for [#3038](https://github.com/pbek/QOwnNotes/issues/3038))
Expand Down
17 changes: 13 additions & 4 deletions docs/scripting/examples/custom-openai-backends.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import QOwnNotesTypes 1.0
* This script provides custom OpenAI backends
*/
Script {
/**
* This function is called when the OpenAI service config is reloaded
* It returns a list of objects with config parameters for new OpenAI backends
*/
function openAiBackendsHook() {
const result = [
return [
{
"id": "my-custom-ai",
"name": "My Custom AI12",
"name": "My Custom AI",
"baseUrl": "http://localhost:5000",
"apiKey": "kDFJkjk3asdm",
"models": ["gpt-3.5-turbo", "gpt-4.0-turbo"],
Expand All @@ -20,9 +24,14 @@ Script {
"baseUrl": "http://localhost:5001",
"apiKey": "lOikf7eNdb9",
"models": ["gpt-3.5-turbo2", "gpt-4.0-turbo2"],
},
{
"id": "custom-groq",
"name": "Custom Groq",
"baseUrl": "https://api.groq.com/openai/v1/chat/completions",
"apiKey": "gsk_Kfj477MosEC5LwKN2nrSyw4Yj4Zt44KsLn7AM5M4KQGUu87xqgX",
"models": ["llama3-70b-8192"],
}
];

return result;
}
}
2 changes: 2 additions & 0 deletions src/dialogs/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent)
"https://www.qownnotes.org/getting-started/command-line-snippet-manager.html"));
ui->commandSnippetsNoteNameLabel->hide();
ui->commandSnippetsNoteNameLineEdit->hide();
ui->openAiScriptingLabel->setText(ui->openAiScriptingLabel->text().arg(
"https://www.qownnotes.org/scripting/hooks.html#openaibackendshook"));

#ifndef Q_OS_LINUX
ui->systemIconThemeCheckBox->setHidden(true);
Expand Down
13 changes: 13 additions & 0 deletions src/dialogs/settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6958,6 +6958,19 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="openAiScriptingLabel">
<property name="text">
<string>You can use the scripting hook &lt;a href=&quot;%1&quot;&gt;openAiBackendsHook&lt;/a&gt; to add more OpenAI API compatible backends.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_21">
<property name="orientation">
Expand Down

0 comments on commit 4740c49

Please sign in to comment.