Skip to content

Commit

Permalink
feat: [chat] modified ui of chat
Browse files Browse the repository at this point in the history
change text & icons & answer component

Log: as title
  • Loading branch information
LiHua000 authored and deepin-mozart committed Jan 20, 2025
1 parent dd9a1ea commit 2e7cbb6
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/plugins/aimanager/option/addmodeldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ void AddModelDialogPrivate::slotAddModel()
return;
}
newLLMInfo.type = cbLLMType->currentData().value<LLMType>();
if (newLLMInfo.type == LLMType::OPENAI)
newLLMInfo.icon = QIcon::fromTheme("uc_openai");

newLLMInfo.modelPath = leApiUrl->text();
if (newLLMInfo.modelPath.isEmpty()) {
leApiUrl->showAlertMessage(AddModelDialog::tr("This field cannot be empty."));
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/codegeex/builtin/icons/uc_openai_16px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/plugins/codegeex/codegeex.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<file>builtin/icons/codegeex_anwser_icon_24px.svg</file>
<file>builtin/icons/codegeex_user_30px.svg</file>
<file>builtin/icons/codegeex_logo_24px.svg</file>
<file>builtin/icons/uc_openai_16px.svg</file>
<file>builtin/texts/codegeex_indicate_16px.svg</file>
<file>builtin/texts/codegeex_advice_16px.svg</file>
<file>builtin/texts/codegeex_comment_16px.svg</file>
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/codegeex/codegeexmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ AbstractLLM *CodeGeeXManager::getCurrentLLM() const
return chatLLM;
}

LLMInfo CodeGeeXManager::getCurrentLLMInfo() const
{
return currentInfo;
}

void CodeGeeXManager::setLocale(CodeGeeX::Locale locale)
{
this->locale = locale;
Expand Down Expand Up @@ -338,6 +343,7 @@ void CodeGeeXManager::onLLMChanged(const LLMInfo &llmInfo)

chatLLM = selectedLLM;
initLLM(chatLLM);
currentInfo = llmInfo;
emit llmChanged(llmInfo);
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/codegeex/codegeexmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CodeGeeXManager : public QObject
bool condaHasInstalled();

AbstractLLM *getCurrentLLM() const;
LLMInfo getCurrentLLMInfo() const;

void setLocale(CodeGeeX::Locale locale);

Expand Down Expand Up @@ -148,6 +149,7 @@ public Q_SLOTS:

int answerFlag = 0; // use to identify every single answer
AbstractLLM *chatLLM { nullptr };
LLMInfo currentInfo;
AbstractLLM *liteLLM { nullptr }; //codegeex Lite.
CodeGeeX::Locale locale { CodeGeeX::Zh };
};
Expand Down
1 change: 0 additions & 1 deletion src/plugins/codegeex/widgets/codegeexwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class CodeGeeXWidget : public DTK_WIDGET_NAMESPACE::DFrame
explicit CodeGeeXWidget(QWidget *parent = nullptr);

public Q_SLOTS:
void onLogOut();
void onNewSessionCreated();
void onCloseHistoryWidget();
void onShowHistoryWidget();
Expand Down
29 changes: 9 additions & 20 deletions src/plugins/codegeex/widgets/intropage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ void IntroPage::initUI()
mainLayout->addStretch(1);
initSuggestContent();
mainLayout->addStretch(1);
initLogoutButton();
}

void IntroPage::initLogo()
Expand All @@ -76,18 +75,19 @@ void IntroPage::initLogo()
logoLayout->setSpacing(20);
qobject_cast<QVBoxLayout *>(layout())->addLayout(logoLayout);

DLabel *logo = new DLabel(this);
logo->setAlignment(Qt::AlignHCenter);
logo->setPixmap(QIcon::fromTheme("codegeex_anwser_icon").pixmap(50));
logoLayout->addWidget(logo);
// DLabel *logo = new DLabel(this);
// logo->setAlignment(Qt::AlignHCenter);
// logo->setPixmap(QIcon::fromTheme("codegeex_anwser_icon").pixmap(50));
// logoLayout->addWidget(logo);
logoLayout->addSpacing(70);

DLabel *logoLabel = new DLabel(this);
logoLabel->setAlignment(Qt::AlignHCenter);
logoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
auto font = logoLabel->font();
font.setPointSize(11);
logoLabel->setFont(font);
logoLabel->setText(tr("Welcome to CodeGeeX"));
logoLabel->setText(tr("Welcome to Chat"));
logoLayout->addWidget(logoLabel);
}

Expand All @@ -98,9 +98,9 @@ void IntroPage::initIntroContent()
introLayout->setSpacing(10);
qobject_cast<QVBoxLayout *>(layout())->addLayout(introLayout);

appendDescLabel(introLayout, tr("CodeGeeX provides code completion suggestions in editor, Press %1 Tab %2 to accept.").arg("<font style='color:dodgerblue;'>", "</font>"));
appendDescLabel(introLayout, tr("CodeGeeX provides inline chat functionality in editor, Press %1 Ctrl + T %2 to use it.").arg("<font style='color:dodgerblue;'>", "</font>"));
appendDescLabel(introLayout, tr("Also, you can directly %1 ask CodeGeeX any questions %2.").arg("<font style='color:dodgerblue;'>", "</font>"));
appendDescLabel(introLayout, tr("Chat provides code completion suggestions in editor, Press %1 Tab %2 to accept.").arg("<font style='color:dodgerblue;'>", "</font>"));
appendDescLabel(introLayout, tr("Chat provides inline chat functionality in editor, Press %1 Ctrl + T %2 to use it.").arg("<font style='color:dodgerblue;'>", "</font>"));
appendDescLabel(introLayout, tr("Also, you can directly %1 ask Chat any questions %2.").arg("<font style='color:dodgerblue;'>", "</font>"));
}

void IntroPage::initSuggestContent()
Expand All @@ -117,17 +117,6 @@ void IntroPage::initSuggestContent()
appendSuggestButton(suggestLayout, tr("What is the best way to start learning JavaScript?"), "codegeex_advice");
}

void IntroPage::initLogoutButton()
{
QHBoxLayout *hlayout = new QHBoxLayout;
auto logoutButton = new DCommandLinkButton(tr("logout"));

hlayout->addWidget(logoutButton);
hlayout->setAlignment(Qt::AlignHCenter);

qobject_cast<QVBoxLayout *>(layout())->addLayout(hlayout);
}

void IntroPage::appendDescLabel(QVBoxLayout *layout, const QString &text)
{
QHBoxLayout *descLayout = new QHBoxLayout;
Expand Down
1 change: 0 additions & 1 deletion src/plugins/codegeex/widgets/intropage.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class IntroPage : public DWidget
void initLogo();
void initIntroContent();
void initSuggestContent();
void initLogoutButton();

void appendDescLabel(QVBoxLayout *layout, const QString &text);
void appendSuggestButton(QVBoxLayout *layout, const QString &text, const QString &iconName = "");
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/codegeex/widgets/messagecomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,18 @@ void MessageComponent::initSenderInfo()
editButton->setFixedSize(QSize(24, 24));
editButton->setToolTip(tr("edit"));

auto currentLLMInfo = CodeGeeXManager::instance()->getCurrentLLMInfo();

switch (messageData.messageType()) {
case MessageData::Ask: {
senderName->setText("You");
senderHead->setPixmap(QIcon::fromTheme("codegeex_user").pixmap(24, 24));
break;
}
case MessageData::Anwser:
senderName->setText("CodeGeeX");
senderHead->setPixmap(QIcon::fromTheme("codegeex_anwser_icon").pixmap(24, 24));
senderName->setText(currentLLMInfo.modelName);
if (!currentLLMInfo.icon.isNull())
senderHead->setPixmap(currentLLMInfo.icon.pixmap(24, 24));
editButton->setVisible(false);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/window/windowelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inline const QString MWNA_DEBUG { QObject::tr("Debug") };
inline const QString MWNA_GIT { QObject::tr("Git") };
inline const QString MWNA_SVN { QObject::tr("Svn") };
inline const QString MWNA_RUNTIME { QObject::tr("Runtime") };
inline const QString MWNA_CODEGEEX { QObject::tr("CodeGeeX") };
inline const QString MWNA_CODEGEEX { QObject::tr("Chat") };
inline const QString MWNA_ADVANCEDSEARCH { QObject::tr("Advanced Search") };

// MWTG = MainWindow TopTool group
Expand Down

0 comments on commit 2e7cbb6

Please sign in to comment.