llm-chat 0.0.0
LLM-Chat
Loading...
Searching...
No Matches
llm_chat::Thread Class Reference

The Thread class provides a model for the chat interface. More...

#include <thread.h>

Inheritance diagram for llm_chat::Thread:
[legend]
Collaboration diagram for llm_chat::Thread:
[legend]

Public Types

enum  MessageRoles { TextRole = Qt::UserRole + 1 , IsUserRole , ContextRole , FinishedRole }
 The data roles for the model. More...
 

Public Member Functions

 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.
 

Properties

QList< Message * > messages
 
QDateTime createdAt
 

Detailed Description

The Thread class provides a model for the chat interface.

Member Enumeration Documentation

◆ MessageRoles

The data roles for the model.

Enumerator
TextRole 
IsUserRole 
ContextRole 
FinishedRole 

Constructor & Destructor Documentation

◆ Thread()

llm_chat::Thread::Thread ( QObject * parent = nullptr)
explicit

Constructs a new Thread object.

Parameters
parentThe parent object.

Member Function Documentation

◆ 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
textThe message text.
is_userWhether the message is from the user.
contextThe message context.
in_progressWhether the message is in progress.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearMessages()

void llm_chat::Thread::clearMessages ( )

Clears the list of messages.

Here is the caller graph for this function:

◆ 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
indexThe model index.
roleThe data role.
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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
parentThe parent index.
Here is the caller graph for this function:

Property Documentation

◆ 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: