Skip to content

Commit fd990cd

Browse files
committed
fix: use metadata
1 parent 76340be commit fd990cd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

frontend/src/views/conversation/components/MessageRowTextDisplay.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ function htmlToElement(html: string) {
4444
function processCitations() {
4545
const citationEls = contentRef.value!.querySelectorAll('span.browsing-citation');
4646
const citationUrls = [] as string[];
47-
console.log(citationEls);
4847
citationEls.forEach(el => {
4948
let metadata = JSON.parse(decodeURIComponent(el.getAttribute('data-citation') || '')) as OpenaiWebChatMessageMetadataCiteData;
50-
console.log(metadata);
5149
if (!metadata) return;
5250
let citationIndex = 0;
5351
if (citationUrls.includes(metadata.url!)) {

frontend/src/views/conversation/index.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ const sendMsg = async () => {
266266
new_conversation: currentConversationId.value!.startsWith('new_conversation'),
267267
model: currentConversation.value!.current_model!,
268268
content: text,
269-
openai_web_plugin_ids: currentConvHistory.value!.meta?.source === 'openai_web' ? currentConvHistory.value!.meta?.plugin_ids : undefined,
269+
openai_web_plugin_ids: currentConvHistory.value!.metadata?.source === 'openai_web' ? currentConvHistory.value!.metadata?.plugin_ids : undefined,
270270
};
271271
if (conversationStore.newConversation) {
272272
askRequest.new_title = conversationStore.newConversation.title;
@@ -279,6 +279,7 @@ const sendMsg = async () => {
279279
currentSendMessage.value = buildTemporaryMessage('user', text, currentConvHistory.value?.current_node, currentConversation.value!.current_model!);
280280
currentRecvMessages.value = [buildTemporaryMessage('assistant', '...', currentSendMessage.value.id, currentConversation.value!.current_model!)];
281281
const wsUrl = getAskWebsocketApiUrl();
282+
let hasError = false;
282283
let wsErrorMessage: string | null = null;
283284
console.log('Connecting to', wsUrl, askRequest);
284285
const webSocket = new WebSocket(wsUrl);
@@ -318,7 +319,8 @@ const sendMsg = async () => {
318319
respConversationId = response.conversation_id || null;
319320
canAbort.value = true;
320321
} else if (response.type === 'error') {
321-
console.error(response);
322+
hasError = true;
323+
console.error('websocket received error message', response);
322324
if (response.error_detail) {
323325
wsErrorMessage = response.error_detail;
324326
}
@@ -330,7 +332,7 @@ const sendMsg = async () => {
330332
aborter = null;
331333
canAbort.value = false;
332334
console.log('WebSocket connection is closed', event, isAborted.value);
333-
if (isAborted.value || event.code === 1000) {
335+
if ((isAborted.value || event.code === 1000) && !hasError) {
334336
// 正常关闭
335337
if (hasGotReply) {
336338
const allNewMessages = [currentSendMessage.value] as BaseChatMessage[];
@@ -346,7 +348,7 @@ const sendMsg = async () => {
346348
current_model: currentConvHistory.value!.current_model,
347349
create_time: currentConvHistory.value!.create_time,
348350
update_time: currentConvHistory.value!.update_time,
349-
meta: currentConvHistory.value!.meta,
351+
metadata: currentConvHistory.value!.metadata,
350352
mapping: {},
351353
current_node: '',
352354
} as BaseConversationHistory;
@@ -369,8 +371,8 @@ const sendMsg = async () => {
369371
title: t('errors.askError'),
370372
content:
371373
wsErrorMessage != null
372-
? `[${event.code}] ${t(event.reason)}: ${wsErrorMessage}`
373-
: `[${event.code}] ${t(event.reason)}`,
374+
? `${t(event.reason)}: ${wsErrorMessage}`
375+
: `${t(event.reason)}`,
374376
positiveText: t('commons.withdrawMessage'),
375377
negativeText: t('commons.cancel'),
376378
onPositiveClick: () => {

0 commit comments

Comments
 (0)