llm-chat 0.0.0
LLM-Chat
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1#pragma once
2
3#include <QJsonObject>
4#include <QObject>
5#include <QString>
6#include <QVariant>
7#include <QVector>
8
9namespace llm_chat {
10
12class Message : public QObject {
13 Q_OBJECT
14 Q_PROPERTY(QString text READ text CONSTANT FINAL)
15 Q_PROPERTY(bool isUser READ isUser CONSTANT FINAL)
16 Q_PROPERTY(QVector<QVariant> context READ context CONSTANT FINAL)
17 Q_PROPERTY(bool inProgress READ inProgress CONSTANT FINAL)
18
19 public:
26 Message(const QString text, const bool is_user,
27 const QVector<QVariant> &context, const bool in_progress = false,
28 QObject *parent = nullptr);
29
32 [[nodiscard]] QString text() const;
35 void setText(const QString text);
38 [[nodiscard]] bool isUser() const;
42 [[nodiscard]] QVector<QVariant> context() const;
45 void setContext(const QVector<QVariant> &context);
48 [[nodiscard]] bool inProgress() const;
51 void setInProgress(const bool in_progress);
54 void updateFromJson(const QJsonObject &json);
55
56 private:
57 QString m_Text;
58 bool m_IsUser;
59 QVector<QVariant> m_Context;
60 bool m_InProgress{false};
61};
62
63} // namespace llm_chat
64
65Q_DECLARE_METATYPE(llm_chat::Message *)
The Message class represents a chat message.
Definition message.h:12
void setContext(const QVector< QVariant > &context)
Sets the context of the message.
Definition message.cpp:24
QVector< QVariant > context
Definition message.h:16
QString text
Definition message.h:14
void setInProgress(const bool in_progress)
Sets the in progress flag of the message.
Definition message.cpp:30
bool isUser
Definition message.h:15
void updateFromJson(const QJsonObject &json)
Updates the message from a JSON object.
Definition message.cpp:34
bool inProgress
Definition message.h:17
void setText(const QString text)
Sets the text of the message.
Definition message.cpp:18
Definition backend.cpp:11