mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-06-14 02:09:22 -04:00
refactor: Agent roaster improve
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <AgentConfig.hpp>
|
||||
#include <AgentFactory.hpp>
|
||||
#include <sources/settings/PipelinesConfig.hpp>
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
@@ -52,7 +53,20 @@ void ChatAgentController::setCurrentAgent(const QString &name)
|
||||
|
||||
void ChatAgentController::reload()
|
||||
{
|
||||
m_availableAgents = m_agentFactory ? m_agentFactory->configNames() : QStringList{};
|
||||
const QStringList all = m_agentFactory ? m_agentFactory->configNames() : QStringList{};
|
||||
const QStringList roster = Settings::PipelinesConfig::load().rosters.chatAssistant;
|
||||
|
||||
if (roster.isEmpty()) {
|
||||
m_availableAgents = all;
|
||||
} else {
|
||||
QStringList filtered;
|
||||
for (const QString &name : roster) {
|
||||
if (all.contains(name))
|
||||
filtered.append(name);
|
||||
}
|
||||
m_availableAgents = filtered.isEmpty() ? all : filtered;
|
||||
}
|
||||
|
||||
emit availableAgentsChanged();
|
||||
ensureValidCurrent();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ void ChatCompressor::startCompression(
|
||||
}
|
||||
|
||||
QString sessionError;
|
||||
Session *session = m_sessionManager->createSession(m_activeAgent, &sessionError);
|
||||
Session *session = m_sessionManager->acquire(m_activeAgent, &sessionError);
|
||||
if (!session) {
|
||||
emit compressionFailed(
|
||||
sessionError.isEmpty() ? tr("No chat agent selected") : sessionError);
|
||||
@@ -265,7 +265,7 @@ void ChatCompressor::cleanupState()
|
||||
m_session = nullptr;
|
||||
|
||||
if (session && m_sessionManager)
|
||||
m_sessionManager->removeSession(session);
|
||||
m_sessionManager->release(session);
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
#include "QodeAssistConstants.hpp"
|
||||
|
||||
#include <AgentFactory.hpp>
|
||||
#include <AgentRouter.hpp>
|
||||
#include <ConversationHistory.hpp>
|
||||
#include <Message.hpp>
|
||||
#include <SessionManager.hpp>
|
||||
#include <sources/settings/PipelinesConfig.hpp>
|
||||
|
||||
#include "ChatAgentController.hpp"
|
||||
#include "AgentRole.hpp"
|
||||
@@ -1269,7 +1271,16 @@ void ChatRootView::compressCurrentChat()
|
||||
if (currentChatAgent().isEmpty())
|
||||
loadAvailableChatAgents();
|
||||
m_chatCompressor->setSessionManager(sessionManager());
|
||||
m_chatCompressor->setActiveAgent(currentChatAgent());
|
||||
|
||||
QString compressionAgent = currentChatAgent();
|
||||
const QStringList roster = Settings::PipelinesConfig::load().rosters.chatCompression;
|
||||
if (!roster.isEmpty() && agentFactory()) {
|
||||
const QString picked
|
||||
= AgentRouter::pickAgent(roster, AgentRouter::Context{}, *agentFactory());
|
||||
if (!picked.isEmpty())
|
||||
compressionAgent = picked;
|
||||
}
|
||||
m_chatCompressor->setActiveAgent(compressionAgent);
|
||||
m_chatCompressor->startCompression(m_recentFilePath, m_history);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user