TextAutoGenerateText::TextAutoGenerateMessagesModel Class
class TextAutoGenerateText::TextAutoGenerateMessagesModelThe TextAutoGenerateMessagesModel class Author: Laurent Montel <montel@kde.org>. More...
| Header: | #include <TextAutoGenerateText/TextAutoGenerateMessagesModel> |
| Inherits: | QAbstractListModel |
Public Types
| enum | MessageRoles { MessageHtmlGeneratedRole, SenderRole, FinishedRole, DateTimeRole, DateTimeStrRole, …, TextToSpeechInProgressRole } |
Public Functions
| TextAutoGenerateMessagesModel(QObject *parent = nullptr) | |
| virtual | ~TextAutoGenerateMessagesModel() override |
| void | addMessage(const TextAutoGenerateText::TextAutoGenerateMessage &msg) |
| void | appendToolExchange(const QByteArray &uuid, const QString &content, const QList<TextAutoGenerateText::TextAutoGenerateReply::ToolCallArgumentInfo> &toolCalls, const QList<QPair<QByteArray, QString>> &results) |
| bool | cancelRequest(const QModelIndex &index) |
| void | changeInProgress(const QByteArray &uuid, bool inProgress) |
| void | changeTextToSpeechInProgress(const QByteArray &uuid, bool inProgress) |
| QByteArray | chatId() const |
| QList<QJsonObject> | convertToOllamaChat(bool hasSystemMessageSupport, bool hasTextOnlySupport, TextAutoGenerateText::TextAutoGenerateMessage::ToolCallFormat format = TextAutoGenerateMessage::ToolCallFormat::OpenAI) const |
| QByteArray | editMessage(const QByteArray &uuid, const QString &str) |
| TextAutoGenerateText::TextAutoGenerateMessage | findLastMessageBefore(const QByteArray &messageId, const std::function<bool (const TextAutoGenerateMessage &)> &predicate) const |
| TextAutoGenerateText::TextAutoGenerateMessage | findNextMessageAfter(const QByteArray &messageId, const std::function<bool (const TextAutoGenerateMessage &)> &predicate) const |
| QModelIndex | indexForUuid(const QByteArray &uuid) const |
| bool | isEmpty() const |
| QByteArray | lastMessageUuid() const |
| TextAutoGenerateText::TextAutoGenerateMessage | message(const QByteArray &uuid) const |
| QList<TextAutoGenerateText::TextAutoGenerateMessage> | messages() const |
| QModelIndex | refreshAnswer(const QByteArray &uuid) const |
| void | refreshMessageColors() |
| void | regenerateHtmlMessage(const QByteArray &identifier, int index) |
| QList<QByteArray> | removeDiscussion(const QByteArray &uuid) |
| void | replaceContent(const QByteArray &uuid, const TextAutoGenerateText::TextAutoGenerateReply::Response &content, const QList<TextAutoGenerateText::TextAutoGenerateAttachmentUtils::AttachmentElementInfo> &attachementInfoList) |
| void | resetConversation() |
| TextAutoGenerateText::TextAutoGenerateSearchMessageSettings * | searchMessageSettings() const |
| QString | searchText() const |
| void | setChatId(const QByteArray &newChatId) |
| void | setMessages(const QList<TextAutoGenerateText::TextAutoGenerateMessage> &newMessages) |
| int | setSearchText(const QString &newSearchText) |
| void | updateMessageInfo(const QByteArray &uuid, const TextAutoGenerateText::TextAutoGenerateAnswerInfo &messageInfo) |
Reimplemented Public Functions
| virtual QVariant | data(const QModelIndex &index, int role) const override |
| virtual int | rowCount(const QModelIndex & = {}) const override |
| virtual bool | setData(const QModelIndex &index, const QVariant &value, int role) override |
Signals
| void | conversationCleared() |
Detailed Description
Member Type Documentation
enum TextAutoGenerateMessagesModel::MessageRoles
The MessageRoles enum
Member Function Documentation
[explicit] TextAutoGenerateMessagesModel::TextAutoGenerateMessagesModel(QObject *parent = nullptr)
Constructs a new TextAutoGenerateMessagesModel object. parent The parent QObject
[override virtual noexcept] TextAutoGenerateMessagesModel::~TextAutoGenerateMessagesModel()
Destroys the TextAutoGenerateMessagesModel object.
void TextAutoGenerateMessagesModel::addMessage(const TextAutoGenerateText::TextAutoGenerateMessage &msg)
Adds a message to the model. msg The message to add
void TextAutoGenerateMessagesModel::appendToolExchange(const QByteArray &uuid, const QString &content, const QList<TextAutoGenerateText::TextAutoGenerateReply::ToolCallArgumentInfo> &toolCalls, const QList<QPair<QByteArray, QString>> &results)
Add tool calls and their results to message uuid. Its content is cleared: it will contain final answer.
bool TextAutoGenerateMessagesModel::cancelRequest(const QModelIndex &index)
Cancels a request at the given index. index The model index Returns true if canceled successfully, false otherwise
void TextAutoGenerateMessagesModel::changeInProgress(const QByteArray &uuid, bool inProgress)
Changes the in-progress state for a message. uuid The message identifier inProgress true if in progress, false otherwise
void TextAutoGenerateMessagesModel::changeTextToSpeechInProgress(const QByteArray &uuid, bool inProgress)
Changes the text-to-speech progress state for a message. uuid The message identifier inProgress true if text-to-speech is in progress, false otherwise
QByteArray TextAutoGenerateMessagesModel::chatId() const
Returns the chat identifier. Returns The chat ID
See also setChatId().
[signal] void TextAutoGenerateMessagesModel::conversationCleared()
Emitted when the conversation is cleared.
QList<QJsonObject> TextAutoGenerateMessagesModel::convertToOllamaChat(bool hasSystemMessageSupport, bool hasTextOnlySupport, TextAutoGenerateText::TextAutoGenerateMessage::ToolCallFormat format = TextAutoGenerateMessage::ToolCallFormat::OpenAI) const
Converts the messages to Ollama chat format. Returns List of messages in JSON object format
[override virtual] QVariant TextAutoGenerateMessagesModel::data(const QModelIndex &index, int role) const
Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.
Returns the data for the given index and role. index The model index role The data role Returns The data value
See also setData().
QByteArray TextAutoGenerateMessagesModel::editMessage(const QByteArray &uuid, const QString &str)
Edits a message with the given content. uuid The message identifier str The new content Returns The UUID of the edited message
TextAutoGenerateText::TextAutoGenerateMessage TextAutoGenerateMessagesModel::findLastMessageBefore(const QByteArray &messageId, const std::function<bool (const TextAutoGenerateMessage &)> &predicate) const
Finds the last message before the given ID that matches the predicate. messageId The reference message ID predicate The filtering predicate Returns The matching message or an empty message if not found
TextAutoGenerateText::TextAutoGenerateMessage TextAutoGenerateMessagesModel::findNextMessageAfter(const QByteArray &messageId, const std::function<bool (const TextAutoGenerateMessage &)> &predicate) const
Finds the next message after the given ID that matches the predicate. messageId The reference message ID predicate The filtering predicate Returns The matching message or an empty message if not found
QModelIndex TextAutoGenerateMessagesModel::indexForUuid(const QByteArray &uuid) const
Returns the model index for a message with the given UUID. uuid The message identifier Returns The model index or an invalid index if not found
bool TextAutoGenerateMessagesModel::isEmpty() const
Returns whether the model is empty. Returns true if empty, false otherwise
QByteArray TextAutoGenerateMessagesModel::lastMessageUuid() const
Returns the UUID of the last message. Returns The UUID or empty if no messages
TextAutoGenerateText::TextAutoGenerateMessage TextAutoGenerateMessagesModel::message(const QByteArray &uuid) const
Returns the message with the given UUID. uuid The message identifier Returns The message or an empty message if not found
QList<TextAutoGenerateText::TextAutoGenerateMessage> TextAutoGenerateMessagesModel::messages() const
Returns all messages in the model. Returns The list of messages
See also setMessages().
QModelIndex TextAutoGenerateMessagesModel::refreshAnswer(const QByteArray &uuid) const
Refreshes the answer at the given UUID. uuid The message identifier Returns The model index of the refreshed message
void TextAutoGenerateMessagesModel::refreshMessageColors()
Refreshes the colors of all messages in the model.
void TextAutoGenerateMessagesModel::regenerateHtmlMessage(const QByteArray &identifier, int index)
Regenerates the HTML representation of a message. identifier The message identifier index The index of the message
QList<QByteArray> TextAutoGenerateMessagesModel::removeDiscussion(const QByteArray &uuid)
Removes a discussion thread starting from the given message UUID. uuid The UUID of the message to remove Returns List of removed message UUIDs
void TextAutoGenerateMessagesModel::replaceContent(const QByteArray &uuid, const TextAutoGenerateText::TextAutoGenerateReply::Response &content, const QList<TextAutoGenerateText::TextAutoGenerateAttachmentUtils::AttachmentElementInfo> &attachementInfoList)
Replaces the content of a message. uuid The message identifier content The new content attachementInfoList List of attachment information
void TextAutoGenerateMessagesModel::resetConversation()
Resets the conversation, clearing all messages.
[override virtual] int TextAutoGenerateMessagesModel::rowCount(const QModelIndex & = {}) const
Reimplements: QAbstractItemModel::rowCount(const QModelIndex &parent) const.
Returns the number of messages in the model. Returns The row count
TextAutoGenerateText::TextAutoGenerateSearchMessageSettings *TextAutoGenerateMessagesModel::searchMessageSettings() const
Returns the search message settings. Returns The TextAutoGenerateSearchMessageSettings instance
QString TextAutoGenerateMessagesModel::searchText() const
Returns the current search text. Returns The search text
See also setSearchText().
void TextAutoGenerateMessagesModel::setChatId(const QByteArray &newChatId)
Sets the chat identifier. newChatId The chat ID to set
See also chatId().
[override virtual] bool TextAutoGenerateMessagesModel::setData(const QModelIndex &index, const QVariant &value, int role)
Reimplements: QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value, int role).
Sets the data for the given index and role. index The model index value The value to set role The data role Returns true if successful, false otherwise
See also data().
void TextAutoGenerateMessagesModel::setMessages(const QList<TextAutoGenerateText::TextAutoGenerateMessage> &newMessages)
Sets the messages in the model. newMessages The messages to set
See also messages().
int TextAutoGenerateMessagesModel::setSearchText(const QString &newSearchText)
Sets the search text and returns the number of matching messages. newSearchText The search text to set Returns The number of messages matching the search text
See also searchText().
void TextAutoGenerateMessagesModel::updateMessageInfo(const QByteArray &uuid, const TextAutoGenerateText::TextAutoGenerateAnswerInfo &messageInfo)
updateMessageInfo uuid messageInfo