Skip to content

Commit

Permalink
Wingman configuration, Preferences dialog, mind, main window, ... han…
Browse files Browse the repository at this point in the history
…dling.
  • Loading branch information
dvorka committed Jan 28, 2024
1 parent c665d0a commit 95bf29b
Show file tree
Hide file tree
Showing 10 changed files with 325 additions and 145 deletions.
26 changes: 18 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contribute to MindForger

MindForger is free and open source software. Feel free to **contribute** - any help
MindForger is free and open source software. Feel free to **contribute** - any help
with MindForger development will be **highly appreciated**!

* **Bugs and Suggestions**
Expand All @@ -13,16 +13,24 @@ with MindForger development will be **highly appreciated**!
* Submit pull request/patch with implementation of a feature you missed.
* **Integration**
* How-to or code enabling integration with your (favorite) project.
* **Enhancements**
* **Enhancements**
* Submit performance, efficiency and/or productivity enhancements suggestions (code, bug or docs)
* **Documentation**
* **Documentation**
* Write a document, block post; create YouTube video, ...

Don't hesitate to contact [me](mailto:[email protected]).

**Table of contents**:

* [Code of Conduct](#code-of-conduct)
* [Styleguide: Git Commit Messages](#styleguide--git-commit-messages)
* [Styleguide: C++](#styleguide--c)
* [Styleguide: C++ Comments](#styleguide--c---comments)
* [Styleguide: Qt](#styleguide--qt)


# Code of Conduct
This project and everyone participating in it is governed by the
This project and everyone participating in it is governed by the
[MindForger Code of Conduct](./CODE_OF_CONDUCT.md). By participating, you are expected to uphold this
code.

Expand All @@ -36,7 +44,7 @@ code.

# Styleguide: C++
Code style:

* Use `.h` extension for header files.
* Use `.cpp` extension for class files.
* Use `lower_case_with_underscores` source code file names.
Expand All @@ -63,8 +71,8 @@ public:
...

void myFunction(int myParam) { ... }
int myMultiLineFunction() const {

int myMultiLineFunction() const {
...
}

Expand Down Expand Up @@ -118,7 +126,7 @@ void MainWindowPresenter::doActionOrganizerMoveNoteToNextVisibleQuadrant(Note* n
```
# Styleguide: C++ comments
# Styleguide: C++ Comments
Comments should be used to explain tricky and/or
important code only. Don't use comments to explain
obvious things as comments might diverge from the
Expand Down Expand Up @@ -190,3 +198,5 @@ public:

* MindForger uses MVP pattern (see `main_window_presenter.h/.cpp`)
* See `/src/qt` source code for a code style reference.


9 changes: 5 additions & 4 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* Feature: Wingman brings OpenAI chat GPT integration allowing to
compose, rewrite, summarize, do NER, fix, or chat with remarks.
* Feature: Notebook Tree view brings ability to organize Notebooks to
and outline.
a tree (an outline).
* Feature: Libraries bring ability to index external PDF files and generate
Notebooks which represent them in MindForger. Synchronization and removal
of the library supported as well.
of the library (directory with files) is supported as well.
* Feature: Emojis dialog allowing to use Unicode-based emojis
in Notebook names, Note names or text.
in Notebooks and Notes names or text.
* Hidden feature: New left side toolbar which runs various tools
(like Wikipedia, arXiv, StackOverflow, ...) on phrase which is the current
context (Notebook or Note name, selected text or text under the cursor, ...)
Expand All @@ -29,8 +29,9 @@
* Fix: Missing OOTB Eisenhower Matrix is automatically added back to
the list of Organizers.
* Fix: Conflicting menu keyboard shortcuts resolution (e.g. Organizers view).
* Fix: Edit and Format menus re-enabled on single Markdown file configuration.
* Deprecation: dashboard view removed.
* Deprecation: experimental Nitie code removed.
* Deprecation: experimental Mitie (NER) code removed (replaced by LLM integration).

2023-01-15 Martin Dvorak <[email protected]>

Expand Down
34 changes: 23 additions & 11 deletions app/src/qt/dialogs/configuration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,7 @@ ConfigurationDialog::WingmanTab::WingmanTab(QWidget* parent)
: QWidget(parent), config(Configuration::getInstance())
{
llmProvidersLabel = new QLabel(tr("LLM provider:"), this);

llmProvidersCombo = new QComboBox{this};
llmProvidersCombo->addItem(""); // disable Wingman
// TODO enable OpenAI ONLY if ENV_VAR_OPENAI_API_KEY is set
llmProvidersCombo->addItem(
QString{"OpenAI"}, WingmanLlmProviders::WINGMAN_PROVIDER_OPENAI);

// set the last selected provider
llmProvidersCombo->setCurrentIndex(
llmProvidersCombo->findData(config.getWingmanLlmProvider()));

llmHelpLabel = new QLabel(
tr(
Expand Down Expand Up @@ -711,12 +702,33 @@ ConfigurationDialog::WingmanTab::~WingmanTab()

void ConfigurationDialog::WingmanTab::refresh()
{
// TODO to be implemented - use App
// TODO to be implemented - use App as inspiration

// refresh LLM providers combo
llmProvidersCombo->clear();
llmProvidersCombo->addItem(""); // disable Wingman
if(config.canWingmanMock()) {
llmProvidersCombo->addItem(
QString{"Mock"}, WingmanLlmProviders::WINGMAN_PROVIDER_MOCK);
}
if(config.canWingmanOpenAi()) {
llmProvidersCombo->addItem(
QString{"OpenAI"}, WingmanLlmProviders::WINGMAN_PROVIDER_OPENAI);
}
// set the last selected provider
llmProvidersCombo->setCurrentIndex(
llmProvidersCombo->findData(config.getWingmanLlmProvider()));
}


void ConfigurationDialog::WingmanTab::save()
{
// TODO to be implemented - use App
// TODO to be implemented - use App as inspiration

// get LLM provider enum value from llmProvidersCombo
WingmanLlmProviders llmProvider = static_cast<WingmanLlmProviders>(
llmProvidersCombo->itemData(llmProvidersCombo->currentIndex()).toInt());
config.setWingmanLlmProvider(llmProvider);
}

/*
Expand Down
44 changes: 23 additions & 21 deletions app/src/qt/dialogs/wingman_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,13 @@ const string COLOR_PROMPT_GREEN{"#00bb00"};
const string COLOR_PROMPT_BLUE{"#00aaaa"};
const string COLOR_PROMPT_GRAY{"#777777"};

WingmanDialog::WingmanDialog(
const vector<string>& predefinedOPrompts,
const vector<string>& predefinedNPrompts,
const vector<string>& predefinedTPrompts,
QWidget* parent
): QDialog(parent),
firstRun{true},
mode{WingmanDialogModes::WINGMAN_DIALOG_MODE_TEXT},
context{},
lastAnswer{}
WingmanDialog::WingmanDialog(QWidget* parent)
: QDialog(parent),
firstRun{true},
mode{WingmanDialogModes::WINGMAN_DIALOG_MODE_TEXT},
context{},
lastAnswer{}
{
for(string prompt:predefinedOPrompts) {
outlinePrompts.push_back(QString::fromStdString(prompt));
}
for(string prompt:predefinedNPrompts) {
notePrompts.push_back(QString::fromStdString(prompt));
}
for(string prompt:predefinedTPrompts) {
textPrompts.push_back(QString::fromStdString(prompt));
}

setWindowTitle(tr("Wingman Chat"));

promptsLabel = new QLabel{tr("Prompt:"), parent};
Expand Down Expand Up @@ -233,8 +219,24 @@ QString WingmanDialog::getContextText() const {
void WingmanDialog::show(
WingmanDialogModes contextType,
QString& contextName,
QString& context
QString& context,
const vector<string>& predefinedOPrompts,
const vector<string>& predefinedNPrompts,
const vector<string>& predefinedTPrompts
) {
outlinePrompts.clear();
for(string prompt:predefinedOPrompts) {
outlinePrompts.push_back(QString::fromStdString(prompt));
}
notePrompts.clear();
for(string prompt:predefinedNPrompts) {
notePrompts.push_back(QString::fromStdString(prompt));
}
textPrompts.clear();
for(string prompt:predefinedTPrompts) {
textPrompts.push_back(QString::fromStdString(prompt));
}

this->initForMode(contextType);

setContextText(context);
Expand Down
11 changes: 5 additions & 6 deletions app/src/qt/dialogs/wingman_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ class WingmanDialog : public QDialog // TODO rename to WingmanDialog
bool predefPromptsVisibilityCache;

public:
explicit WingmanDialog(
const std::vector<std::string>& predefinedOPrompts,
const std::vector<std::string>& predefinedNPrompts,
const std::vector<std::string>& predefinedTPrompts,
QWidget* parent);
explicit WingmanDialog(QWidget* parent);
WingmanDialog(const WingmanDialog&) = delete;
WingmanDialog(const WingmanDialog&&) = delete;
WingmanDialog& operator =(const WingmanDialog&) = delete;
Expand Down Expand Up @@ -144,7 +140,10 @@ class WingmanDialog : public QDialog // TODO rename to WingmanDialog
void show(
WingmanDialogModes contextType,
QString& contextName,
QString& context);
QString& context,
const std::vector<std::string>& predefinedOPrompts,
const std::vector<std::string>& predefinedNPrompts,
const std::vector<std::string>& predefinedTPrompts);

void resetProgress(int maximum) {
progressBar->setValue(0);
Expand Down
22 changes: 6 additions & 16 deletions app/src/qt/main_window_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,7 @@ MainWindowPresenter::MainWindowPresenter(MainWindowView& view)
syncLibraryDialog = new SyncLibraryDialog{&view};
rmLibraryDialog = new RemoveLibraryDialog(&view);
runToolDialog = new RunToolDialog{&view};
if(config.isWingman()) {
wingmanDialog = new WingmanDialog{
mind->getWingman()->getPredefinedOPrompts(),
mind->getWingman()->getPredefinedNPrompts(),
mind->getWingman()->getPredefinedTPrompts(),
&view
};
} else {
vector<string> empty{};
wingmanDialog = new WingmanDialog{
empty, empty, empty,
&view
};
}
wingmanDialog = new WingmanDialog{&view};
scopeDialog = new ScopeDialog{mind->getOntology(), &view};
newOrganizerDialog = new OrganizerNewDialog{mind->getOntology(), &view};
newOutlineDialog = new OutlineNewDialog{
Expand Down Expand Up @@ -2068,7 +2055,7 @@ void MainWindowPresenter::handleActionWingman()
QObject::tr("Wingman Not Available"),
QObject::tr(
"Wingman provider is either not configured or "
"it cannot be initialized.")
"initialized - see MindForger Preferences (Wingman tab).")
};
msgBox.exec();
return;
Expand Down Expand Up @@ -2147,7 +2134,10 @@ void MainWindowPresenter::handleActionWingman()
this->wingmanDialog->show(
contextType,
contextTextName,
contextText
contextText,
mind->getWingman()->getPredefinedOPrompts(),
mind->getWingman()->getPredefinedNPrompts(),
mind->getWingman()->getPredefinedTPrompts()
);
}

Expand Down
Loading

0 comments on commit 95bf29b

Please sign in to comment.