The Thread class provides a model for the chat interface.
More...
#include <thread.h>
|
| Thread (QObject *parent=nullptr) |
| Constructs a new Thread object.
|
|
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| Returns the number of rows under the given parent.
|
|
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| Returns the data stored under the given role for the item referred to by the index.
|
|
QHash< int, QByteArray > | roleNames () const override |
| Returns the role names for the model.
|
|
Q_INVOKABLE void | addMessage (const QString &text, bool is_user, const QVector< QVariant > &context={}, const bool in_progress=false) |
| Adds a new message to the model.
|
|
const QList< Message * > & | messages () const |
| Returns the list of messages.
|
|
void | clearMessages () |
| Clears the list of messages.
|
|
const QDateTime & | createdAt () const |
| Returns the creation time of the chat thread.
|
|
void | removeLatestMessage () |
| Removes the latest message from the model.
|
|
The Thread class provides a model for the chat interface.
◆ MessageRoles
The data roles for the model.
Enumerator |
---|
TextRole | |
IsUserRole | |
ContextRole | |
FinishedRole | |
◆ Thread()
llm_chat::Thread::Thread |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
Constructs a new Thread object.
- Parameters
-
◆ addMessage()
void llm_chat::Thread::addMessage |
( |
const QString & | text, |
|
|
bool | is_user, |
|
|
const QVector< QVariant > & | context = {}, |
|
|
const bool | in_progress = false ) |
Adds a new message to the model.
- Parameters
-
text | The message text. |
is_user | Whether the message is from the user. |
context | The message context. |
in_progress | Whether the message is in progress. |
◆ clearMessages()
void llm_chat::Thread::clearMessages |
( |
| ) |
|
Clears the list of messages.
◆ createdAt()
const QDateTime & llm_chat::Thread::createdAt |
( |
| ) |
const |
|
inlinenodiscard |
Returns the creation time of the chat thread.
- Returns
- The creation time of the chat thread.
◆ data()
QVariant llm_chat::Thread::data |
( |
const QModelIndex & | index, |
|
|
int | role = Qt::DisplayRole ) const |
|
nodiscardoverride |
Returns the data stored under the given role for the item referred to by the index.
- Parameters
-
index | The model index. |
role | The data role. |
◆ messages()
const QList< Message * > & llm_chat::Thread::messages |
( |
| ) |
const |
|
inlinenodiscard |
Returns the list of messages.
- Returns
- The list of messages.
◆ removeLatestMessage()
void llm_chat::Thread::removeLatestMessage |
( |
| ) |
|
Removes the latest message from the model.
◆ roleNames()
QHash< int, QByteArray > llm_chat::Thread::roleNames |
( |
| ) |
const |
|
nodiscardoverride |
Returns the role names for the model.
- Returns
- The role names for the model.
◆ rowCount()
int llm_chat::Thread::rowCount |
( |
const QModelIndex & | parent = QModelIndex() | ) |
const |
|
nodiscardoverride |
Returns the number of rows under the given parent.
- Parameters
-
◆ createdAt
QDateTime llm_chat::Thread::createdAt |
|
read |
◆ messages
QList<Message *> llm_chat::Thread::messages |
|
read |
The documentation for this class was generated from the following files: