mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-25 19:20:16 +00:00
feat: live context window status tracking during streaming
This commit is contained in:
@@ -1159,6 +1159,18 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
|
||||
try{
|
||||
const d=JSON.parse(e.data||'{}');
|
||||
if((d.session_id||activeSid)!==activeSid) return;
|
||||
if(d.usage&&typeof _syncCtxIndicator==='function'){
|
||||
S.lastUsage={...(S.lastUsage||{}),...d.usage};
|
||||
if(S.session&&S.session.session_id===activeSid){
|
||||
S.session.input_tokens=d.usage.input_tokens??S.session.input_tokens;
|
||||
S.session.output_tokens=d.usage.output_tokens??S.session.output_tokens;
|
||||
S.session.estimated_cost=d.usage.estimated_cost??S.session.estimated_cost;
|
||||
S.session.context_length=d.usage.context_length??S.session.context_length;
|
||||
S.session.threshold_tokens=d.usage.threshold_tokens??S.session.threshold_tokens;
|
||||
S.session.last_prompt_tokens=d.usage.last_prompt_tokens??S.session.last_prompt_tokens;
|
||||
}
|
||||
_syncCtxIndicator(S.lastUsage);
|
||||
}
|
||||
if(d.estimated===true||d.tps_available!==true||typeof d.tps!=='number'||d.tps<=0){
|
||||
if(typeof _setLiveAssistantTps==='function') _setLiveAssistantTps(null);
|
||||
return;
|
||||
|
||||
@@ -392,6 +392,17 @@ async function newSession(flash){
|
||||
updateSendBtn();
|
||||
setStatus('');
|
||||
setComposerStatus('');
|
||||
if(typeof _setLiveAssistantTps==='function') _setLiveAssistantTps(null);
|
||||
if(typeof _syncCtxIndicator==='function'){
|
||||
_syncCtxIndicator({
|
||||
input_tokens:data.session.input_tokens||0,
|
||||
output_tokens:data.session.output_tokens||0,
|
||||
estimated_cost:data.session.estimated_cost||0,
|
||||
context_length:data.session.context_length||0,
|
||||
last_prompt_tokens:data.session.last_prompt_tokens||0,
|
||||
threshold_tokens:data.session.threshold_tokens||0,
|
||||
});
|
||||
}
|
||||
updateQueueBadge(S.session.session_id);
|
||||
syncTopbar();renderMessages();loadDir('.');
|
||||
// don't call renderSessionList here - callers do it when needed
|
||||
|
||||
Reference in New Issue
Block a user