Просмотр исходного кода

feat: enhance JSON marshaling for Message and skip Fluent Read links in chat items

CaIon 7 месяцев назад
Родитель
Сommit
a47fc5a76b
2 измененных файлов с 16 добавлено и 0 удалено
  1. 8 0
      dto/openai_request.go
  2. 8 0
      web/src/components/layout/SiderBar.js

+ 8 - 0
dto/openai_request.go

@@ -140,6 +140,14 @@ type Message struct {
 	//parsedStringContent *string
 	//parsedStringContent *string
 }
 }
 
 
+func (m *Message) MarshalJSON() ([]byte, error) {
+	if m.Content == nil {
+		m.Content = ""
+	}
+	type Alias Message
+	return json.Marshal((*Alias)(m))
+}
+
 type MediaContent struct {
 type MediaContent struct {
 	Type       string `json:"type"`
 	Type       string `json:"type"`
 	Text       string `json:"text,omitempty"`
 	Text       string `json:"text,omitempty"`

+ 8 - 0
web/src/components/layout/SiderBar.js

@@ -201,12 +201,20 @@ const SiderBar = ({ onNavigate = () => { } }) => {
         if (Array.isArray(chats)) {
         if (Array.isArray(chats)) {
           let chatItems = [];
           let chatItems = [];
           for (let i = 0; i < chats.length; i++) {
           for (let i = 0; i < chats.length; i++) {
+            let shouldSkip = false;
             let chat = {};
             let chat = {};
             for (let key in chats[i]) {
             for (let key in chats[i]) {
+              let link = chats[i][key];
+              if (typeof link !== 'string') continue; // 确保链接是字符串
+              if (link.startsWith('fluent')) {
+                shouldSkip = true;
+                continue; // 跳过 Fluent Read
+              }
               chat.text = key;
               chat.text = key;
               chat.itemKey = 'chat' + i;
               chat.itemKey = 'chat' + i;
               chat.to = '/console/chat/' + i;
               chat.to = '/console/chat/' + i;
             }
             }
+            if (shouldSkip) continue;
             chatItems.push(chat);
             chatItems.push(chat);
           }
           }
           setChatItems(chatItems);
           setChatItems(chatItems);