@@ -152,7 +152,10 @@ ChatEditor::ChatEditor()
152152 &ChatManager::followUpQuestionsReceived,
153153 this ,
154154 &ChatEditor::createFollowUpWidget);
155- connect (&chatManager, &ChatManager::messageExtraUpdated, this , &ChatEditor::onMessageExtraUpdated);
155+ connect (&chatManager,
156+ &ChatManager::messageExtraUpdated,
157+ this ,
158+ &ChatEditor::onMessageExtraUpdated);
156159
157160 connect (m_input, &ChatInput::sendRequested, this , &ChatEditor::onSendRequested);
158161 connect (m_input, &ChatInput::stopRequested, this , &ChatEditor::onStopRequested);
@@ -812,22 +815,42 @@ void ChatEditor::updateSpeedLabel(const Message &msg)
812815{
813816 // Update the speed label using the latest timings
814817 if (settings ().showTokensPerSecond .value ()) {
815- const auto &t = msg.timings ;
816- if (t.predicted_ms > 0 && t.prompt_ms > 0 ) {
817- qreal tokensPerSec = (t.predicted_n + t.prompt_n ) * 1000.0
818- / (t.predicted_ms + t.prompt_ms );
819- m_speedLabel->setText (Tr::tr (" Speed: %1 t/s" ).arg (tokensPerSec, 0 , ' f' , 1 ));
820-
821- QString labelTooltip (
822- Tr::tr (" <b>Prompt:</b><br>Tokens: %1<br>Time: %2 ms<br>Speed: %3 t/s<br><br>"
823- " <b>Generation:</b><br>Tokens: %4<br>Time: %5 ms<br>Speed: %6 t/s" )
824- .arg (t.prompt_n )
825- .arg (t.prompt_ms )
826- .arg (t.prompt_n * 1000.0 / t.prompt_ms , 0 , ' f' , 1 )
827- .arg (t.predicted_n )
828- .arg (t.predicted_ms )
829- .arg (t.predicted_n * 1000.0 / t.predicted_ms , 0 , ' f' , 1 ));
818+ if (msg.content .isEmpty () && msg.promptProgress .total > 0 ) {
819+ double processed = msg.promptProgress .processed + msg.promptProgress .cache ;
820+ double percent = (processed / msg.promptProgress .total ) * 100.0 ;
821+
822+ percent = qBound (0.0 , percent, 100.0 );
823+
824+ m_speedLabel->setText (Tr::tr (" Processing: %1%" ).arg (percent, 0 , ' f' , 0 ));
825+
826+ QString labelTooltip = Tr::tr (" <b>Prompt Processing:</b><br>"
827+ " Total Tokens: %1<br>"
828+ " Processed: %2<br>"
829+ " Cached: %3<br>"
830+ " Time: %4 ms" )
831+ .arg (msg.promptProgress .total )
832+ .arg (msg.promptProgress .processed )
833+ .arg (msg.promptProgress .cache )
834+ .arg (msg.promptProgress .time_ms );
830835 m_speedLabel->setToolTip (labelTooltip);
836+ } else if (!msg.content .isEmpty ()) {
837+ const auto &t = msg.timings ;
838+ if (t.predicted_ms > 0 && t.prompt_ms > 0 ) {
839+ qreal tokensPerSec = (t.predicted_n + t.prompt_n ) * 1000.0
840+ / (t.predicted_ms + t.prompt_ms );
841+ m_speedLabel->setText (Tr::tr (" Speed: %1 t/s" ).arg (tokensPerSec, 0 , ' f' , 1 ));
842+
843+ QString labelTooltip (
844+ Tr::tr (" <b>Prompt:</b><br>Tokens: %1<br>Time: %2 ms<br>Speed: %3 t/s<br><br>"
845+ " <b>Generation:</b><br>Tokens: %4<br>Time: %5 ms<br>Speed: %6 t/s" )
846+ .arg (t.prompt_n )
847+ .arg (t.prompt_ms )
848+ .arg (t.prompt_n * 1000.0 / t.prompt_ms , 0 , ' f' , 1 )
849+ .arg (t.predicted_n )
850+ .arg (t.predicted_ms )
851+ .arg (t.predicted_n * 1000.0 / t.predicted_ms , 0 , ' f' , 1 ));
852+ m_speedLabel->setToolTip (labelTooltip);
853+ }
831854 }
832855 }
833856}
0 commit comments