mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-06-14 02:09:22 -04:00
refactor: Move QuickRefactor to Session way
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -66,8 +66,6 @@ public:
|
||||
|
||||
LLMQore::RequestID sendText(const QString &text);
|
||||
|
||||
LLMQore::RequestID sendCompletion(Templates::ContextData ctx);
|
||||
|
||||
void cancel();
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user