refactor: Move QuickRefactor to Session way

This commit is contained in:
Petr Mironychev
2026-06-11 14:18:44 +02:00
parent 7bfe9d6f0e
commit e65ac23e66
7 changed files with 83 additions and 87 deletions

View File

@@ -31,6 +31,24 @@ private:
QString m_mediaType;
};
class CompletionContent : public LLMQore::ContentBlock
{
public:
CompletionContent(QString prefix, QString suffix)
: m_prefix(std::move(prefix))
, m_suffix(std::move(suffix))
{}
QString type() const override { return QStringLiteral("completion"); }
QString prefix() const { return m_prefix; }
QString suffix() const { return m_suffix; }
private:
QString m_prefix;
QString m_suffix;
};
class StoredAttachmentContent : public LLMQore::ContentBlock
{
public:

View File

@@ -134,17 +134,6 @@ LLMQore::RequestID Session::sendText(const QString &text)
return send(std::move(blocks));
}
LLMQore::RequestID Session::sendCompletion(Templates::ContextData ctx)
{
if (!isValid()) {
m_lastError = makeError(ErrorCategory::Config, invalidReason());
return {};
}
if (isInFlight())
cancel();
return dispatchContext(std::move(ctx), /*tools=*/false);
}
LLMQore::RequestID Session::send(
std::vector<std::unique_ptr<LLMQore::ContentBlock>> userBlocks,
std::optional<bool> toolsOverride)
@@ -290,6 +279,12 @@ Templates::ContextData Session::buildLegacyContext(
if (m.role() == Message::Role::System)
continue;
if (auto *cc = m.lastBlockOfType<CompletionContent>()) {
ctx.prefix = cc->prefix();
ctx.suffix = cc->suffix();
continue;
}
QVector<ContentBlockEntry> blockEntries;
for (const auto &blockPtr : m.blocks()) {

View File

@@ -66,8 +66,6 @@ public:
LLMQore::RequestID sendText(const QString &text);
LLMQore::RequestID sendCompletion(Templates::ContextData ctx);
void cancel();
signals: