@@ -4,7 +4,7 @@ import { config } from '$lib/stores/settings.svelte';
44/**
55 * SlotsService - Real-time processing state monitoring and token rate calculation
66 *
7- * This service provides real-time information about generation progress, token rates,
7+ * This service provides real-time information about generation progress, token rates,
88 * and context usage based on timing data from ChatService streaming responses.
99 * It manages streaming session tracking and provides accurate processing state updates.
1010 *
@@ -66,7 +66,9 @@ export class SlotsService {
6666 * This method logs a warning if called to help identify outdated usage
6767 */
6868 fetchAndNotify ( ) : void {
69- console . warn ( 'SlotsService.fetchAndNotify() is deprecated - use timing data from ChatService instead' ) ;
69+ console . warn (
70+ 'SlotsService.fetchAndNotify() is deprecated - use timing data from ChatService instead'
71+ ) ;
7072 }
7173
7274 subscribe ( callback : ( state : ApiProcessingState ) => void ) : ( ) => void {
@@ -85,13 +87,13 @@ export class SlotsService {
8587 predicted_per_second : number ;
8688 } ) : Promise < void > {
8789 const processingState = await this . parseCompletionTimingData ( timingData ) ;
88-
90+
8991 // Only update if we successfully parsed the state
9092 if ( processingState === null ) {
9193 console . warn ( 'Failed to parse timing data - skipping update' ) ;
9294 return ;
9395 }
94-
96+
9597 this . lastKnownState = processingState ;
9698
9799 for ( const callback of this . callbacks ) {
@@ -132,15 +134,17 @@ export class SlotsService {
132134 return 4096 ;
133135 }
134136
135- private async parseCompletionTimingData ( timingData : Record < string , unknown > ) : Promise < ApiProcessingState | null > {
137+ private async parseCompletionTimingData (
138+ timingData : Record < string , unknown >
139+ ) : Promise < ApiProcessingState | null > {
136140 // Extract timing information from /chat/completions response
137141 const promptTokens = ( timingData . prompt_n as number ) || 0 ;
138142 const predictedTokens = ( timingData . predicted_n as number ) || 0 ;
139143 const tokensPerSecond = ( timingData . predicted_per_second as number ) || 0 ;
140144
141145 // Get context total from server or cache
142146 const contextTotal = await this . getContextTotal ( ) ;
143-
147+
144148 if ( contextTotal === null ) {
145149 console . warn ( 'No context total available - cannot calculate processing state' ) ;
146150 return null ;
@@ -149,7 +153,7 @@ export class SlotsService {
149153 // Get output max tokens from user settings
150154 const currentConfig = config ( ) ;
151155 const outputTokensMax = currentConfig . max_tokens ;
152-
156+
153157 // Validate required data is available
154158 if ( ! outputTokensMax ) {
155159 console . warn ( 'No max_tokens setting available' ) ;
0 commit comments