TextAutoGenerateText::TextAutoGenerateReply Class
class TextAutoGenerateText::TextAutoGenerateReplyThe TextAutoGenerateReply class represents a reply from an LLM. Author: Laurent Montel <montel@kde.org>. More...
| Header: | #include <TextAutoGenerateText/TextAutoGenerateReply> |
| Inherits: | QObject |
Public Types
| struct | DownloadModelInfo |
| struct | Response |
| struct | ToolCallArgument |
| struct | ToolCallArgumentInfo |
| enum class | RequestTypes { Unknown, StreamingGenerate, StreamingChat, ShowModelInfo, DownloadModel, …, StreamingResponses } |
Public Functions
| TextAutoGenerateReply(QNetworkReply *netReply, TextAutoGenerateText::TextAutoGenerateReply::RequestTypes requestType, QObject *parent = nullptr) | |
| virtual | ~TextAutoGenerateReply() override |
| void | cancel() |
| virtual TextAutoGenerateText::TextAutoGenerateReply::Response | readResponse() const = 0 |
| const TextAutoGenerateText::TextAutoGenerateReply::RequestTypes & | requestType() const |
Signals
| void | callTools(const QList<TextAutoGenerateText::TextAutoGenerateReply::ToolCallArgument> &toolsArguments, const QString &toolName) |
| void | canceled() |
| void | contentAdded() |
| void | downloadError(const QString &errorStr) |
| void | downloadInProgress(const TextAutoGenerateText::TextAutoGenerateReply::DownloadModelInfo &info) |
| void | errorOccurred(QNetworkReply::NetworkError e, const QString &errorString) |
| void | finished() |
| void | needOllamaLogin() |
Protected Functions
| QList<TextAutoGenerateText::TextAutoGenerateReply::ToolCallArgumentInfo> | accumulateToolCallsOpenAI(const QJsonArray &array) |
Detailed Description
...
the new content. If you prefer to wait for the entire reply before displaying anything, connect to finished(), which will only be emitted once the reply is complete.
Member Type Documentation
enum class TextAutoGenerateReply::RequestTypes
Specifies the request type.
When the class in instantiated the type of request should be specified
Member Function Documentation
[explicit] TextAutoGenerateReply::TextAutoGenerateReply(QNetworkReply *netReply, TextAutoGenerateText::TextAutoGenerateReply::RequestTypes requestType, QObject *parent = nullptr)
Constructs a new TextAutoGenerateReply object. netReply The QNetworkReply from the network request requestType The type of request being made parent The parent QObject
[override virtual noexcept] TextAutoGenerateReply::~TextAutoGenerateReply()
Destroys the TextAutoGenerateReply object.
[protected] QList<TextAutoGenerateText::TextAutoGenerateReply::ToolCallArgumentInfo> TextAutoGenerateReply::accumulateToolCallsOpenAI(const QJsonArray &array)
In streaming mode, OpenAI sends tool calls in several parts (arguments are split in several strings). Merge array with previous parts and return all tool calls.
[signal] void TextAutoGenerateReply::callTools(const QList<TextAutoGenerateText::TextAutoGenerateReply::ToolCallArgument> &toolsArguments, const QString &toolName)
Emitted when tools need to be called.
void TextAutoGenerateReply::cancel()
Cancels the reply and stops processing.
[signal] void TextAutoGenerateReply::canceled()
Emitted when the reply has been canceled.
[signal] void TextAutoGenerateReply::contentAdded()
Emits when new content has been added to the response.
If you are not streaming the response live, this signal is not of importance to you. However, if you are streaming content, when this signal is emitted, you should call readResponse() to update the response that your application shows.
[signal] void TextAutoGenerateReply::downloadError(const QString &errorStr)
Emitted when a download error occurs.
[signal] void TextAutoGenerateReply::downloadInProgress(const TextAutoGenerateText::TextAutoGenerateReply::DownloadModelInfo &info)
Emitted when a model download is in progress.
[signal] void TextAutoGenerateReply::errorOccurred(QNetworkReply::NetworkError e, const QString &errorString)
Emitted when a network error occurs.
[signal] void TextAutoGenerateReply::finished()
Emits when the LLM has finished returning its response.
After this signal has emitted, the content is guaranteed to not change. At this point, you should call readResponse() to get the content and then either take ownership of the KLLMReply or delete it, as automatic reply deletion is not implemented yet.
[signal] void TextAutoGenerateReply::needOllamaLogin()
Emitted when Ollama login is required.
[pure virtual] TextAutoGenerateText::TextAutoGenerateReply::Response TextAutoGenerateReply::readResponse() const
Reads the response from the LLM. Returns The Response containing the LLM output
const TextAutoGenerateText::TextAutoGenerateReply::RequestTypes &TextAutoGenerateReply::requestType() const
Get request type.
The request type is set when this object is created.
Returns Corresponding request type.