Merge pull request #186 from Webifi/main
Fix restore chat JSON regression, Fix issue with summary continuation
This commit is contained in:
		
						commit
						bddfc81446
					
				|  | @ -417,9 +417,10 @@ export class ChatRequest { | ||||||
|           _this.updatingMessage = 'Summarizing...' |           _this.updatingMessage = 'Summarizing...' | ||||||
|           const summarizedIds = rw.map(m => m.uuid) |           const summarizedIds = rw.map(m => m.uuid) | ||||||
|           const summaryIds = [summaryResponse.uuid] |           const summaryIds = [summaryResponse.uuid] | ||||||
|  |           let loopCount = 0 | ||||||
|           while (continueCounter-- > 0) { |           while (continueCounter-- > 0) { | ||||||
|             try { |             try { | ||||||
|               const summary = await _this.sendRequest(top.concat(rw).concat([summaryRequest]), { |               const summary = await _this.sendRequest(top.concat(rw).concat([summaryRequest]).concat(loopCount > 0 ? [summaryResponse] : []), { | ||||||
|                 summaryRequest: true, |                 summaryRequest: true, | ||||||
|                 streaming: opts.streaming, |                 streaming: opts.streaming, | ||||||
|                 maxTokens: maxSummaryTokens, |                 maxTokens: maxSummaryTokens, | ||||||
|  | @ -452,6 +453,12 @@ export class ChatRequest { | ||||||
|                 // Try to get more of it |                 // Try to get more of it | ||||||
|                 delete summaryResponse.finish_reason |                 delete summaryResponse.finish_reason | ||||||
|                 _this.updatingMessage = 'Summarizing more...' |                 _this.updatingMessage = 'Summarizing more...' | ||||||
|  |                 let _recount = countPromptTokens(top.concat(rw).concat([summaryRequest]).concat([summaryResponse]), model) | ||||||
|  |                 while (rw.length && (_recount + maxSummaryTokens >= maxTokens)) { | ||||||
|  |                   rw.shift() | ||||||
|  |                   _recount = countPromptTokens(top.concat(rw).concat([summaryRequest]).concat([summaryResponse]), model) | ||||||
|  |                 } | ||||||
|  |                 loopCount++ | ||||||
|                 continue |                 continue | ||||||
|               } else { |               } else { | ||||||
|                 // We're done |                 // We're done | ||||||
|  |  | ||||||
|  | @ -245,7 +245,7 @@ | ||||||
|       setMessagesTimer = setTimeout(() => { |       setMessagesTimer = setTimeout(() => { | ||||||
|         getChat(chatId).messages = messages |         getChat(chatId).messages = messages | ||||||
|         saveChatStore() |         saveChatStore() | ||||||
|       }, 100) |       }, 200) | ||||||
|     } else { |     } else { | ||||||
|       getChat(chatId).messages = messages |       getChat(chatId).messages = messages | ||||||
|       saveChatStore() |       saveChatStore() | ||||||
|  | @ -351,7 +351,7 @@ | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   export const updateChatImages = async (chatId: number, chat: Chat) => { |   export const updateChatImages = async (chatId: number, chat: Chat) => { | ||||||
|     const messages = getMessages(chatId) |     const messages = chat.messages | ||||||
|     for (let i = 0; i < messages.length; i++) { |     for (let i = 0; i < messages.length; i++) { | ||||||
|       const m = messages[i] |       const m = messages[i] | ||||||
|       if (m.image) m.image = await setImage(chatId, m.image) |       if (m.image) m.image = await setImage(chatId, m.image) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Niek van der Maas
						Niek van der Maas