Skip to content

Commit d42469f

Browse files
committed
refactor: Singleton exports from service files
1 parent 93ae5dd commit d42469f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

tools/server/webui/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
stopGeneration,
2929
setMaxContextError
3030
} from '$lib/stores/chat.svelte';
31-
import { contextService } from '$lib/services/context';
31+
import { contextService } from '$lib/services';
3232
import { fade, fly, slide } from 'svelte/transition';
3333
import { AUTO_SCROLL_INTERVAL, AUTO_SCROLL_THRESHOLD } from '$lib/constants/auto-scroll';
3434
import { navigating } from '$app/state';

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,5 @@ export class ChatService {
619619
return [systemMsg, ...messages];
620620
}
621621
}
622+
623+
export const chatService = new ChatService();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { ChatService } from './chat';
2-
export { DatabaseStore } from '$lib/stores/database';
1+
export { chatService } from './chat';
2+
export { contextService } from './context';
33
export { slotsService } from './slots';

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { DatabaseStore } from '$lib/stores/database';
2-
import { ChatService } from '$lib/services/chat';
3-
import { slotsService } from '$lib/services/slots';
2+
import { chatService, slotsService } from '$lib/services';
43
import { serverStore } from '$lib/stores/server.svelte';
54
import type {
65
DatabaseConversation,
@@ -58,7 +57,6 @@ class ChatStore {
5857
maxContextError = $state<{ message: string; estimatedTokens: number; maxContext: number } | null>(
5958
null
6059
);
61-
private chatService = new ChatService();
6260

6361
constructor() {
6462
if (browser) {
@@ -270,7 +268,7 @@ class ChatStore {
270268
// Start slots polling when streaming begins
271269
slotsService.startStreamingPolling();
272270

273-
await this.chatService.sendMessage(allMessages, {
271+
await chatService.sendMessage(allMessages, {
274272
...this.getApiOptions(),
275273

276274
onChunk: (chunk: string) => {
@@ -527,7 +525,7 @@ class ChatStore {
527525
*/
528526
stopGeneration() {
529527
slotsService.stopStreamingPolling();
530-
this.chatService.abort();
528+
chatService.abort();
531529
this.savePartialResponseIfNeeded();
532530
this.isLoading = false;
533531
this.currentResponse = '';
@@ -540,7 +538,7 @@ class ChatStore {
540538
if (!this.isLoading) return;
541539

542540
slotsService.stopStreamingPolling();
543-
this.chatService.abort();
541+
chatService.abort();
544542
await this.savePartialResponseIfNeeded();
545543
this.isLoading = false;
546544
this.currentResponse = '';

0 commit comments

Comments
 (0)