wangqifan hace 2 años
padre
commit
afab175c00
Se han modificado 1 ficheros con 5 adiciones y 3 borrados
  1. 5 3
      src/chat/chat.service.ts

+ 5 - 3
src/chat/chat.service.ts

@@ -63,12 +63,12 @@ export class ChatService {
     }
     }
 
 
     public async chat1(req, res) {
     public async chat1(req, res) {
-        const user = await this.chatPdfService.getUser(req.user.id)
+        const user = this.chatPdfService.getUser(req.user.id)
         res.setHeader('Content-type', 'application/octet-stream')
         res.setHeader('Content-type', 'application/octet-stream')
         const defSysMsg = (await this.sysConfigService.findByName('system_message'))?.value
         const defSysMsg = (await this.sysConfigService.findByName('system_message'))?.value
         const membership = await this.membershipService.getMembership(req.user.id)
         const membership = await this.membershipService.getMembership(req.user.id)
         const { prompt, options = {}, systemMessage, code, temperature, top_p } = req.body as RequestProps
         const { prompt, options = {}, systemMessage, code, temperature, top_p } = req.body as RequestProps
-        if (!code && !!user.apiUserId) {
+        if (!code) {
             if (!membership) {
             if (!membership) {
                 throw new ForbiddenException('请先成为会员')
                 throw new ForbiddenException('请先成为会员')
             }
             }
@@ -82,7 +82,9 @@ export class ChatService {
         try {
         try {
             let content = ''
             let content = ''
             const promptTime = new Date()
             const promptTime = new Date()
-            content = await this.chatPdfService.getSystemConfig(req.user.id, prompt, code, code, systemMessage)
+            if (!!(await user).apiUserId) {
+                content = await this.chatPdfService.getSystemConfig(req.user.id, prompt, code, code, systemMessage)
+            }
             let firstChunk = true
             let firstChunk = true
             const result = await chatReplyProcess({
             const result = await chatReplyProcess({
                 message: prompt,
                 message: prompt,