Skip to content

Commit

Permalink
Adding WIP actions (Wikipedia, arXiv, ...): create tool name/ID tuple…
Browse files Browse the repository at this point in the history
…s & use them through the source > better tool struct: name/ID/URL
  • Loading branch information
dvorka committed Feb 10, 2024
1 parent e678c24 commit 629b9be
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 34 deletions.
4 changes: 3 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
2024-02-?? Martin Dvorak <[email protected]>

* Released v2.0.0 - a major release that removes unused features
and brings several new features like Wingman
and brings several new features like Wingman.
* 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
Expand Down Expand Up @@ -30,6 +30,8 @@
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.
* Upgrade: new version(s) of Qt with enhanced security support
added - Qt 5.15.2 LTS is supported on macOS and Windows.
* Deprecation: dashboard view removed.
* Deprecation: experimental Mitie (NER) code removed (replaced by LLM integration).

Expand Down
1 change: 0 additions & 1 deletion FIX-IT.txt

This file was deleted.

55 changes: 35 additions & 20 deletions app/src/qt/cli_n_breadcrumbs_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ void CliAndBreadcrumbsPresenter::handleCliTextChanged(const QString& text)
// IMPROVE consider <html> prefix, <br/> separator and colors/bold
"<html>"
"Use the following commands:"
"<br>"
"<pre>"
"<br>? ... help"
"<br>/ ... search"
"<br>/ ... find"
"<br>@ ... knowledge recherche"
"<br>> ... run a command"
//"<br>: ... chat with workspace, Notebook or Note"
"<br>&nbsp;&nbsp;... or full-text search phrase"
"<br>"
"</pre>"
"<br>Examples:"
"<br>"
"<br>/ find notebook by tag TODO"
"<br>@ arxiv LLM"
"<br>> emojis"
"<pre>"
"<br>/notebook by tag TODO"
"<br>@arxiv LLM"
"<br>>emojis"
//"<br>: explain in simple terms SELECTED"
"<br>"
"</pre>"
)
);
view->setCommand("");
Expand Down Expand Up @@ -183,20 +183,35 @@ void CliAndBreadcrumbsPresenter::executeCommand()
// mainPresenter->getStatusBar()->showInfo(tr("Notebook ")+QString::fromStdString(outlines->front()->getName()));
// mainPresenter->getStatusBar()->showInfo(tr("Notebook not found: ") += QString(name.c_str()));
return;
} else if(command.startsWith(CliAndBreadcrumbsView::CMD_KNOW_WIKIPEDIA)) {
string name = command.toStdString().substr(
CliAndBreadcrumbsView::CMD_KNOW_WIKIPEDIA.size());
MF_DEBUG(" executing: knowledge recherche of '" << name << "' @ wikipedia" << endl);
if(name.size()) {
QString phrase=QString::fromStdString(name);
// TODO choose tool
mainPresenter->doActionOpenRunToolDialog(phrase);
} else {
mainPresenter->getStatusBar()->showInfo(tr("Please specify a search phrase - it cannot be empty"));
} else
// knowledge lookup in the CLI:
// - @wikipedia ... opens tool dialog with Wikipedi SELECTED in the dropdown
// - @wikipedia llm ... opens directly https://wikipedia.org
if(command.startsWith(CliAndBreadcrumbsView::CHAR_KNOW)) {
for(auto c:CliAndBreadcrumbsView::HELP_KNOW_CMDS) {
QString toolName = command.mid(1, c.size()-1);
if(command.startsWith(c)) {
QString phrase = command.mid(1, c.size());
MF_DEBUG(
" executing: knowledge recherche of '"
<< phrase.toStdString()
<< "' using command '"
<< c.toStdString() << "' and tool '"
<< toolName.toStdString() << "'" << endl);
if(phrase.size() > 1 && phrase.startsWith(" ")) {
phrase = phrase.mid(1);
mainPresenter->doActionOpenRunToolDialog(phrase, toolName, false);
mainPresenter->handleRunTool();
} else {
// search phrase is empty
mainPresenter->doActionOpenRunToolDialog(phrase, toolName);
}
return;
}
}
return;
// ELSE: unknown @unknown knowledge recherche tool do FTS as fallback
mainPresenter->getStatusBar()->showInfo(tr("Unknown knowledge recherche source - use valid source like @wikipedia"));
} else {
// do FTS as fallback
mainPresenter->doFts(view->getCommand(), true);
}
} else {
Expand Down
9 changes: 5 additions & 4 deletions app/src/qt/cli_n_breadcrumbs_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ const QString CliAndBreadcrumbsView::CMD_KNOW_DUCK
= "@duckduckgo";
const QString CliAndBreadcrumbsView::CMD_KNOW_GITHUB
= "@github";
const QString CliAndBreadcrumbsView::CMD_KNOW_BARD
= "@bard";

const QStringList CliAndBreadcrumbsView::HELP_KNOW_CMDS = QStringList()
// << CMD_KNOW_WIKIPEDIA
// << CMD_KNOW_ARXIV
<< CMD_KNOW_WIKIPEDIA
<< CMD_KNOW_ARXIV
<< CMD_KNOW_STACK_OVERFLOW
<< CMD_KNOW_DUCK
<< CMD_KNOW_GITHUB
;

const QString CliAndBreadcrumbsView::CHAR_CMD
Expand Down
4 changes: 3 additions & 1 deletion app/src/qt/dialogs/configuration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ ConfigurationDialog::AppTab::AppTab(QWidget *parent)
appearanceLayout->addWidget(appFontSizeSpin);
appearanceLayout->addWidget(menuLabel);
appearanceLayout->addWidget(nerdMenuCheck);
QGroupBox* appearanceGroup = new QGroupBox{tr("Appearance"), this};
QGroupBox* appearanceGroup = new QGroupBox{
tr("Appearance (<font color='#ff0000'>requires restart</font>)"),
this};
appearanceGroup->setLayout(appearanceLayout);

QVBoxLayout* controlsLayout = new QVBoxLayout{this};
Expand Down
2 changes: 1 addition & 1 deletion app/src/qt/dialogs/run_tool_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RunToolDialog::RunToolDialog(QWidget* parent)
);

// dialog
setWindowTitle(tr("Get Knowledge"));
setWindowTitle(tr("Retrieve Knowledge"));
resize(fontMetrics().averageCharWidth()*55, height());
setModal(true);
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/qt/dialogs/run_tool_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class RunToolDialog : public QDialog
this->toolCombo->currentIndex()
);
}
void setSelectedTool(QString toolName) {
int index = this->toolCombo->findText(toolName);
if(index != -1) {
this->toolCombo->setCurrentIndex(index);
}
}
QString getTemplateText() const {
return this->templateEdit->text();
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/qt/main_window_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,18 +1796,24 @@ void MainWindowPresenter::doActionEditPasteImageData(QImage image)
injectImageLinkToEditor(path, QString{"image"});
}

void MainWindowPresenter::doActionOpenRunToolDialog(QString& phrase)
{
void MainWindowPresenter::doActionOpenRunToolDialog(
QString& phrase,
QString& toolName,
bool openDialog
) {
MF_DEBUG("SIGNAL handled: open run tool dialog...");
this->runToolDialog->setPhraseText(phrase);
this->runToolDialog->setSelectedTool(toolName);
QString templateText = this->runToolDialog->getTemplateTextForToolName(
this->runToolDialog->getSelectedTool().toStdString());
if(templateText.length() == 0) {
return;
}
this->runToolDialog->setTemplateText(templateText);

this->runToolDialog->show();
if(openDialog) {
this->runToolDialog->show();
}
}

void MainWindowPresenter::handleRunTool()
Expand Down Expand Up @@ -3101,7 +3107,6 @@ void MainWindowPresenter::selectNoteInOutlineTree(Note* note, Outline::Patch& pa
{
QModelIndex idx;
if(orloj->isFacetActive(OrlojPresenterFacets::FACET_MAP_OUTLINES)) {
QModelIndex idx;
if(onUp) {
idx = orloj->getOutlinesMap()->getModel()->index(patch.start, 0);
} else {
Expand All @@ -3110,7 +3115,6 @@ void MainWindowPresenter::selectNoteInOutlineTree(Note* note, Outline::Patch& pa

orloj->getOutlinesMap()->getView()->setCurrentIndex(idx);
} else {
QModelIndex idx;
if(onUp) {
idx = orloj->getOutlineView()->getOutlineTree()->getView()->model()->index(patch.start, 0);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/src/qt/main_window_presenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public slots:
void doActionEditFindAgain();
void doActionEditWordWrapToggle();
void doActionEditPasteImageData(QImage image);
void doActionOpenRunToolDialog(QString& phrase);
void doActionOpenRunToolDialog(QString& phrase, QString& tool, bool showDialog=true);
void handleRunTool();
void doActionToggleLiveNotePreview();
void doActionNameDescFocusSwap();
Expand Down

0 comments on commit 629b9be

Please sign in to comment.