Move this logic to QML.

This commit is contained in:
Adam Treat 2023-10-29 18:34:42 -04:00
parent f5f22fdbd0
commit f529d55380
3 changed files with 14 additions and 13 deletions

View File

@ -142,17 +142,9 @@ QString Chat::response() const
return m_response;
}
QString Chat::responseState() const
Chat::ResponseState Chat::responseState() const
{
switch (m_responseState) {
case ResponseStopped: return QStringLiteral("response stopped");
case LocalDocsRetrieval: return QStringLiteral("retrieving ") + m_collections.join(", ");
case LocalDocsProcessing: return QStringLiteral("processing ") + m_collections.join(", ");
case PromptProcessing: return QStringLiteral("processing");
case ResponseGeneration: return QStringLiteral("generating response");
};
Q_UNREACHABLE();
return QString();
return m_responseState;
}
void Chat::handleResponseChanged(const QString &response)

View File

@ -21,7 +21,7 @@ class Chat : public QObject
Q_PROPERTY(bool responseInProgress READ responseInProgress NOTIFY responseInProgressChanged)
Q_PROPERTY(bool isRecalc READ isRecalc NOTIFY recalcChanged)
Q_PROPERTY(bool isServer READ isServer NOTIFY isServerChanged)
Q_PROPERTY(QString responseState READ responseState NOTIFY responseStateChanged)
Q_PROPERTY(ResponseState responseState READ responseState NOTIFY responseStateChanged)
Q_PROPERTY(QList<QString> collectionList READ collectionList NOTIFY collectionListChanged)
Q_PROPERTY(QString modelLoadingError READ modelLoadingError NOTIFY modelLoadingErrorChanged)
Q_PROPERTY(QString tokenSpeed READ tokenSpeed NOTIFY tokenSpeedChanged);
@ -68,7 +68,7 @@ public:
QString response() const;
bool responseInProgress() const { return m_responseInProgress; }
QString responseState() const;
ResponseState responseState() const;
ModelInfo modelInfo() const;
void setModelInfo(const ModelInfo &modelInfo);
bool isRecalc() const;

View File

@ -815,8 +815,17 @@ Window {
}
Label {
anchors.verticalCenter: parent.verticalCenter
text: currentChat.responseState + "..."
color: theme.textAccent
text: {
switch (currentChat.responseState) {
case Chat.ResponseStopped: return "response stopped ...";
case Chat.LocalDocsRetrieval: return "retrieving " + currentChat.collectionList.join(", ") + " ...";
case Chat.LocalDocsProcessing: return "processing " + currentChat.collectionList.join(", ") + " ...";
case Chat.PromptProcessing: return "processing ..."
case Chat.ResponseGeneration: return "generating response ...";
default: return ""; // handle unexpected values
}
}
}
}
}