wangqifan 2 vuotta sitten
vanhempi
commit
f1ac16c894
2 muutettua tiedostoa jossa 6 lisäystä ja 7 poistoa
  1. 3 4
      src/chat-pdf/chat-pdf.service.ts
  2. 3 3
      src/chat/chat.service.ts

+ 3 - 4
src/chat-pdf/chat-pdf.service.ts

@@ -283,11 +283,11 @@ export class ChatPdfService {
 
     async getSystemConfig(userId: number, q: string, name: string, code: string, sysMsg: string) {
         const user = await this.userService.findById(userId)
-        if (!!user.apiUserId) {
+        if (!user.apiUserId) {
             return sysMsg
         }
         let apiUser = await this.apiUserService.findById(user.apiUserId)
-        if (user.roles.includes(Role.User) && !!user.apiUserId) {
+        if (user.roles.includes(Role.User)) {
             code = apiUser.publicCode
         } else {
             code = apiUser.code
@@ -301,10 +301,9 @@ export class ChatPdfService {
         //     }
         // }
         return dedent`${apiUser.desc}'
-        根据相关性从高到低排序。 '
         这是用户提出的问题:
         ${q}
-        你只能根据用户的问题,以下面的内容和之前的聊天记录为准结合你的身份进行回答:
+        你只能根据用户的问题,以下面的内容为准结合你的身份进行回答:
         \`\`\`
         ${context.join('\n')}
         \`\`\`

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

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