|
1 | 1 | let can_delete_history = false; |
2 | 2 | let max_chats_history = 512; |
| 3 | +let save_history = true; |
3 | 4 | let chosen_platform = localStorage.getItem('chosen_platform'); |
4 | 5 | let model = localStorage.getItem('selected_model'); |
5 | 6 | let is_mobile = window.matchMedia("(max-width: 768px)").matches; |
@@ -338,14 +339,17 @@ function addConversation(role, content, add_to_document = true, do_scroll = true |
338 | 339 |
|
339 | 340 |
|
340 | 341 | function saveLocalHistory() { |
341 | | - try { |
342 | | - localStorage.setItem(chat_id.toString(), JSON.stringify(conversations)); |
343 | | - }catch (e) { |
344 | | - if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED'){ |
345 | | - addWarning('Your browser has reached the maximum number of items allowed for local storage.' + |
346 | | - ' Please clear out some old chats to free up space.', false); |
347 | | - } |
348 | | - } |
| 342 | + if(save_history){ |
| 343 | + try { |
| 344 | + localStorage.setItem(chat_id.toString(), JSON.stringify(conversations)); |
| 345 | + }catch (e) { |
| 346 | + if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED'){ |
| 347 | + addWarning('Your browser has reached the maximum number of items allowed for local storage.' + |
| 348 | + ' Please clear out some old chats to free up space.', false); |
| 349 | + } |
| 350 | + } |
| 351 | + } |
| 352 | + save_history = true; |
349 | 353 | loadOldChatTopics(); |
350 | 354 | } |
351 | 355 |
|
@@ -1186,6 +1190,7 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') { |
1186 | 1190 | data.generationConfig.thinkingConfig = { thinkingBudget: 8000 }; |
1187 | 1191 | } |
1188 | 1192 | if(pog === 'pic' || pog === 'imagine'){ |
| 1193 | + save_history = false; |
1189 | 1194 | console.log('image generation command activated'); |
1190 | 1195 | gemini_model = "gemini-2.0-flash-preview-image-generation"; |
1191 | 1196 | } |
@@ -2823,7 +2828,7 @@ async function geminiStreamChat(fileUri, data, allow_tool_use = true) { |
2823 | 2828 | }) |
2824 | 2829 | if (story) { |
2825 | 2830 | // remove base64 image to save tokens |
2826 | | - conversations.messages[conversations.messages.length - 1].content = story.replace(/<img[^>]*>/g, ''); |
| 2831 | + conversations.messages[conversations.messages.length - 1].content = story.replace(/<img[^>]*>/g, ' '); |
2827 | 2832 | saveLocalHistory(); |
2828 | 2833 | botMessageDiv.innerHTML = converter.makeHtml(story); |
2829 | 2834 | } |
|
0 commit comments