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:
@@ -5,12 +5,13 @@
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QVariantList>
|
||||
#include <QtQml>
|
||||
|
||||
namespace ZShell::llm {
|
||||
|
||||
class ChatMessage;
|
||||
class ChatSession;
|
||||
class LlmClient;
|
||||
|
||||
class ChatGeneration : public QObject {
|
||||
@@ -18,35 +19,39 @@ class ChatGeneration : public QObject {
|
||||
QML_ELEMENT
|
||||
QML_UNCREATABLE("Chat generations are managed by ChatMessage")
|
||||
|
||||
Q_PROPERTY(
|
||||
QString content READ content WRITE setContent NOTIFY contentChanged)
|
||||
Q_PROPERTY(QString content READ content NOTIFY contentChanged)
|
||||
Q_PROPERTY(QString reasoning READ reasoning NOTIFY reasoningChanged)
|
||||
Q_PROPERTY(bool error READ error NOTIFY errorChanged)
|
||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged)
|
||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
||||
Q_PROPERTY(
|
||||
qint64 reasoningElapsedMs READ reasoningElapsedMs NOTIFY
|
||||
elapsedMsChanged)
|
||||
reasoningElapsedMsChanged)
|
||||
Q_PROPERTY(
|
||||
qint64 contentElapsedMs READ contentElapsedMs NOTIFY elapsedMsChanged)
|
||||
Q_PROPERTY(qint64 toolsElapsedMs READ toolsElapsedMs NOTIFY elapsedMsChanged)
|
||||
qint64 contentElapsedMs READ contentElapsedMs NOTIFY
|
||||
contentElapsedMsChanged)
|
||||
Q_PROPERTY(
|
||||
qint64 toolsElapsedMs READ toolsElapsedMs NOTIFY toolsElapsedMsChanged)
|
||||
Q_PROPERTY(bool streaming READ streaming NOTIFY streamingChanged)
|
||||
Q_PROPERTY(
|
||||
bool reasoningActive READ reasoningActive NOTIFY reasoningActiveChanged)
|
||||
Q_PROPERTY(bool hasRunningTool READ hasRunningTool NOTIFY toolStateChanged)
|
||||
Q_PROPERTY(
|
||||
bool hasRunningTool READ hasRunningTool NOTIFY hasRunningToolChanged)
|
||||
Q_PROPERTY(qint64 timestamp READ timestamp CONSTANT)
|
||||
Q_PROPERTY(
|
||||
QList<ZShell::llm::LlmSegment*> segments READ segments NOTIFY
|
||||
segmentsChanged)
|
||||
Q_PROPERTY(int toolCallCount READ toolCallCount NOTIFY segmentsChanged)
|
||||
Q_PROPERTY(int toolCallCount READ toolCallCount NOTIFY toolCallCountChanged)
|
||||
Q_PROPERTY(
|
||||
bool toolApprovalPending READ toolApprovalPending NOTIFY
|
||||
toolApprovalPendingChanged)
|
||||
Q_PROPERTY(
|
||||
QVariantList pendingToolCalls READ pendingToolCalls NOTIFY
|
||||
toolApprovalPendingChanged)
|
||||
pendingToolCallsChanged)
|
||||
|
||||
public:
|
||||
explicit ChatGeneration(qint64 timestamp, QObject* parent = nullptr);
|
||||
ChatGeneration(ChatMessage* message, qint64 timestamp, QObject* parent);
|
||||
|
||||
[[nodiscard]] ChatMessage* message() const;
|
||||
|
||||
[[nodiscard]] QString content() const;
|
||||
[[nodiscard]] QString reasoning() const;
|
||||
@@ -59,12 +64,12 @@ class ChatGeneration : public QObject {
|
||||
[[nodiscard]] bool streaming() const { return m_streaming; }
|
||||
[[nodiscard]] qint64 timestamp() const { return m_timestamp; }
|
||||
[[nodiscard]] QList<LlmSegment*> segments() const { return m_segments; }
|
||||
[[nodiscard]] QList<LlmToolCall*> toolCalls() const;
|
||||
[[nodiscard]] int toolCallCount() const;
|
||||
[[nodiscard]] bool hasRunningTool() const;
|
||||
[[nodiscard]] bool hasPendingTool() const;
|
||||
|
||||
[[nodiscard]] bool toolApprovalPending() const { return m_approvalPending; }
|
||||
void setApprovalPending(bool value);
|
||||
[[nodiscard]] QVariantList pendingToolCalls() const;
|
||||
|
||||
Q_INVOKABLE void approveTools();
|
||||
@@ -76,10 +81,10 @@ class ChatGeneration : public QObject {
|
||||
void appendReasoning(const QString& piece);
|
||||
void setStreaming(bool value);
|
||||
void setError(const QString& value);
|
||||
void setApprovalPending(bool value);
|
||||
|
||||
[[nodiscard]] LlmSegment* openContentSegment();
|
||||
[[nodiscard]] LlmSegment* openReasoningSegment();
|
||||
[[nodiscard]] LlmSegment* beginToolCall(
|
||||
[[nodiscard]] LlmTextSegment* openTextSegment(LlmSegment::Type type);
|
||||
[[nodiscard]] LlmToolCall* beginToolCall(
|
||||
const QString& name, const QString& toolCallId);
|
||||
void addSegment(LlmSegment* segment);
|
||||
void closeOpenSegments();
|
||||
@@ -88,17 +93,23 @@ class ChatGeneration : public QObject {
|
||||
void contentChanged();
|
||||
void reasoningChanged();
|
||||
void errorChanged();
|
||||
void errorMessageChanged();
|
||||
void reasoningActiveChanged();
|
||||
void elapsedMsChanged();
|
||||
void reasoningElapsedMsChanged();
|
||||
void contentElapsedMsChanged();
|
||||
void toolsElapsedMsChanged();
|
||||
void streamingChanged();
|
||||
void toolStateChanged();
|
||||
void hasRunningToolChanged();
|
||||
void segmentsChanged();
|
||||
void toolCallCountChanged();
|
||||
void toolApprovalPendingChanged();
|
||||
void pendingToolCallsChanged();
|
||||
|
||||
private:
|
||||
void updateReasoningActive();
|
||||
LlmClient* client() const;
|
||||
[[nodiscard]] LlmClient* client() const;
|
||||
|
||||
ChatMessage* m_message;
|
||||
QTimer m_timer;
|
||||
QList<LlmSegment*> m_segments;
|
||||
bool m_reasoningActive = false;
|
||||
|
||||
Reference in New Issue
Block a user