Skip to content

Commit 43a7192

Browse files
committed
chore: Code formatting
1 parent 3aa9a5e commit 43a7192

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

tools/server/webui/src/lib/services/chat.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class ChatService {
285285

286286
try {
287287
const parsed: ApiChatCompletionStreamChunk = JSON.parse(data);
288-
288+
289289
const content = parsed.choices[0]?.delta?.content;
290290
const reasoningContent = parsed.choices[0]?.delta?.reasoning_content;
291291
const timings = parsed.timings;
@@ -642,13 +642,15 @@ export class ChatService {
642642
: 0;
643643

644644
// Update slots service with timing data (async but don't wait)
645-
slotsService.updateFromTimingData({
646-
prompt_n: timings.prompt_n || 0,
647-
predicted_n: timings.predicted_n || 0,
648-
predicted_per_second: tokensPerSecond
649-
}).catch(error => {
650-
console.warn('Failed to update processing state:', error);
651-
});
645+
slotsService
646+
.updateFromTimingData({
647+
prompt_n: timings.prompt_n || 0,
648+
predicted_n: timings.predicted_n || 0,
649+
predicted_per_second: tokensPerSecond
650+
})
651+
.catch((error) => {
652+
console.warn('Failed to update processing state:', error);
653+
});
652654
}
653655
}
654656

tools/server/webui/src/lib/services/slots.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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');

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,16 @@ class ChatStore {
276276
if (currentConfig.dry_base !== undefined && currentConfig.dry_base !== null) {
277277
apiOptions.dry_base = Number(currentConfig.dry_base);
278278
}
279-
if (currentConfig.dry_allowed_length !== undefined && currentConfig.dry_allowed_length !== null) {
279+
if (
280+
currentConfig.dry_allowed_length !== undefined &&
281+
currentConfig.dry_allowed_length !== null
282+
) {
280283
apiOptions.dry_allowed_length = Number(currentConfig.dry_allowed_length);
281284
}
282-
if (currentConfig.dry_penalty_last_n !== undefined && currentConfig.dry_penalty_last_n !== null) {
285+
if (
286+
currentConfig.dry_penalty_last_n !== undefined &&
287+
currentConfig.dry_penalty_last_n !== null
288+
) {
283289
apiOptions.dry_penalty_last_n = Number(currentConfig.dry_penalty_last_n);
284290
}
285291
if (currentConfig.samplers) {
@@ -329,7 +335,6 @@ class ChatStore {
329335
streamedReasoningContent += reasoningChunk;
330336
const messageIndex = this.findMessageIndex(assistantMessage.id);
331337
this.updateMessageAtIndex(messageIndex, { thinking: streamedReasoningContent });
332-
333338
},
334339

335340
onComplete: async (finalContent?: string, reasoningContent?: string) => {

0 commit comments

Comments
 (0)