@@ -3,7 +3,7 @@ import { ChatCompletionChunk } from './chat.model';
3
3
import { ChatProxyService , ChatService } from './chat.service' ;
4
4
import { UserService } from 'src/user/user.service' ;
5
5
import { Chat } from './chat.model' ;
6
- import { Message } from 'src/chat/message.model' ;
6
+ import { Message , Role } from 'src/chat/message.model' ;
7
7
import {
8
8
NewChatInput ,
9
9
UpateChatTitleInput ,
@@ -27,13 +27,15 @@ export class ChatResolver {
27
27
} )
28
28
async * chatStream ( @Args ( 'input' ) input : ChatInput ) {
29
29
const iterator = this . chatProxyService . streamChat ( input . message ) ;
30
+ this . chatService . saveMessage ( input . chatId , null , input . message , Role . User ) ;
30
31
try {
31
32
for await ( const chunk of iterator ) {
32
33
if ( chunk ) {
33
34
await this . chatService . saveMessage (
34
35
input . chatId ,
35
36
chunk . id ,
36
37
chunk . choices [ 0 ] . delta . content ,
38
+ Role . Model ,
37
39
) ;
38
40
yield chunk ;
39
41
}
@@ -58,6 +60,7 @@ export class ChatResolver {
58
60
return this . chatService . getMessageById ( messageId ) ;
59
61
}
60
62
63
+ @UseGuards ( ChatGuard )
61
64
@Query ( ( ) => [ Message ] )
62
65
async getChatHistory ( @Args ( 'chatId' ) chatId : string ) : Promise < Message [ ] > {
63
66
return this . chatService . getChatHistory ( chatId ) ;
@@ -70,7 +73,7 @@ export class ChatResolver {
70
73
}
71
74
72
75
// @Query (() => [Message])
73
- // getModelTags (@Args('chatId') chatId: string): Message[] {
76
+ // getAvailableModelTags (@Args('chatId') chatId: string): Message[] {
74
77
// return this.chatService.getChatHistory(chatId);
75
78
// }
76
79
0 commit comments