chore: restructure llm plugin to be more coherent & fix various bugs in llm ui
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Python / verify (pull_request) Successful in 1m35s
Rust / fmt (pull_request) Successful in 36s
Rust / clippy (pull_request) Successful in 54s
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Python / verify (pull_request) Successful in 1m35s
Rust / fmt (pull_request) Successful in 36s
Rust / clippy (pull_request) Successful in 54s
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
#include "generation.hpp"
|
||||
#include "segment.hpp"
|
||||
#include "tool.hpp"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
namespace ZShell::llm {
|
||||
|
||||
class ChatSession;
|
||||
|
||||
class Turn {
|
||||
public:
|
||||
Turn(
|
||||
ChatSession* session,
|
||||
ChatGeneration* generation,
|
||||
const ToolRegistry& registry);
|
||||
|
||||
[[nodiscard]] ChatSession* session() const { return m_session; }
|
||||
[[nodiscard]] ChatGeneration* generation() const { return m_generation; }
|
||||
[[nodiscard]] const ToolRegistry& registry() const { return m_registry; }
|
||||
|
||||
[[nodiscard]] QJsonArray contextMessages() const;
|
||||
[[nodiscard]] int transcriptTokens() const;
|
||||
[[nodiscard]] int promptBudgetTokens() const;
|
||||
|
||||
[[nodiscard]] int targetRow() const;
|
||||
|
||||
void resetRound();
|
||||
|
||||
[[nodiscard]] QJsonObject roundAssistantMessage();
|
||||
[[nodiscard]] QJsonArray toolMessages() const;
|
||||
[[nodiscard]] bool roundHasCalls() const;
|
||||
|
||||
struct Call {
|
||||
QString id;
|
||||
QString name;
|
||||
QString arguments;
|
||||
QPointer<LlmToolCall> segment;
|
||||
bool seen = false;
|
||||
};
|
||||
|
||||
QList<Call>& calls() { return m_calls; }
|
||||
[[nodiscard]] const QList<Call>& calls() const { return m_calls; }
|
||||
|
||||
QList<ToolResult>& results() { return m_results; }
|
||||
[[nodiscard]] const QList<ToolResult>& results() const { return m_results; }
|
||||
|
||||
void appendToTranscript(const QJsonObject& message);
|
||||
[[nodiscard]] const QJsonArray& transcript() const { return m_transcript; }
|
||||
|
||||
[[nodiscard]] int batchSize() const;
|
||||
[[nodiscard]] int outputBudgetChars() const;
|
||||
|
||||
int round = 0;
|
||||
int pendingCalls = 0;
|
||||
bool roundDone = false;
|
||||
bool streamDone = false;
|
||||
bool toolPhase = false;
|
||||
bool approvalPending = false;
|
||||
bool contextRetryUsed = false;
|
||||
QString finishReason;
|
||||
|
||||
private:
|
||||
void appendSandboxPreamble(QJsonArray& messages) const;
|
||||
|
||||
ChatSession* m_session;
|
||||
ChatGeneration* m_generation;
|
||||
const ToolRegistry& m_registry;
|
||||
QJsonArray m_transcript;
|
||||
QList<Call> m_calls;
|
||||
QList<ToolResult> m_results;
|
||||
qsizetype m_contentMark = 0;
|
||||
qsizetype m_reasoningMark = 0;
|
||||
};
|
||||
|
||||
} // namespace ZShell::llm
|
||||
Reference in New Issue
Block a user