general ui work
This commit is contained in:
@ -7,6 +7,9 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <qlabel.h>
|
||||
#include <qradiobutton.h>
|
||||
|
||||
#include "backend.h"
|
||||
|
||||
KateAiConfigPage::KateAiConfigPage(QWidget *parent, KateAiPlugin *plugin)
|
||||
: KTextEditor::ConfigPage(parent)
|
||||
@ -15,19 +18,42 @@ KateAiConfigPage::KateAiConfigPage(QWidget *parent, KateAiPlugin *plugin)
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
std::vector<QString> backends = AiBackend::getAvailableBackendNames();
|
||||
for(const QString& name : backends)
|
||||
cmbxServerType.addItem(name);
|
||||
|
||||
layout->addWidget(&cmbxServerType);
|
||||
|
||||
QHBoxLayout* lineLayout = new QHBoxLayout(this);
|
||||
QLabel* lineEditLabel = new QLabel(i18n("Url for the WebSockets ExLlama Ai server:"), this);
|
||||
QLabel* lineEditLabel = new QLabel(i18n("Url for the Ai server:"), this);
|
||||
lineEditLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
lineLayout->addWidget(lineEditLabel);
|
||||
lineLayout->addWidget(&lineUrl);
|
||||
layout->addLayout(lineLayout);
|
||||
|
||||
QHBoxLayout* contextSpinLayout = new QHBoxLayout(this);
|
||||
QLabel* contextSpinLabel = new QLabel(i18n("Maximum context:"), this);
|
||||
contextSpinLayout->addWidget(contextSpinLabel);
|
||||
contextSpinBox.setMinimum(100);
|
||||
contextSpinBox.setMaximum(32768);
|
||||
contextSpinLayout->addWidget(&contextSpinBox);
|
||||
layout->addLayout(contextSpinLayout);
|
||||
|
||||
btnCompletion.setText(i18n("Use the Ai to generate a completion"));
|
||||
btnInstruct.setText(i18n("Use the Ai to insert a response to a instruction"));
|
||||
btnInstruct.setText(i18n("Use the Ai to insert a response to an instruction"));
|
||||
layout->addWidget(&btnCompletion);
|
||||
layout->addWidget(&btnInstruct);
|
||||
|
||||
QHBoxLayout* systemPromptLayout = new QHBoxLayout(this);
|
||||
systemPromptLabel.setText(i18n("System Prompt:"));
|
||||
systemPromptLabel.setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
systemPromptLayout->addWidget(&systemPromptLabel);
|
||||
systemPromptLayout->addWidget(&lineSystemPrompt);
|
||||
layout->addLayout(systemPromptLayout);
|
||||
layout->addStretch();
|
||||
|
||||
connect(&btnInstruct, &QRadioButton::toggled, this, &KateAiConfigPage::instructBtnToggeled);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -51,6 +77,9 @@ void KateAiConfigPage::apply()
|
||||
KConfigGroup config(KSharedConfig::openConfig(), "Ai");
|
||||
config.writeEntry("Url", lineUrl.text());
|
||||
config.writeEntry("Instruct", btnInstruct.isChecked());
|
||||
config.writeEntry("SystemPrompt", lineSystemPrompt.text());
|
||||
config.writeEntry("Context", contextSpinBox.value());
|
||||
config.writeEntry("Backend", cmbxServerType.currentText());
|
||||
|
||||
config.sync();
|
||||
m_plugin->readConfig();
|
||||
@ -59,7 +88,19 @@ void KateAiConfigPage::apply()
|
||||
void KateAiConfigPage::reset()
|
||||
{
|
||||
KConfigGroup config(KSharedConfig::openConfig(), "Ai");
|
||||
lineUrl.setText(config.readEntry("Url", "ws://localhost:8642"));
|
||||
lineSystemPrompt.setText(config.readEntry("SystemPrompt", "ws://localhost:8642"));
|
||||
lineUrl.setText(config.readEntry("Url", "You are an intelligent programming assistant."));
|
||||
btnInstruct.setChecked(config.readEntry("Instruct", false));
|
||||
btnCompletion.setChecked(!btnInstruct.isChecked());
|
||||
contextSpinBox.setValue(config.readEntry("Context", 1024));
|
||||
cmbxServerType.setCurrentText(config.readEntry("Backend", "KoboldAI"));
|
||||
|
||||
lineSystemPrompt.setEnabled(btnInstruct.isChecked());
|
||||
systemPromptLabel.setEnabled(btnInstruct.isChecked());
|
||||
}
|
||||
|
||||
void KateAiConfigPage::instructBtnToggeled(bool checked)
|
||||
{
|
||||
lineSystemPrompt.setEnabled(checked);
|
||||
systemPromptLabel.setEnabled(checked);
|
||||
}
|
||||
|
Reference in New Issue
Block a user