Try to import chat name suggestion
This commit is contained in:
		
							parent
							
								
									cdbd17fa13
								
							
						
					
					
						commit
						df222e7028
					
				| 
						 | 
					@ -273,13 +273,16 @@
 | 
				
			||||||
  const suggestName = async (): Promise<void> => {
 | 
					  const suggestName = async (): Promise<void> => {
 | 
				
			||||||
    const suggestMessage: Message = {
 | 
					    const suggestMessage: Message = {
 | 
				
			||||||
      role: 'user',
 | 
					      role: 'user',
 | 
				
			||||||
      content: "Using appropriate language, please give a 5 word summary of this conversation's topic.",
 | 
					      content: "Using appropriate language, please tell me a short 6 word summary of this conversation's topic for use as a book title. Only respond with the summary.",
 | 
				
			||||||
      uuid: uuidv4()
 | 
					      uuid: uuidv4()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const suggestMessages = $currentChatMessages.slice(0, 10) // limit to first 10 messages
 | 
					    const suggestMessages = $currentChatMessages.slice(0, 10) // limit to first 10 messages
 | 
				
			||||||
    suggestMessages.push(suggestMessage)
 | 
					    suggestMessages.push(suggestMessage)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    chatRequest.updating = true
 | 
				
			||||||
 | 
					    chatRequest.updatingMessage = 'Getting suggestion for chat name...'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const response = await chatRequest.sendRequest(suggestMessages, {
 | 
					    const response = await chatRequest.sendRequest(suggestMessages, {
 | 
				
			||||||
      chat,
 | 
					      chat,
 | 
				
			||||||
      autoAddMessages: false,
 | 
					      autoAddMessages: false,
 | 
				
			||||||
| 
						 | 
					@ -297,7 +300,7 @@
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      response.getMessages().forEach(m => {
 | 
					      response.getMessages().forEach(m => {
 | 
				
			||||||
        const name = m.content.split(/\s+/).slice(0, 8).join(' ').trim()
 | 
					        const name = m.content.split(/\s+/).slice(0, 8).join(' ').replace(/^[^a-z0-9!?]+|[^a-z0-9!?]+$/gi, '').trim()
 | 
				
			||||||
        if (name) chat.name = name
 | 
					        if (name) chat.name = name
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      saveChatStore()
 | 
					      saveChatStore()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue