Skip to content

Commit 6691e6a

Browse files
authored
Support reasoning_content
1 parent 55784b2 commit 6691e6a

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

index.html

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@
334334
</v-container>
335335
<div class="input-area">
336336
<v-sheet elevation="0" class="input-panel d-flex align-end px-1">
337-
<v-speed-dial location="bottom right" transition="expand-transition" offset="50">
337+
<v-speed-dial transition="expand-transition" offset="10">
338338
<template v-slot:activator="{ props: activatorProps }">
339-
<v-fab v-bind="activatorProps" size="small" icon="mdi-cog" absolute
340-
class="input-icon"></v-fab>
339+
<v-btn v-bind="activatorProps" size="small" icon="mdi-cog" absolute
340+
class="input-icon"></v-btn>
341341
</template>
342342
<v-btn key="4" variant="elevated" @click="settingStore.initDialog" icon="mdi-api"
343343
v-tooltip:end="$t('$vuetify.dataIterator.i.title')">
@@ -920,6 +920,11 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
920920
</v-avatar>
921921
<tuui-chat-card :index="group.index" :messages="messages" :show-content="true">
922922
<template v-slot:default="{ showcontent }">
923+
<v-card-text v-if="group.message.reasoning_content" class="md-preview pt-1">
924+
<v-textarea class="conversation-area text-disabled font-italic" variant="plain"
925+
density='compact' auto-grow hide-details rows="1" readonly
926+
v-model="group.message.reasoning_content"></v-textarea>
927+
</v-card-text>
923928
<v-card-text v-if="showcontent" class="md-preview pt-1">
924929
<v-textarea class="conversation-area" variant="plain" density='compact' auto-grow
925930
hide-details rows="1" readonly v-model="group.message.content"></v-textarea>
@@ -965,6 +970,9 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
965970
</v-card-text>
966971
</v-card>
967972
<v-card class="mt-1" variant="flat" v-if="item.role == 'assistant'">
973+
<v-card-text v-if="item.reasoning_content" class="font-weight-bold">
974+
{{ item.reasoning_content }}
975+
</v-card-text>
968976
<v-card-text v-if="item.content" class="font-weight-bold">
969977
{{ item.content }}
970978
</v-card-text>
@@ -2013,18 +2021,21 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
20132021
const languageStore = useLanguageStore();
20142022

20152023
const createCompletion = async (rawconversation) => {
2016-
2017-
// const conversation = rawconversation.reduce((newConversation, item) => {
2018-
// if (item.role === "user" && item.content[0].type === "image_url") {
2019-
// // Image is too large, only latest query could be kept
2020-
// newConversation = [item];
2021-
// }
2022-
// else {
2023-
// newConversation.push(item);
2024-
// }
2025-
// return newConversation;
2026-
// }, []);
2027-
const conversation = rawconversation
2024+
const conversation = rawconversation.reduce((newConversation, item) => {
2025+
if (item.role === "assistant") {
2026+
const { reasoning_content, ...rest } = item;
2027+
newConversation.push(rest);
2028+
}
2029+
// (item.role === "user" && item.content[0].type === "image_url") {
2030+
// // Image is too large, only latest query could be kept
2031+
// newConversation = [item];
2032+
// }
2033+
else {
2034+
newConversation.push(item);
2035+
}
2036+
return newConversation;
2037+
}, []);
2038+
// const conversation = rawconversation
20282039
try {
20292040
messageStore.generating = true
20302041
// Create a completion (axios is not used here because it does not support streaming)
@@ -2091,14 +2102,15 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
20912102
// Add the bot message
20922103
messageStore.conversation.push({
20932104
content: "",
2105+
reasoning_content: "",
20942106
tool_calls: [],
20952107
role: "assistant",
20962108
});
20972109

20982110
let buffer = ''
20992111

21002112
// Read the stream
2101-
await read(reader, messageStore.conversation[messageStore.conversation.length - 1], buffer, chatbotStore.stream);
2113+
await read(reader, messageStore.conversation.at(-1), buffer, chatbotStore.stream);
21022114
} catch (error) {
21032115
snackbarStore.showErrorMessage(error.message);
21042116
} finally {
@@ -2202,6 +2214,8 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
22022214
target.content += choice
22032215
} else if (typeof choice.content === 'string') {
22042216
target.content += choice.content
2217+
} else if (typeof choice.reasoning_content === 'string') {
2218+
target.reasoning_content += choice.reasoning_content
22052219
}
22062220
parseTool(choice.tool_calls, target)
22072221
}
@@ -2229,7 +2243,7 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
22292243
}
22302244
};
22312245

2232-
watch(computed(() => messageStore.conversation[messageStore.conversation.length - 1]?.content),
2246+
watch(computed(() => messageStore.conversation.at(-1)?.content),
22332247
(newValue, oldValue) => {
22342248
if (newValue !== oldValue) {
22352249
asyncScrollToBottom();
@@ -2646,4 +2660,4 @@ <h5 class="font-weight-bold mb-4">MCP</h5>
26462660
</script>
26472661
</body>
26482662

2649-
</html>
2663+
</html>

0 commit comments

Comments
 (0)