Skip to content

Commit

Permalink
fix: [codegeex] incorrect ui of codeggex
Browse files Browse the repository at this point in the history
1. hide codebase Button when env do not support miniforge
2. clear selectCodeTag when no selected code

Log: as title
  • Loading branch information
LiHua000 committed Nov 19, 2024
1 parent 06641cb commit b8e422e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/plugins/codegeex/codegeex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ bool CodeGeex::start()
using namespace std::placeholders;
auto aiService = dpfGetService(dpfservice::AiService);
aiService->available = std::bind(&CodeGeeXManager::isLoggedIn, CodeGeeXManager::instance());
aiService->askQuestion = std::bind(&CodeGeeXManager::independentAsking, CodeGeeXManager::instance(), _1, _2);
aiService->askQuestion = std::bind(&CodeGeeXManager::independentAsking, CodeGeeXManager::instance(), _1, QMultiMap<QString, QString>(), _2);
aiService->askQuestionWithHistory = std::bind(&CodeGeeXManager::independentAsking, CodeGeeXManager::instance(), _1, _2, _3);

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/codegeex/codegeexmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ void CodeGeeXManager::setReferenceFiles(const QStringList &files)
askApi.setReferenceFiles(files);
}

void CodeGeeXManager::independentAsking(const QString &prompt, QIODevice *pipe)
void CodeGeeXManager::independentAsking(const QString &prompt, const QMultiMap<QString, QString> &history, QIODevice *pipe)
{
if (!isLoggedIn()) {
emit notify(1, tr("CodeGeeX is not avaliable, please logging in"));
pipe->close();
return;
}
AskApi *api = new AskApi;
api->postSSEChat(kUrlSSEChat, sessionId, prompt, QSysInfo::machineUniqueId(), {}, currentTalkID);
api->postSSEChat(kUrlSSEChat, sessionId, prompt, QSysInfo::machineUniqueId(), history, currentTalkID);
QTimer::singleShot(10000, api, [=](){
if (pipe && pipe->isOpen()) {
qWarning() << "timed out, close pipe";
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/codegeex/codegeexmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CodeGeeXManager : public QObject
bool isReferenceCodebase() const;
void setReferenceFiles(const QStringList &files);

void independentAsking(const QString &prompt, QIODevice *pipe);
void independentAsking(const QString &prompt, const QMultiMap<QString, QString> &history, QIODevice *pipe);
// Rag
QString condaRootPath() const;
void showIndexingWidget();
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/codegeex/widgets/inputeditwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ void InputEditWidgetPrivate::initButtonBox()
codeBaseBtn->setIcon(QIcon::fromTheme("uc_codegeex_project_chat"));
codeBaseBtn->setToolTip(InputEditWidget::tr("reference codebase"));
codeBaseBtn->setCheckable(true);
#ifndef SUPPORTMINIFORGE
codeBaseBtn->hide();
#endif

referenceBtn = new DToolButton(q);
referenceBtn->setFixedSize(24, 24);
Expand Down Expand Up @@ -252,8 +255,13 @@ InputEdit::InputEdit(QWidget *parent)
auto editorService = dpfGetService(EditorService);
QString currentFile = editorService->currentFile();
QString selectedCode = editorService->getSelectedText();
if (currentFile.isEmpty() || selectedCode.isEmpty())
if (currentFile.isEmpty() || selectedCode.isEmpty()) {
if (!selectedCodeTag.isEmpty())
removeTag(selectedCodeTag);
this->selectedCode.clear();
this->selectedCodeTag.clear();
return;
}

Edit::Range selectedRange = editorService->selectionRange(currentFile);
QString tagText = QString("%1:L%2C%3-L%4C%5").arg(QFileInfo(currentFile).fileName(),
Expand Down
1 change: 1 addition & 0 deletions src/services/ai/aiservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SERVICE_EXPORT AiService final : public dpf::PluginService, dpf::AutoServi

DPF_INTERFACE(bool, available);
DPF_INTERFACE(void, askQuestion, const QString &prompt, QIODevice *pipe); // pipe recevice data from ai
DPF_INTERFACE(void, askQuestionWithHistory, const QString &prompt, const QMultiMap<QString, QString> history, QIODevice *pipe);
};

} // namespace dpfservice
Expand Down

0 comments on commit b8e422e

Please sign in to comment.