mirror of
				https://github.com/vastxie/99AI.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	更新聊天服务标题名称代码为异步函数,提高速度
This commit is contained in:
		
							
								
								
									
										53
									
								
								dist/modules/chat/chat.service.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										53
									
								
								dist/modules/chat/chat.service.js
									
									
									
									
										vendored
									
									
								
							@@ -224,22 +224,45 @@ let ChatService = class ChatService {
 | 
				
			|||||||
        if (groupId) {
 | 
					        if (groupId) {
 | 
				
			||||||
            groupInfo = await this.chatGroupService.getGroupInfoFromId(groupId);
 | 
					            groupInfo = await this.chatGroupService.getGroupInfoFromId(groupId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ((groupInfo === null || groupInfo === void 0 ? void 0 : groupInfo.title) === '新对话') {
 | 
					        // if ((groupInfo === null || groupInfo === void 0 ? void 0 : groupInfo.title) === '新对话') {
 | 
				
			||||||
            let chatTitle;
 | 
					        //     let chatTitle;
 | 
				
			||||||
            if (modelType === 1) {
 | 
					        //     if (modelType === 1) {
 | 
				
			||||||
                chatTitle = await this.apiDataService.chatFree(`根据用户提问{${prompt}},给这个对话取一个名字,不超过10个字`);
 | 
					        //         chatTitle = await this.apiDataService.chatFree(`根据用户提问{${prompt}},给这个对话取一个名字,不超过10个字`);
 | 
				
			||||||
 | 
					        //     }
 | 
				
			||||||
 | 
					        //     else {
 | 
				
			||||||
 | 
					        //         chatTitle = '创意 AI';
 | 
				
			||||||
 | 
					        //     }
 | 
				
			||||||
 | 
					        //     await this.chatGroupService.update({
 | 
				
			||||||
 | 
					        //         groupId,
 | 
				
			||||||
 | 
					        //         title: chatTitle,
 | 
				
			||||||
 | 
					        //         isSticky: false,
 | 
				
			||||||
 | 
					        //         config: '',
 | 
				
			||||||
 | 
					        //     }, req);
 | 
				
			||||||
 | 
					        //     common_1.Logger.log(`更新标题名称为: ${chatTitle}`);
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //将更新标题名称的代码改为异步函数
 | 
				
			||||||
 | 
					        const updateTitleAsync = async () => {
 | 
				
			||||||
 | 
					            if ((groupInfo === null || groupInfo === void 0 ? void 0 : groupInfo.title) === '新对话') {
 | 
				
			||||||
 | 
					                let chatTitle;
 | 
				
			||||||
 | 
					                if (modelType === 1) {
 | 
				
			||||||
 | 
					                    chatTitle = await this.apiDataService.chatFree(`根据用户提问{${prompt}},给这个对话取一个名字,不超过10个字`);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else {
 | 
				
			||||||
 | 
					                    chatTitle = '创意 AI';
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                await this.chatGroupService.update({
 | 
				
			||||||
 | 
					                    groupId,
 | 
				
			||||||
 | 
					                    title: chatTitle,
 | 
				
			||||||
 | 
					                    isSticky: false,
 | 
				
			||||||
 | 
					                    config: '',
 | 
				
			||||||
 | 
					                }, req);
 | 
				
			||||||
 | 
					                common_1.Logger.log(`更新标题名称为: ${chatTitle}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					        };
 | 
				
			||||||
                chatTitle = '创意 AI';
 | 
					        
 | 
				
			||||||
            }
 | 
					        // 调用异步函数
 | 
				
			||||||
            await this.chatGroupService.update({
 | 
					        updateTitleAsync();
 | 
				
			||||||
                groupId,
 | 
					 | 
				
			||||||
                title: chatTitle,
 | 
					 | 
				
			||||||
                isSticky: false,
 | 
					 | 
				
			||||||
                config: '',
 | 
					 | 
				
			||||||
            }, req);
 | 
					 | 
				
			||||||
            common_1.Logger.log(`更新标题名称为: ${chatTitle}`);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (groupId) {
 | 
					        if (groupId) {
 | 
				
			||||||
            await this.chatGroupService.updateTime(groupId);
 | 
					            await this.chatGroupService.updateTime(groupId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user