diff --git a/backend/src/chat/chat.resolver.ts b/backend/src/chat/chat.resolver.ts index 431c9916..57fc8bfd 100644 --- a/backend/src/chat/chat.resolver.ts +++ b/backend/src/chat/chat.resolver.ts @@ -53,7 +53,7 @@ export class ChatResolver { MessageRole.User, ); - const iterator = this.chatProxyService.streamChat(input.message); + const iterator = this.chatProxyService.streamChat(input); let accumulatedContent = ''; for await (const chunk of iterator) { diff --git a/backend/src/chat/chat.service.ts b/backend/src/chat/chat.service.ts index 0e5579b1..e1b356ad 100644 --- a/backend/src/chat/chat.service.ts +++ b/backend/src/chat/chat.service.ts @@ -5,7 +5,11 @@ import { Message, MessageRole } from 'src/chat/message.model'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { User } from 'src/user/user.model'; -import { NewChatInput, UpdateChatTitleInput } from 'src/chat/dto/chat.input'; +import { + ChatInput, + NewChatInput, + UpdateChatTitleInput, +} from 'src/chat/dto/chat.input'; type CustomAsyncIterableIterator = AsyncIterator & { [Symbol.asyncIterator](): AsyncIterableIterator; @@ -17,8 +21,12 @@ export class ChatProxyService { constructor(private httpService: HttpService) {} - streamChat(input: string): CustomAsyncIterableIterator { - this.logger.debug('request chat input: ' + input); + streamChat( + input: ChatInput, + ): CustomAsyncIterableIterator { + this.logger.debug( + `Request chat input: ${input.message} with model: ${input.model}`, + ); let isDone = false; let responseSubscription: any; const chunkQueue: ChatCompletionChunk[] = []; @@ -60,7 +68,7 @@ export class ChatProxyService { responseSubscription = this.httpService .post( 'http://localhost:3001/chat/completion', - { content: input }, + { content: input.message, model: input.model }, { responseType: 'stream' }, ) .subscribe({