@@ -21,6 +21,8 @@ const kMmojoCompletion = "Mmojo Completion";
2121const kStatus_TypeSomething = "Awaiting your cue." ;
2222const kStatus_Ready = "Ready." ;
2323const kStatus_Evaluating = "Evaluating." ;
24+ const kStatus_EvaluatingProgress = "Evaluating " ;
25+ const kStatus_EvaulatingFinishing = "Finishing evaluating." ;
2426const kStatus_Generating = "Generating." ;
2527const kStatus_FinishedGenerating = "Finished generating." ;
2628const kStatus_StoppedByWord = "Stopped by \"[stopping_word]\"." ;
@@ -456,6 +458,8 @@ var manualStop = false;
456458var generatedContent = '' ;
457459
458460async function StartGenerating ( workAreaText , temperature , tokens , stopWords ) {
461+ let logThis = true ;
462+
459463 // show that we're working??
460464 SetStatus ( kStatus_Evaluating ) ;
461465
@@ -466,6 +470,7 @@ async function StartGenerating(workAreaText, temperature, tokens, stopWords) {
466470 "n_predict" : tokens ,
467471 "temperature" : temperature ,
468472 "stream" : true ,
473+ "include_prompt_progress" : true ,
469474 }
470475
471476 if ( stopWords . length > 0 ) {
@@ -530,15 +535,34 @@ async function StartGenerating(workAreaText, temperature, tokens, stopWords) {
530535
531536 if ( match ) {
532537 lineData [ match [ 1 ] ] = match [ 2 ] ; // data: { whatever }
533- if ( kLogging ) console . log ( match [ 1 ] + ": " + match [ 2 ] ) ;
538+ if ( kLogging || logThis ) console . log ( match [ 1 ] + ": " + match [ 2 ] ) ;
534539 }
535540
536541 if ( lineData . data ) {
537542 lineData . data = JSON . parse ( lineData . data ) ;
538543
539- if ( kLogging ) console . log ( lineData . data ) ;
544+ if ( kLogging || logThis ) console . log ( lineData . data ) ;
545+
546+ if ( "prompt_processing" in lineData . data ) {
547+ if ( kLogging || logThis ) console . log ( "Prompt processing:" ) ;
548+ if ( kLogging || logThis ) console . log ( lineData . data . prompt_processing ) ;
549+
550+ let n_past = lineData . data . prompt_processing . n_past ;
551+ let n_prompt_tokens = lineData . data . prompt_processing . n_prompt_tokens ;
552+
553+ if ( kLogging || logThis ) console . log ( "n_past: " + n_past ) ;
554+ if ( kLogging || logThis ) console . log ( "n_prompt_tokens: " + n_prompt_tokens ) ;
555+
556+ if ( n_past < n_prompt_tokens ) {
557+ let status = kStatus_EvaluatingProgress + " " + n_past + " / " + n_prompt_tokens ;
558+ SetStatus ( status ) ;
559+ }
560+ else {
561+ SetStatus ( kStatus_EvaulatingFinishing ) ;
562+ }
563+ }
540564
541- if ( ( lineData . data . stop_type == "word" ) && lineData . data . stopping_word !== "" ) {
565+ else if ( ( lineData . data . stop_type == "word" ) && lineData . data . stopping_word !== "" ) {
542566 // if (kLogging) console.log("stopping_word: " + lineData.data.stopping_word);
543567 SetStatus ( kStatus_StoppedByWord . replace ( '[stopping_word]' , lineData . data . stopping_word ) ) ;
544568
@@ -563,7 +587,7 @@ async function StartGenerating(workAreaText, temperature, tokens, stopWords) {
563587 // elements.workAreaText.scrollTop = elements.workAreaText.scrollHeight
564588 // don't set selectionStart, selectionEnd?
565589
566- if ( kLogging ) console . log ( "end of strem" ) ;
590+ if ( kLogging || logThis ) console . log ( "end of strem" ) ;
567591 controller = null ;
568592 ShowHideStatusButtons ( ) ;
569593 }
@@ -598,9 +622,9 @@ async function StartGenerating(workAreaText, temperature, tokens, stopWords) {
598622 }
599623 }
600624 catch ( exc ) {
601- if ( kLogging ) console . log ( "Exception caught receiving results." ) ;
602- if ( kLogging ) console . log ( exc . name ) ;
603- if ( kLogging ) console . log ( exc . message ) ;
625+ if ( kLogging || logThis ) console . log ( "Exception caught receiving results." ) ;
626+ if ( kLogging || logThis ) console . log ( exc . name ) ;
627+ if ( kLogging || logThis ) console . log ( exc . message ) ;
604628
605629 // I thought this might be a checkbox in settings, but that felt clumsy.
606630 // These are mostly network errors. It would be good for the user to know.
0 commit comments