diff --git a/themes/common.css b/themes/common.css
index eb929cff..c28713c1 100644
--- a/themes/common.css
+++ b/themes/common.css
@@ -270,4 +270,9 @@
}
#gpt-submit-row #gpt-submit-dropdown > *:hover {
cursor: context-menu;
+}
+
+.tooltip.svelte-p2nen8.svelte-p2nen8 {
+ box-shadow: 10px 10px 15px rgba(0, 0, 0, 0.5);
+ left: 10px;
}
\ No newline at end of file
diff --git a/themes/common.js b/themes/common.js
index 13158931..038d74cf 100644
--- a/themes/common.js
+++ b/themes/common.js
@@ -953,26 +953,14 @@ function update_conversation_metadata() {
// console.log("conversation_metadata", conversation_metadata);
}
-// // Example schema for conversation data structure
-// const example_conversation = {
-// metadata: {
-// id: "550e8400-e29b-41d4-a716-446655440000",
-// timestamp: "2024-03-29T12:34:56.789Z"
-// },
-// conversation: [
-// ["user", "Hello, how are you?"],
-// ["assistant", "I'm doing well, thank you for asking! How can I help you today?"],
-// ["user", "What is the weather like?"],
-// ["assistant", "I don't have access to real-time weather information. You would need to check a weather service or look outside to know the current weather conditions."]
-// ],
-// preview: "A conversation about greetings and weather"
-// }
// Helper function to generate conversation preview
-function generatePreview(conversation, maxLength = 100) {
+function generatePreview(conversation, timestamp, maxLength = 100) {
if (!conversation || conversation.length === 0) return "";
// Join all messages with dash separator
- const preview = conversation.join("\n");
+ let preview = conversation.join("\n");
+ const readableDate = new Date(timestamp).toLocaleString();
+ preview = readableDate + "\n" + preview;
if (preview.length <= maxLength) return preview;
return preview.substring(0, maxLength) + "...";
}
@@ -990,7 +978,7 @@ async function save_conversation_history() {
metadata: conversation_metadata,
conversation: chatbot,
history: history,
- preview: generatePreview(JSON.parse(history))
+ preview: generatePreview(JSON.parse(history), conversation_metadata.timestamp)
};
// Get existing conversation history from local storage
@@ -1036,6 +1024,7 @@ async function save_conversation_history() {
}
}
+
function restore_chat_from_local_storage(event) {
let conversation = event.detail;
push_data_to_gradio_component(conversation.conversation, "gpt-chatbot", "obj");
@@ -1053,7 +1042,6 @@ function restore_chat_from_local_storage(event) {
setCookie("conversation_metadata", JSON.stringify(conversationData), 2);
// read from cookie
let conversation_metadata = getCookie("conversation_metadata");
- // console.log("conversation_metadata", conversation_metadata);
}
@@ -1066,6 +1054,7 @@ function clear_conversation(a, b, c) {
return reset_conversation(a, b);
}
+
function reset_conversation(a, b) {
// console.log("js_code_reset");
a = btoa(unescape(encodeURIComponent(JSON.stringify(a))));
@@ -1076,6 +1065,7 @@ function reset_conversation(a, b) {
return [[], [], "已重置"];
}
+
// clear -> 将 history 缓存至 history_cache -> 点击复原 -> restore_previous_chat() -> 触发elem_update_history -> 读取 history_cache
function restore_previous_chat() {
// console.log("restore_previous_chat");
@@ -1088,90 +1078,6 @@ function restore_previous_chat() {
// document.querySelector("#elem_update_history").click(); // in order to call set_history_gr_state, and send history state to server
}
-function gen_restore_btn() {
-
-
- // 创建按钮元素
- const button = document.createElement('div');
- // const recvIcon = '';
- const rec_svg = ''
- const recvIcon = '' + rec_svg + '';
-
- // 设置按钮的样式和属性
- button.id = 'floatingButton';
- button.className = 'glow';
- button.style.textAlign = 'center';
- button.style.position = 'fixed';
- button.style.bottom = '10px';
- button.style.left = '10px';
- button.style.width = '50px';
- button.style.height = '50px';
- button.style.borderRadius = '50%';
- button.style.backgroundColor = '#007bff';
- button.style.color = 'white';
- button.style.display = 'flex';
- button.style.alignItems = 'center';
- button.style.justifyContent = 'center';
- button.style.cursor = 'pointer';
- button.style.transition = 'all 0.3s ease';
- button.style.boxShadow = '0 0 10px rgba(0,0,0,0.2)';
-
- button.innerHTML = recvIcon;
-
- // 添加发光动画的关键帧
- const styleSheet = document.createElement('style');
- styleSheet.id = 'floatingButtonStyle';
- styleSheet.innerText = `
- @keyframes glow {
- from {
- box-shadow: 0 0 10px rgba(0,0,0,0.2);
- }
- to {
- box-shadow: 0 0 13px rgba(0,0,0,0.5);
- }
- }
- #floatingButton.glow {
- animation: glow 1s infinite alternate;
- }
- #floatingButton:hover {
- transform: scale(1.2);
- box-shadow: 0 0 20px rgba(0,0,0,0.4);
- }
- #floatingButton.disappearing {
- animation: shrinkAndDisappear 0.5s forwards;
- }
- `;
-
- // only add when not exist
- if (!document.getElementById('recvButtonStyle')) {
- document.head.appendChild(styleSheet);
- }
-
- // 鼠标悬停和移开的事件监听器
- button.addEventListener('mouseover', function () {
- this.textContent = "还原\n对话";
- });
-
- button.addEventListener('mouseout', function () {
- this.innerHTML = recvIcon;
- });
-
- // 点击事件监听器
- button.addEventListener('click', function () {
- // 添加一个类来触发缩小和消失的动画
- restore_previous_chat();
- this.classList.add('disappearing');
- // 在动画结束后移除按钮
- document.body.removeChild(this);
- });
- // only add when not exist
- if (!document.getElementById('recvButton')) {
- document.body.appendChild(button);
- }
-
- // 将按钮添加到页面中
-
-}
async function on_plugin_exe_complete(fn_name) {
// console.log(fn_name);
diff --git a/version b/version
index af84f9b1..2edd3596 100644
--- a/version
+++ b/version
@@ -1,5 +1,5 @@
{
- "version": 3.90,
+ "version": 3.91,
"show_feature": true,
- "new_feature": "支持chatgpt-4o-latest <-> 增加RAG组件 <-> 升级多合一主提交键"
+ "new_feature": "优化前端并修复TTS的BUG <-> 添加时间线回溯功能 <-> 支持chatgpt-4o-latest <-> 增加RAG组件 <-> 升级多合一主提交键"
}