mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-01 02:29:13 -04:00
fix: Improve agents profiles for Ollama
This commit is contained in:
@@ -18,7 +18,10 @@ namespace QodeAssist {
|
|||||||
SessionManager::SessionManager(AgentFactory *agentFactory, QObject *parent)
|
SessionManager::SessionManager(AgentFactory *agentFactory, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_agentFactory(agentFactory)
|
, m_agentFactory(agentFactory)
|
||||||
{}
|
{
|
||||||
|
if (m_agentFactory)
|
||||||
|
connect(m_agentFactory, &AgentFactory::agentsChanged, this, &SessionManager::flushPool);
|
||||||
|
}
|
||||||
|
|
||||||
SessionManager::~SessionManager() = default;
|
SessionManager::~SessionManager() = default;
|
||||||
|
|
||||||
@@ -101,7 +104,7 @@ Session *SessionManager::acquire(const QString &agentName, QString *errorOut)
|
|||||||
auto &bucket = m_pool[agentName];
|
auto &bucket = m_pool[agentName];
|
||||||
while (!bucket.isEmpty()) {
|
while (!bucket.isEmpty()) {
|
||||||
QPointer<Session> pooled = bucket.takeLast();
|
QPointer<Session> pooled = bucket.takeLast();
|
||||||
if (pooled && pooled->isValid()) {
|
if (pooled && pooled->isValid() && pooledAgentMatchesCurrent(pooled, agentName)) {
|
||||||
resetSession(pooled);
|
resetSession(pooled);
|
||||||
m_sessions.append(pooled);
|
m_sessions.append(pooled);
|
||||||
return pooled.data();
|
return pooled.data();
|
||||||
@@ -154,6 +157,32 @@ void SessionManager::resetSession(Session *session)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SessionManager::pooledAgentMatchesCurrent(Session *session, const QString &agentName) const
|
||||||
|
{
|
||||||
|
if (!m_agentFactory)
|
||||||
|
return true;
|
||||||
|
Agent *agent = session ? session->agent() : nullptr;
|
||||||
|
if (!agent)
|
||||||
|
return false;
|
||||||
|
const AgentConfig *current = m_agentFactory->configByName(agentName);
|
||||||
|
if (!current)
|
||||||
|
return false;
|
||||||
|
const AgentConfig &snapshot = agent->config();
|
||||||
|
return snapshot.model == current->model
|
||||||
|
&& snapshot.providerInstance == current->providerInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionManager::flushPool()
|
||||||
|
{
|
||||||
|
for (auto &bucket : m_pool) {
|
||||||
|
for (const QPointer<Session> &pooled : bucket) {
|
||||||
|
if (pooled)
|
||||||
|
pooled->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_pool.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void SessionManager::removeSession(Session *session)
|
void SessionManager::removeSession(Session *session)
|
||||||
{
|
{
|
||||||
if (!session)
|
if (!session)
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void resetSession(Session *session);
|
void resetSession(Session *session);
|
||||||
|
void flushPool();
|
||||||
|
[[nodiscard]] bool pooledAgentMatchesCurrent(
|
||||||
|
Session *session, const QString &agentName) const;
|
||||||
|
|
||||||
static constexpr int kMaxPooledPerAgent = 2;
|
static constexpr int kMaxPooledPerAgent = 2;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<file>ollama_chat_completion.toml</file>
|
<file>ollama_chat_completion.toml</file>
|
||||||
<file>ollama_base_fim.toml</file>
|
<file>ollama_base_fim.toml</file>
|
||||||
<file>ollama_fim.toml</file>
|
<file>ollama_fim.toml</file>
|
||||||
|
<file>ollama_codellama_qml_fim.toml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/roles">
|
<qresource prefix="/roles">
|
||||||
<file alias="qt-cpp-developer.md">roles/qt-cpp-developer.md</file>
|
<file alias="qt-cpp-developer.md">roles/qt-cpp-developer.md</file>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ system_prompt = """
|
|||||||
|
|
||||||
[body]
|
[body]
|
||||||
max_tokens = 512
|
max_tokens = 512
|
||||||
temperature = 0
|
temperature = 0.2
|
||||||
stop_sequences = ["</code_context>"]
|
stop_sequences = ["</code_context>"]
|
||||||
messages = """
|
messages = """
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ messages = """
|
|||||||
|
|
||||||
[body.options]
|
[body.options]
|
||||||
num_predict = 512
|
num_predict = 512
|
||||||
temperature = 0
|
temperature = 0.2
|
||||||
num_ctx = 8192
|
|
||||||
keep_alive = "5m"
|
keep_alive = "5m"
|
||||||
stop = ["</code_context>"]
|
stop = ["</code_context>"]
|
||||||
23
sources/agents/ollama_codellama_qml_fim.toml
Normal file
23
sources/agents/ollama_codellama_qml_fim.toml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
schema_version = 1
|
||||||
|
|
||||||
|
name = "Ollama CodeLlama QML FIM"
|
||||||
|
description = "Local Ollama FIM for the CodeLlama-13B QML fine-tune (raw passthrough Modelfile, suffix-first markers)."
|
||||||
|
|
||||||
|
provider_instance = "Ollama (Native)"
|
||||||
|
endpoint = "/api/generate"
|
||||||
|
|
||||||
|
model = "theqtcompany/codellama-7b-qml"
|
||||||
|
tags = ["completion", "ollama", "local", "fim", "qml"]
|
||||||
|
|
||||||
|
[match]
|
||||||
|
file_patterns = ["*.qml"]
|
||||||
|
|
||||||
|
[body]
|
||||||
|
prompt = """{{ tojson("<SUF>" + ctx.suffix + "<PRE>" + ctx.prefix + "<MID>") }}"""
|
||||||
|
|
||||||
|
[body.options]
|
||||||
|
temperature = 0
|
||||||
|
top_p = 1
|
||||||
|
repeat_penalty = 1.05
|
||||||
|
num_predict = 500
|
||||||
|
stop = ["<SUF>", "<PRE>", "</PRE>", "</SUF>", "< EOT >", "\\end", "<MID>", "</MID>", "##"]
|
||||||
@@ -10,7 +10,4 @@ tags = ["completion", "ollama", "local", "fim"]
|
|||||||
[body.options]
|
[body.options]
|
||||||
num_predict = 512
|
num_predict = 512
|
||||||
temperature = 0.2
|
temperature = 0.2
|
||||||
top_p = 0.9
|
|
||||||
num_ctx = 8192
|
|
||||||
keep_alive = "5m"
|
keep_alive = "5m"
|
||||||
stop = ["<EOT>"]
|
|
||||||
|
|||||||
Reference in New Issue
Block a user